Hello everybody, I've been practicing with some data in R and SPSS and I noticed that there are some differences in ANOVA results. For example with : y<-c(1,2,34,2,3,45,2,1,67,3,2,67,2,2,98,4,4,23,1,1,23,2,3,45) and x<-rep(c(1,2,3),8) I get in R ( with summary(aov(y~x)) ) MSres=350.7 df=22 while in SPSS I get MSres=221.9 df=21 Can enyone explain me what is the problem or what am I doing wrong? Thanks for your interest a priori, Vasileios. --------------------------------- ÁðïêôÞóôå ôçí äùñåÜí óáò@yahoo.gr [[alternative HTML version deleted]]
vasilis pappas <vasileios_p at yahoo.gr> writes:> Hello everybody, > I've been practicing with some data in R and SPSS and I noticed that there are some differences in ANOVA results. > > For example with : > y<-c(1,2,34,2,3,45,2,1,67,3,2,67,2,2,98,4,4,23,1,1,23,2,3,45) and > x<-rep(c(1,2,3),8) > > I get in R ( with summary(aov(y~x)) ) > MSres=350.7 > df=22 > > while in SPSS I get > MSres=221.9 > df=21 > > Can enyone explain me what is the problem or what am I doing wrong?You need x <- factor(x) , I guess. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On Thu, 27 May 2004, [iso-8859-7] vasilis pappas wrote:> Hello everybody, > I've been practicing with some data in R and SPSS and I noticed that there are some differences in ANOVA results. > > For example with : > y<-c(1,2,34,2,3,45,2,1,67,3,2,67,2,2,98,4,4,23,1,1,23,2,3,45) and > x<-rep(c(1,2,3),8) > > I get in R ( with summary(aov(y~x)) ) > MSres=350.7 > df=22 > > while in SPSS I get > MSres=221.9 > df=21 > > Can enyone explain me what is the problem or what am I doing wrong?If you want to do a traditional one-way anova, you have to declare x to be a factor:> y<-c(1,2,34,2,3,45,2,1,67,3,2,67,2,2,98,4,4,23,1,1,23,2,3,45) > x<-rep(c(1,2,3),8) > summary(aov(y~x))Df Sum Sq Mean Sq F value Pr(>F) x 1 9264.1 9264.1 26.414 3.761e-05 *** Residuals 22 7715.9 350.7 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1> xf<-as.factor(x) > summary(aov(y~xf))Df Sum Sq Mean Sq F value Pr(>F) xf 2 12320.1 6160.0 27.761 1.269e-06 *** Residuals 21 4659.9 221.9 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Notice that when x is not a factor there is only one degree of freedom for x. David Scott _________________________________________________________________ David Scott Department of Statistics, Tamaki Campus The University of Auckland, PB 92019 Auckland NEW ZEALAND Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 Email: d.scott at auckland.ac.nz Graduate Officer, Department of Statistics
x is numeric, so R consider this to be a linear regression, not a 3 group analysis. To do the latter in R: x<-factor(1:3) Read the R Introductory manuals or the first few and other relevant chapters Venables' and Ripley's MASS first, please! -- Bert Gunter vasilis pappas wrote:> Hello everybody, > I've been practicing with some data in R and SPSS and I noticed that there are some differences in ANOVA results. > > For example with : > y<-c(1,2,34,2,3,45,2,1,67,3,2,67,2,2,98,4,4,23,1,1,23,2,3,45) and > x<-rep(c(1,2,3),8) > > I get in R ( with summary(aov(y~x)) ) > MSres=350.7 > df=22 > > while in SPSS I get > MSres=221.9 > df=21 > > Can enyone explain me what is the problem or what am I doing wrong? > Thanks for your interest a priori, > Vasileios. > > --------------------------------- > > ????????????????? ?????? ???????????? ??????@yahoo.gr > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! R-project.org/posting-guide.html-- Bert Gunter Non-Clinical Biostatistics Genentech MS: 240B Phone: 650-467-7374 "The business of the statistician is to catalyze the scientific learning process." -- George E.P. Box