[R-sig-ME] correlation structure in gls or lme/lmer with several observations per day
Olivier Renaud
Olivier.Renaud at unige.ch
Mon Oct 6 14:34:16 CEST 2008
Hi,
To simplify, suppose I have 2 observations each day for three days. I
would like to define the correlation structure of these 6 observations
as follows: the correlation of 2 observations on the same day is, say,
alpha, the correlation for 2 observations one day apart is rho and the
correlation for 2 observations 2 days apart is rho^2. I.e. I would like
to have an AR1 correlation + a correlation for the same day. I tried
with gls and lme from the nlme package, but with no success. One
difficulty arises since corAR1 seems to require only one observation per
day (see example below). Any idea on how to implement it, either with
special correlation structures, or through random effects in lme/lmer ?
should I try to define a "new" correlation structure corMultiAR1 ? If
so, where can I find help on how to write such a piece of code (
nlme:::corAR1 is not clear to me) ?
Olivier
*> obs6 <- matrix( c(1,2,3,4,5,6, 1,1,2,2,3,3), byrow=F, nc=2)
> dimnames(obs6) <- list(NULL, c("y","time"))
> obs6 <- data.frame(obs6)
> obs6
y time
1 1 1
2 2 1
3 3 2
4 4 2
5 5 3
6 6 3
> gls (y~1, correl=corAR1(0.0,~time), data=obs6)
Error in Initialize.corAR1(X[[1L]], ...) :
Covariate must have unique values within groups for corAR1 objects
*
--
Olivier.Renaud at unige.ch http://www.unige.ch/~renaud/
Methodology & Data Analysis - Psychology Dept - University of Geneva
UniMail, Office 4142 - 40, Bd du Pont d'Arve - CH-1211 Geneva 4
More information about the R-sig-mixed-models
mailing list