Hi all, I have been struggling with ANOVAs on R. I am new to R, so I created a simple data frame, and I do some analyses on R just to learn R and then check them on SPSS to make sure that I am doing fine. Here is the problem that I've run into: when we use the aov function, it uses SS Type I as default (on SPSS it is Type III). Then I used the Anova function under cars package using the command: mod <- lm(DV ~ IV1*IV2, data = mydata, contrasts=list(IV1=contr.sum, IV2=contr.sum)) Anova(mod, type=”3”) Above, both of my IVs are between-SS variables. But still, results from this model do not match the results from SPSS (I have to say they are not too different either). But I was wondering if I am doing something wrong. If what I am doing is okay, then my next question is can I use the same set of commands (for Anova function) if one of my IVs was within-SS and the other IV was between-SS? Thank you very much! [[alternative HTML version deleted]]
On May 19, 2012, at 6:58 PM, jacaranda tree wrote:> Hi all, > I have been struggling with ANOVAs on R. I am new to R, so I created > a simple data frame, and I do some analyses on R just to learn R and > then check them on SPSS to make sure that I am doing fine. Here is > the problem that I've run into: > > when we use the aov function, it uses SS Type I as default (on SPSS > it is Type III). Then I used the Anova function under cars package > using the command: > > mod <- lm(DV > ~ IV1*IV2, data = mydata, > contrasts=list(IV1=contr.sum, > IV2=contr.sum)) > Anova(mod, type=?3?)Are you perhaps having a problem due to using a non-plain-text editor? Those quotes look "wrong". compare " with ? I do not think the second version of double-quote will be recognized correctly.> > Above, both of my IVs are between-SS variables. But still, results > from this model do not match the results from SPSS (I have to say > they are not too different either). But I was wondering if I am > doing something wrong. If what I am doing is okay, then my next > question is can I use the same set of commands (for Anova function) > if one of my IVs was within-SS and the other IV was between-SS? > > > Thank you very much! > [[alternative HTML version deleted]]Part of learning R is moving away from pretty versions of formatting, -- David Winsemius, MD West Hartford, CT
On May 20, 2012, at 00:58 , jacaranda tree wrote:> Hi all, > I have been struggling with ANOVAs on R. I am new to R, so I created a simple data frame, and I do some analyses on R just to learn R and then check them on SPSS to make sure that I am doing fine. Here is the problem that I've run into: > > when we use the aov function, it uses SS Type I as default (on SPSS it is Type III). Then I used the Anova function under cars package using the command: > > mod <- lm(DV > ~ IV1*IV2, data = mydata, > contrasts=list(IV1=contr.sum, > IV2=contr.sum)) > Anova(mod, type=?3?) > > Above, both of my IVs are between-SS variables. But still, results from this model do not match the results from SPSS (I have to say they are not too different either). But I was wondering if I am doing something wrong. If what I am doing is okay, then my next question is can I use the same set of commands (for Anova function) if one of my IVs was within-SS and the other IV was between-SS?Please at least provide some output to show the difference (both systems). It's pretty hard to guess what might have gone wrong based on partial code for one system and no data... (There are good reasons that base R doesn't do Type III SS. In my experience, they are either identical to Type I or test a hypothesis much more bizarre than the user expects.)> Thank you very much! > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Hi, you should give more details of your problem (at least some output, as Peter Daalgard says). But you are probably asking for something like this: http://www.r-bloggers.com/anova-%E2%80%93-type-iiiiii-ss-explained/ or many other webpages that you may find if you Google or R-seek with keywords like "anova" "type i", "type iii", etc. If you have within-subjects factors, the same commands will not give you a sensible result. If you want to use Anova() for that, you should use the arguments "idata", "idesign", etc., as explained in the help page of that function, or in the web appendix to the "CAR" book: http://socserv.mcmaster.ca/jfox/Books/Companion/appendix/Appendix-Multivariate-Linear-Models.pdf Helios De Rosario -- Helios de Rosario Mart?nez Researcher>>> El d?a 20/05/2012 a las 0:58, jacaranda tree<myjacaranda at yahoo.com> escribi?:> Hi all, > I have been struggling with ANOVAs on R. I am new to R, so I createda> simple data frame, and I do some analyses on R just to learn R andthen check> them on SPSS to make sure that I am doing fine. Here is the problemthat I've> run into: > > when we use the aov function, it uses SS Type I as default (on SPSSit is> Type III). Then I used the Anova function under cars package usingthe> command: > > mod <- lm(DV > ~ IV1*IV2, data = mydata, > contrasts=list(IV1=contr.sum, > IV2=contr.sum)) > Anova(mod, type=?3?) > > Above, both of my IVs are between-SS variables. But still, resultsfrom this> model do not match the results from SPSS (I have to say they are nottoo> different either). But I was wondering if I am doing something wrong.If what> I am doing is okay, then my next question is can I use the same setof> commands (for Anova function) if one of my IVs was within-SS and theother IV> was between-SS? > > > Thank you very much!INSTITUTO DE BIOMEC?NICA DE VALENCIA Universidad Polit?cnica de Valencia ? Edificio 9C Camino de Vera s/n ? 46022 VALENCIA (ESPA?A) Tel. +34 96 387 91 60 ? Fax +34 96 387 91 69 www.ibv.org Antes de imprimir este e-mail piense bien si es necesario hacerlo. En cumplimiento de la Ley Org?nica 15/1999 reguladora de la Protecci?n de Datos de Car?cter Personal, le informamos de que el presente mensaje contiene informaci?n confidencial, siendo para uso exclusivo del destinatario arriba indicado. En caso de no ser usted el destinatario del mismo le informamos que su recepci?n no le autoriza a su divulgaci?n o reproducci?n por cualquier medio, debiendo destruirlo de inmediato, rog?ndole lo notifique al remitente.