Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

lme4 - Linear mixed model with crossed repeated effects and AR1 covariance structure, in R

I have within-subject physiological data from participants (part), who have all looked at stimuli (reading newspapers) on three rounds (round), which each have five papers (paper), and within each there are variable number of visits (visit) in the newspaper. I have two fixed factors (CONDhier and CONDabund) plus interaction to predict the physiological state (e.g., EDA), which is usually autoregressive. I try to take into account individual differences in physiology with random effects (let's settle for intercept only for now), and perhaps fatigue over rounds with another random effect.

Thus, my model that I would like to run in R would be, in SPSS:

MIXED EDA BY CONDhier CONDabund  
 /FIXED=CONDhier CONDabund CONDhier*CONDabund | SSTYPE(3)  
 /RANDOM=INTERCEPT | SUBJECT(part) COVTYPE(VC)  
 /RANDOM=INTERCEPT | SUBJECT(part*round) COVTYPE(VC)  
 /PRINT=SOLUTION  
 /METHOD=REML  
 /REPEATED=visit | SUBJECT(part*round*paper) COVTYPE(AR1).

Now, I have understood that while lme does not do crossed terms well, lmer (that handles crossed terms with no problem) cannot use different covariance structures. I can run simple lme models such as

    lme(EDA ~ factor(CONDhier) * factor(CONDabund), random= ~1
   |part, na.action=na.exclude, data=phys2)

but a more complicated model is beyond me. I have read that crossed terms in lme can be done with random definitions like

    random=pdBlocked(list(pdCompSymm(~part), pdCompSymm(~round-1), pdCompSymm(~paper-1), 
pdCompSymm(~visit-1)))

but that seems to block the AR1 structure, and the second random intercept for part*round, from me. And I'm not so sure it's the same as my SPSS syntax anyway.

So, any advice? Although there are lots of different writings on lme and lmer, I couldn't find one that would have both crossed terms and AR1.

(Also, the syntax on lme seems quite obscure: from several different sources I have understood that | groups what is on the left under what's on the right, that / makes nested terms, that ~1 is random intercept, ~x is random slope, and ~1+x is both, but there seems to be at least : and -1 definitions that I couldn't find anywhere. Is there a tutorial that would explain all the different definitions?)

question from:https://stackoverflow.com/questions/20124109/linear-mixed-model-with-crossed-repeated-effects-and-ar1-covariance-structure-i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Consider the R package MCMCglmm which allows for complex mixed effects models.

https://cran.r-project.org/web/packages/MCMCglmm/vignettes/CourseNotes.pdf

Although it can be challenging to implement, it may solve the problems you've been having. It allows the fixed and random effects formulas to be given separately, eg.

fixed <- formula(EDA ~ CONDhier * CONDabund)
rand <- formula( ~(us(1+ CONDhier):part + us(1+ CONDhier):round + us(1+ CONDhier):paper + us(1+ CONDhier):visit))

The covariance structure between the random effects are given as coefficients which can be examined using summary() on the MCMCglmm object once the model has been run.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...