[R-sig-ME] Please post to the listserv
Prathiba Natesan Batley
pnb@t|ey @end|ng |rom gm@||@com
Wed Jan 25 23:14:23 CET 2023
Hello:
Could you please post the following to the listserv?
I am in a bit of a pickle here. I tried running a fixed effects model with
autocorrelation on a very small dataset (single case design). My syntax
look like this:
lm2 <- lme(y ~ 1 + treatment, random = ~1|pid, data = df, correlation =
corAR1())
I want to obtain the phi coefficient which I see is in
lm2$modelStruct$corStruct. But the moment I extract it and put it into a
matrix it stores a different value. In this case it should be -0.17 but is
stored as -0.35. Pls see below:
> lm.2$modelStruct$corStruct
Correlation structure of class corAR1 representing
Phi
-0.1743846
> cbind(1, lm.2$modelStruct$corStruct)
[,1] [,2]
[1,] 1 -0.3523706
Here is a sample dataset and syntax
d=.5
ICC=.1
m=6
phi=0
n=5
rep=1
df <- read.csv(paste0("data", d, "-", ICC, "-", phi, "-", m,
"-", n, "_", rep, ".csv"))
lm2 <- lme(y ~ 1 + treatment, random = ~1|pid, data = df, correlation =
corAR1())
phi.hps <- c(lm2[[1]][2]) #or lm2$modelStruct#corStruct
More information about the R-sig-mixed-models
mailing list