I would suggest running the code: options('contrasts')
on both machines to see if there is a difference. Having the default contrasts set differently would be one explanation. On Tue, Jan 14, 2014 at 2:28 PM, Marc Schwartz <marc_schwa...@me.com> wrote: > > On Jan 14, 2014, at 2:23 PM, CASENHISER, DEVIN M <de...@uthsc.edu> wrote: > >> 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 > > > On my Mac with R 3.0.2, I get the same output as you get on your Windows > machine. > > Something on your Mac is amiss, resulting in the recoding of 'sex' into a > factor with presumably 0/1 levels rather than the default textual factor > levels. If you try something like: > > model.frame(pitch ~ sex) > > the output should give you an indication of the actual data that is being > used for your model in each case. > > Either you have other code on your Mac that you did not include above, which > is modifying the contents of 'sex', or you have some other behavior going on > in the default workspace. > > I would check for other objects in your current workspace on the Mac, using > ls() for example, that might be conflicting. If you are running some type of > GUI on your Mac (eg. the default R.app or perhaps RStudio), try running R > from a terminal session, using 'R --vanilla' from the command line, to be > sure that you are not loading a default workspace containing objects that are > resulting in the altered behavior. Then re-try the example code. If that > resolves the issue, you may want to delete, or at least rename/move the > .RData file contained in your default working directory. > > Regards, > > Marc Schwartz > > ______________________________________________ > 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com ______________________________________________ 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.