[R] Trouble setting up correlation structure in lme

From: Gang Chen <gangchen6_at_gmail.com>
Date: Fri, 25 Jan 2008 16:15:15 -0500


Hi, I'm trying to set up AR(1) as a correlation structure in modeling some data (attached file data.txt in text format) with lme, but have trouble getting it to work.

Incent, Correctness, and Oppor are 3 categorical variables, Beta is a response variable, and Time is an equally-spaced variable with 6 time points (treated as a categorical variable as well). I'm not so sure about the form in corAR1 here. Since the correlation is supposed to be along the Time points, is form=~1 | Subject/Time a correct setup?

library(nlme)
Data <- read.table("data.txt", header=TRUE) fm <- lme(Beta~Incent*Correctness+Oppor+(Time-1),

    random = ~1|Subj, correlation=corAR1(0.5, form=~1|Subj/Time), Data)

The above lines do work, but my intuition seems pointing to a form like form = ~time | Subj/Incent/Correctness/Oppor. However

fm <- lme(Beta~Incent*Correctness+Oppor+(Time-1),

   random = ~1|Subj, correlation=corAR1(0.5, form=~Time|/Incent/Correctness/Oppor), Data)

gives me the following error:

Error in attributes(.Data) <- c(attributes(.Data), attrib) :   'names' attribute [270] must be the same length as the vector [0]

It is probably due to the fact some combinations in the data are missing, but I could not figure out how to group them so that the values on the time variable would be unique within each subject. So how can I do this?

Any help is highly appreciated,
Gang



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.
Received on Fri 25 Jan 2008 - 21:20:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jan 2008 - 21:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive