title: Multiple Linear Regression with Dichotomous Predictor Variables in R: to dummy-code or let R handle it?
body: <p>I am running a multiple linear regression for a course using R. One of my predictor variables that I want to include in the model is the sex of the individual coded as "m" and "f". I ran the model in R two different ways:</p>
  
  <p><strong>Model 1:</strong> "Sex" as the original categorical variable R</p>
  
  <pre><code>lm(formula = P_iP_Choice ~ Sex + Carapace + Competitor_Presence_BI + 
      PSI_Day1_Choice + AGG_AVERAGE, data = pano2014)
  
  Residuals:
       Min       1Q   Median       3Q      Max 
  -0.55241 -0.12879 -0.04414  0.13769  0.67394 
  
  Coefficients:
                         Estimate Std. Error t value Pr(&gt;|t|)    
  (Intercept)            -0.43031    0.23872  -1.803 0.074353 .  
  Sexm                   -0.28566    0.04685  -6.098 1.86e-08 ***
  Carapace                0.15558    0.04534   3.431 0.000863 ***
  Competitor_Presence_BI -0.03339    0.04532  -0.737 0.462870    
  PSI_Day1_Choice         0.15825    0.13029   1.215 0.227273    
  AGG_AVERAGE             0.15406    0.07790   1.978 0.050604 .  
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
  
  Residual standard error: 0.2375 on 104 degrees of freedom
  Multiple R-squared: 0.3146, Adjusted R-squared: 0.2817 
  F-statistic: 9.549 on 5 and 104 DF,  p-value: 1.611e-07 
  </code></pre>
  
  <p><strong>Model 2:</strong> Sex of the individuals as a different variable "Female" which was coded 0=males 1=females. </p>
  
  <pre><code>lm(formula = P_iP_Choice ~ Female + Carapace + Competitor_Presence_BI + 
      PSI_Day1_Choice + AGG_AVERAGE, data = pano2014)
  
  Residuals:
       Min       1Q   Median       3Q      Max 
  -0.55241 -0.12879 -0.04414  0.13769  0.67394 
  
  Coefficients:
                         Estimate Std. Error t value Pr(&gt;|t|)    
  (Intercept)            -0.71597    0.24498  -2.923 0.004260 ** 
  Female                  0.28566    0.04685   6.098 1.86e-08 ***
  Carapace                0.15558    0.04534   3.431 0.000863 ***
  Competitor_Presence_BI -0.03339    0.04532  -0.737 0.462870    
  PSI_Day1_Choice         0.15825    0.13029   1.215 0.227273    
  AGG_AVERAGE             0.15406    0.07790   1.978 0.050604 .  
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
  
  Residual standard error: 0.2375 on 104 degrees of freedom
  Multiple R-squared: 0.3146, Adjusted R-squared: 0.2817 
  F-statistic: 9.549 on 5 and 104 DF,  p-value: 1.611e-07
  </code></pre>
  
  <p>My understanding is that the difference in the coefficient of the intercept term is caused because in Model 1 R dummy-coded my categorical variable into a dichotomous variable and the variation in my response variable explained by "females" gets added to the intercept because R coded "Sex" using males. However in Model 2 the difference in running the model does not change the estimates of coefficients for other parts of my model. </p>
  
  <p>What I would like to know is what is the "correct" or widely accepted method of using dichotomous categorical variables in linear models? Dummy coding them yourself? Or letting R dummy code it?</p>