[R-sig-ME] Please post to the listserv

John Fox j|ox @end|ng |rom mcm@@ter@c@
Thu Jan 26 00:21:06 CET 2023


Dear Prathiba,

m2$modelStruct$corStruct is a fairly complex object, not a simple 
number. Try:

	coef(m2$modelStruct$corStruct, unconstrained=FALSE)

(By the way, I couldn't make sense of the sample dataset you said you 
supplied, so I couldn't check my answer. Also, your model is a mixed 
model, not a fixed-effects model -- there are random effects.)

I hope this helps,
  John

-- 
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

On 2023-01-25 5:14 p.m., Prathiba Natesan Batley wrote:
> 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
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list