[R] Help Non-sequential ANOVAs

John Fox jfox at mcmaster.ca
Thu Jul 28 23:06:29 CEST 2011


Dear Ariane,

You must be referring to the Anova() function in the car package. The function doesn't have an appropriate method for gls objects. The error was produced by the default method, which is inappropriate for gls objects, as you discovered. I agree that it would be nice for Anova() to handle gls objects, and it shouldn't be too hard to do that. I'll consider this a request and put it on my to-do list.

On the other hand, it should not be difficult to do what you want, by dropping terms for the model and comparing alternative models by LR tests. It would likely make most sense to start with the interaction,

mod.1 <- gls(maturity~morph*month, 
    weights = varIdent(form = ~ 1 |morph*month),
    na.action=na.omit, method="ML")

mod.2 <- update(mod.1, . ~ . - morph:month)
anova(mod.1, mod.2)

Then, if the interaction is negligible, proceed to test the main effects:

mod.3 <- update(mod.2, . ~ . - morph)
anova(mod.2, mod.3)

mod.4 <- update(mod.2, . ~ . - month)
anova(mod.2, mod.4)

I hope this helps,
 John

On Thu, 28 Jul 2011 18:37:58 +0000
 Ariane Charaoui <ariane_cha at hotmail.com> wrote:
> 
> 
> 
> Hello,
> 
> I have data
> on the maturity of two morphs of fish. I want to test whether their maturity is
> evolving differently or not on a temporal scale (month). The maturity variable (independent
> variable) is continuous and the morph and month variables (dependant variables)
> are categorical. Because the data show variance heterogeneity, I modeled it
> with the function gls:
> 
> kg1 =
> gls(maturity~morph*month, weights = varIdent(form = ~ 1 |morph*month) ,
> na.action=na.omit, method="ML")
> 
> Next, I
> want to test if the two effects “morph” and “month” are significant so I use
> the function anova
> 
> anova(kg1)
> 
> Denom. DF: 75 
> 
>                                    numDF            F-value          p-value
> 
> (Intercept)                   1
>                      174.20833       <.0001
> 
> morph                         1  
>                    5.37109           0.0232
> 
> month                         5                      46.41181
>          <.0001
> 
> morph:month              5                       2.85388 
>         0.0206
> 
>  
> 
> The problem is that I
> want the results of a non-sequential anova. I tried also the function Anova,
> but I get an error message:
> 
>  
> 
> Error in !factors[,
> term2] : invalid argument type
> 
>  
> 
> Is there a way to fix
> this problem or is it possible to specify a non-sequential anova?
> 
>  
> 
> Thank you
> 
>  
> 
> Ariane
> 
> 
> 
> 
>  		 	   		  
> 	[[alternative HTML version deleted]]
> 

------------------------------------------------
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/



More information about the R-help mailing list