I've noticed that I get different output when running a linear model on my Mac 
versus on my PC. Same effect, but the Mac assumes the predictor as a 0 level 
whereas the PC uses the first category (alphabetically).

So for example (using Bodo Winter's example from his online linear models 
tutorial):

pitch = c(233,204,242,130,112,142)
sex=c(rep("female",3),rep("male",3))

summary(lm(pitch~sex))

My Mac, running R 3.0.2, outputs:

Residuals:
      1       2       3       4       5       6
  6.667 -22.333  15.667   2.000 -16.000  14.000

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  177.167      7.201  24.601 1.62e-05 ***
sex1          49.167      7.201   6.827  0.00241 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 17.64 on 4 degrees of freedom
Multiple R-squared:  0.921, Adjusted R-squared:  0.9012
F-statistic: 46.61 on 1 and 4 DF,  p-value: 0.002407

But my PC, running R 3.0.2, outputs:

Residuals:
      1       2       3       4       5       6
  6.667 -22.333  15.667   2.000 -16.000  14.000

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)   226.33      10.18  22.224 2.43e-05 ***
sexmale       -98.33      14.40  -6.827  0.00241 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 17.64 on 4 degrees of freedom
Multiple R-squared:  0.921,     Adjusted R-squared:  0.9012
F-statistic: 46.61 on 1 and 4 DF,  p-value: 0.002407


I understand that these are the same (correct) answer, but it does make it a 
little more challenging to follow examples (when learning or teaching) given 
that the coefficient outputs are calculated differently.

I don't suppose that there is way to easily change either output so that they 
correspond (some setting I've overlooked perhaps)?

Thanks and Cheers!
Devin


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to