[R] Please help: ANOVA with SS Type III for unequal sample sized data

Ista Zahn izahn at psych.rochester.edu
Wed Oct 20 15:57:34 CEST 2010


Hi Jeong,

On Wed, Oct 20, 2010 at 5:25 AM, BumSeok Jeong <bumseok.jeong at gmail.com> wrote:
> Dear R experts,
>
> I'm beginner.
> My question about ANOVA for unequal sample sized data should be obsolete but
> I can not clarify it.
>
> I have a dataset from 23 males and 18 females.
> I measured one condition('cond') with 4 levels.
> So I'd like to see main effect of gender, cond and gender by cond
> interaction and also postHoc test. (In fact, I have to do anova 90 times)
> *
> 1. Question about constrast stuff for type III*
> After googling, I found a document (
> https://stat.ethz.ch/pipermail/r-help/2001-October/015889.html) and it
> looked like make sense.
> This below is what I did on R and I encountered 'error message'.
>
> library(car)
> results_lmanova <- list()
> for(i in 1:90) {sum=subset(ast.ast_coef, ast.ast_coef$coef_thr==i)
>                results_lmanova[[i]] <- anova(lm(sum$ast.values ~ sum$gender
> * sum$cond,
>                                     contrasts=list(sum$gender='contr.sum',
> sum$cond='contr.sum'),
>                                      type='III'))

anova calculates only "type I" SS. You need to replace anova with
Anova (notice the capital A). Also, the type argument is in the wrong
place (in you code it is an argument to lm() when it should be an
argument to Anova(). ) Replace ", type='III')) with " ), type='III')

This is all untested, but try correcting those errors and see what happens.

-Ista
>
> If remove the row of 'contrasts=....', some results showed up and my anxiety
> also did..
> Even if change from 'contr.sum' to 'contr.sum(2)' for gender and to
> 'contr.sum(4)' for cond, it did not work. And my brain also did not.
>
> Please let me know what is error in my command.
>
> *2. Question about postHoc test*
> In my understand, TukeyHSD is for the results of aov() with type I, not
> anova() with type III which is I used.
> Please let me know what is the best postHoc test for the results from
> anova() with type III.
> Is multcomp a way?
>
> thank you,
>
> Jeong
>
>        [[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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list