# [R-sig-ME] results lme unstructured covariance matrix, again

John Fox j|ox @end|ng |rom mcm@@ter@c@
Sat Jul 16 16:50:49 CEST 2022

```Dear Ben,

First, I'll make this into a reproducible example:

> set.seed(123)
> t1 <- c(rep(1, 10), rep(0, 10))
> t2 <- 1 - t1
> person <- rep(1:10, 2)
> y <- t2 + rnorm(20)
> da <- data.frame(y, t1, t2, person)

> library(nlme)

Then note that the random-effect specification 0 + t1 + t2 is simply a
reparametrization of 1 + t2 (i.e., 1 = t1 + t2), which produces the same
fit to the data (same fixed effects, same restricted log-likelihood):

> m1 <- lme(y ~ 1 + t2, random = ~ 0 + t1 + t2 | person, data=da)
> m2 <- lme(y ~ 1 + t2, random = ~ 1 + t2 | person, data=da)
> m1
Linear mixed-effects model fit by REML
Data: da
Log-restricted-likelihood: -25.92726
Fixed: y ~ 1 + t2
(Intercept)          t2
0.07462564  1.13399632

Random effects:
Formula: ~0 + t1 + t2 | person
Structure: General positive-definite, Log-Cholesky parametrization
StdDev    Corr
t1       0.8964136 t1
t2       0.9856215 0.647
Residual 0.3258015

Number of Observations: 20
Number of Groups: 10

> m2
Linear mixed-effects model fit by REML
Data: da
Log-restricted-likelihood: -25.92726
Fixed: y ~ 1 + t2
(Intercept)          t2
0.07462564  1.13399632

Random effects:
Formula: ~1 + t2 | person
Structure: General positive-definite, Log-Cholesky parametrization
StdDev    Corr
(Intercept) 0.8787887 (Intr)
t2          0.7540826 -0.302
Residual    0.3707215

Number of Observations: 20
Number of Groups: 10

Finally, it's unnecessary to supply the intercept 1 in the model formula
since the intercept is implied if it's not explicitly excluded:

> m3 <- lme(y ~ t2, random = ~ t2 | person, data=da)
> m3
Linear mixed-effects model fit by REML
Data: da
Log-restricted-likelihood: -25.92726
Fixed: y ~ t2
(Intercept)          t2
0.07462564  1.13399632

Random effects:
Formula: ~t2 | person
Structure: General positive-definite, Log-Cholesky parametrization
StdDev    Corr
(Intercept) 0.8787887 (Intr)
t2          0.7540826 -0.302
Residual    0.3707215

Number of Observations: 20
Number of Groups: 10

I hope this helps,
John

On 2022-07-16 10:05 a.m., ben pelzer wrote:
> Sorry, my previous mailed contained another question which is irrelevant...
> I deleted that now.
>
>
> Hi all,
>
> I have a question about results from lme of package nlme.
>
> Suppose the data consists of repeated measures at two fixed time points.
>
> I used the following equation:
>
>
>
> Model1 <- lme ( y ~ 1+t2 , random = ~ 0 + t1+t2|person, data=da)
>
>
>
> y is the dependent, t1 and t2 are binary dummy variables, valued 0 or 1,
> indicating the time point.  Model1 is estimated without any convergence
> problems and the reproduced (co)variances found with
>
>
>
> getVarCov(Model1, type=”marginal”, indivual=”1”)
>
>
>
> are identical to the observed (co)variances.
>
>
> My question is:  how can lme estimate 4 (co)variances with only 3 known
> (co)variances?
>
>
>
> The 4 estimates concern:
>
> -          std. deviation of the random effect of dummy t1
>
> -          std. deviation of the random effect of dummy t2
>
> -          covariance of the random effects of the dummies t1 and t2 t1
>
> -          residual std. error
>
>
>
> Related to the question above: how can the variances of the random effects
> and the residual std. error be interpreted?
>
>
>
> Thanks for any help,
>
>
>
> Ben.
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
John Fox, Professor Emeritus
McMaster University