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). Basically I want to model the
correlation with AR(1) or even ARMA along those 6 time points. First, how is
the order determined among the 6 levels of Time? Alphabetically? If so, I
would have to be very careful about their labels? Or can I specify their
order somehow? Secondly, 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. However
fm <- lme(Beta~Incent*Correctness+Oppor+(Time-1),
random = ~1|Subj, correlation=corAR1(0.5, form=~Time|Subj), Data)
gives me the following error:
Error in Initialize.corAR1(X[[2L]], ...) :
Covariate must have unique values within groups for corAR1 objects
Does it mean that the values on the time variable should be unique within
each subject? How can I define a group variable using more than just subject
since I have multiple combinations of subject and some other variables?
Any help is highly appreciated,
Gang
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data.txt
Url:
https://stat.ethz.ch/pipermail/r-help/attachments/20080125/a34d95d2/attachment.txt
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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data.txt
Url:
https://stat.ethz.ch/pipermail/r-help/attachments/20080125/2e7d148b/attachment.txt
Seemingly Similar Threads
- [R-sig-ME] account for temporal correlation
- How to extract the within group correlation structure matrix in "lme"
- Mixed Model notation SAS -> R
- Which R function for GLMM with binary response, nested random factors with temporal correlation?
- panel data unit root tests