I think this is a case of using dput to make sure that the datasets are the same.
I was bitten once by this and now dput between machines. Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marc Schwartz Sent: Wednesday, 15 January 2014 07:29 To: CASENHISER, DEVIN M Cc: r-help@r-project.org Subject: Re: [R] Different output for lm Mac vs PC 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. ______________________________________________ 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.