ahimsa campos-arceiz
2007-Feb-28 08:23 UTC
[R] no df to test the effect of an interaccion on a lmer mixed model
Dear useRs,
I am fitting a mixed model using the function lmer from the package lme4,
but I have some problems when I try to test the effect of my factors of
interest.
First let me explain the structure of the model:
I'm measuring animal movements. Explicitly, I am interested in displacement
(straight-line distance from an initial point). Displacements are measured
longitudinally, with one measurement every 2h (up to 20h). A series of
measurements from 2 to 20h makes a "displacement series".
We have 2 study areas, with 3 individuals per study area (individuals are
different in each area), and data have been taken in 2 seasons for each
individual. In each season, we have 10 replicates per individual (10
displacement series).
Factors are thus:
A = study area. Fixed factor with 2 levels
id = individual animal. Random factor with 6 levels, nested within area.
S = season. Fixed factor, with 2 levels.
t = time of measurement. Longitudinal measurement with 10 levels.
R = replica. 10 replicates per individual and season
y = response variable (distance).
my interest is to know:
(1) whether there are seasonal differences in displacement, understood as
the interaction S*t, and
(2) whether there are between-area differences in displacement, the
interaction A*t
my full model is
full.model <- lmer(y ~ A*S*t + (S*t | id), data , method="ML")
then I first test for the interaction A*S*t, to know whether I can eliminate
it from the full model:
red.mod1 <- lmer(y ~ A*S*t - A:S:t + (S*t | id), data ,
method="ML")
anova (full.model, red.mod1)
results:
Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)
red.model1 17 10495.0 10603.7 -5230.5
full model 18 10493.7 10608.8 -5228.8 3.3247 1 0.06824 .
with this small value of p, I cannot eliminate A*S*t from the full model
next I check for seasonal differences as S*t
red.mod2 <- lmer(y ~ A*S*t - S:t + (S*t | id), data , method="ML")
red.mod3 <- lmer(y ~ A*S*t + (S + t | id), data , method="ML") #
to see if
there are individual differences in their response to season
anova (full.model, red.mod2, red.mod3)
results
Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)
red.mod3 14 10525.0 10614.5 -5248.5
full.model 18 10493.7 10608.8 -5228.8 39.346 4 5.908e-08 ***
red.mod2 18 10493.7 10608.8 -5228.8 0.000 0
there are no Df to test the effect of the interaction S*t,
Can anybody give any insight on how should I test the effect of this
interaction?
Really thank you!
Ahimsa
below I include the script with a dummy data set. Using these data results
are different, but data structure is equivalent to mine.
####################################
library(lme4)
# dataset
A <- as.factor(rep(1:2, each=600))
id <- as.factor(rep(1:6, each=200))
S <- as.factor(rep(1:2, each=100, times=6))
R <- as.factor(rep(1:10, each = 10, times = 12))
t <- rep(c(2,4,6,8,10,12,14,16,18,20), times=120)
y <- rnorm(1200, mean=100, sd=25)
dummy.df <- data.frame(A,id,S,R,t,y)
summary(dummy.df)
str(dummy.df )
# fitting the full model
full.model <- lmer(y ~ A*S*t + (S*t|id), dummy.df, method="ML")
summary(full.model)
# reduced model without the interaction S:t
red.model1 <- lmer(y ~ A*S*t - S:t + (S*t|id), dummy.df,
method="ML")
summary(red.model1)
# reduced model 2 without the interaction id:S:t
red.model2 <- lmer(y ~ A*S*t + (S+t|id), dummy.df, method="ML")
summary(red.model2)
anova ( full.model, red.model1, red.model2)
# I continue later testing the effect of A*t...
--
ahimsa campos-arceiz
www.camposarceiz.com
[[alternative HTML version deleted]]
