Re: [R] Differences in estimates calculated in R and SPSS

From: John Fox <jfox_at_mcmaster.ca>
Date: Sat 14 Oct 2006 - 17:25:01 GMT


Dear Katja,

If the fitted values are the same and the coefficients differ, then the parametrization of the models differ. I suspect that SPSS is using sum-to-zero contrasts (contr.sum in R, coded -1, 0, 1), while R uses dummy-coded contrasts (contr.treatment, coded 0,1) by default. If this is the case, then you should get the same coefficients in R by setting options(contrasts=c("contr.sum", "contr.poly")). There are other ways of doing this as well.

See ?options, ?contr.treatment, etc., and section 11.1.1 of the introductory manual that comes with R (and perhaps read something more detailed about how R handles factors in linear models).

I hope this helps,
 John



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Katja
> Walentowitz
> Sent: Saturday, October 14, 2006 11:08 AM
> To: Dirk Eddelbuettel
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] Differences in estimates calculated in R and SPSS
>
> I have compared the models, they are exactly the same. The
> same for the data. The problem occurs most often when I use
> the aov-function.
> When I calculate the fitted values, they are the same, but
> the intercept is somewhat different. In R the intercept is
> more or less the mean of the regressand values, as defined in
> some statistical books - but still: it is not the exact mean.
> In SPSS it is not.
>
> Thanks again for helping me.
> Katja
>
> On 10/14/06, Dirk Eddelbuettel <edd@debian.org> wrote:
> >
> >
> > On 14 October 2006 at 16:59, Katja Walentowitz wrote:
> > | I am a bit confused because I get different estimates for the
> > | regression coefficients from R and SPSS.
> > | Does anyone have an explanation for this? As I am not so
> > | experienced in data analysis, I don't know why this happens.
> >
> > Maybe you are not estimating the same model -- one may have an
> > intercept, and the other doesn't. Or maybe something happens while
> > you read the data -- start by comparing summary statistics,
> > tabulations and plots of your data.
> >
> > But as you didn't tell what you estimated, and how, it is a
> tad hard
> > for use to guess. There is a Posting Guide recommending
> how to phrase
> > questions and what to suplly ...
> >
> > Dirk
> >
> > --
> > Hell, there are no rules here - we're trying to accomplish
> something.
> > -- Thomas
> A. Edison
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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. Received on Sun Oct 15 03:28:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 14 Oct 2006 - 18:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.