Skip to content
Prev 16348 / 20628 Next

What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure?

Hi Maarten,

Here is an example which shows the unstructured model with gls and the 
not converging model with lmer. In this example, we have three occasions 
on which the dependent variable "test" was observed, for each of 20 
persons. In total then we have 60 observations, with the "occasion" 
variable taking values 1, 2, 3. The data also contain the person id 
variable "person" and dummy variables "occ1", "occ2", "occ3" as (0 or 1) 
indicators of the occasion.  In the syntax below, a factor variable 
"factor1" is created also, to be in line with your question.

I used two different specifications for the unstructured model with gls, 
depending on whether dummies or factor1 was used. For lmer, I used these 
three different specifications, none of which converges.

The lmer syntax was added only to show the problem which lmer has with 
estimating an unstructured correlation pattern.


#------------------------------------------------------------------------------------------------------------------------------------------------------------
mydata <- 
read.table(url("https://surfdrive.surf.nl/files/index.php/s/XfE3mtbFCTUejIz/download"), 
header=TRUE)


#-------------------  unstructured correlation matrix 
-----------------------


# Before applying a model, let's first examine the variances and 
correlations
# for the three occasions. We have a strong violation of the assumptions
# of homoscedasticity and compound symmetry.
test1 <- mydata[mydata$occasion==1,"test"]
test2 <- mydata[mydata$occasion==2,"test"]
test3 <- mydata[mydata$occasion==3,"test"]
cor(cbind(test1, test2, test3))
var(cbind(test1, test2, test3))

# Unstructured model using gls from package nlme and dummies for occasion.
# This model exactly reproduces the observed correlations between occasions.
unstruc.gls1 <- gls(test ~ 1+ occ2 + occ3,
                            method="REML", data=mydata,
                            correlation=corSymm(form = ~ 1 |person),
                            weights = varIdent(form = ~1|occasion))
summary(unstruc.gls1)


# Unstructured model using factor1 for occasion instead of dummies.
# The results are exactly the same as those above, as should be.
mydata$factor1 <- as.factor(mydata$occasion)
unstruc.gls2 <- gls(test ~ factor1,
                     method="REML", data=mydata,
                     correlation=corSymm(form = ~ 1|person),
                     weights = varIdent(form = ~1|factor1))
summary(unstruc.gls2)


# Unstructured model using lmer and dummies for occasion: does not 
converge.
unstruc.lmer <- lmer(test ~ 1+ occ2 + occ3 + (1+occ2+occ3|person),
                      data=mydata, REML=TRUE)
summary(unstruc.lmer)


# Unstructured model using lmer and factor1 for occasion: does not 
converge.
unstruc.lmer <- lmer(test ~ 1+ factor1 + (1+factor1|person),
                      data=mydata, REML=TRUE)
summary(unstruc.lmer)


# Unstructured model using lmer and factor1 for occasion, no intercept 
specified: does not converge.
unstruc.lmer <- lmer(test ~ factor1 + (factor1|person),
                      data=mydata, REML=TRUE)
summary(unstruc.lmer)
On 21/03/2018 13:07, Maarten Jung wrote:
the two specifications are not equivalent in the sense that lmer also 
tries to estimate residual variance. However, with the given lmer model 
specification, the random factor1 effects capture all variance there is 
and no residual variance remains.
Regards, Ben.

  
  

Thread (14 messages)

Douglas Bates What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 20 Rune Haubo What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 21 Ben Pelzer What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 21 Maarten Jung What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 21 Ben Pelzer What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 21 Maarten Jung What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Ben Pelzer What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Maarten Jung What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Phillip Alday What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Ben Pelzer What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Rune Haubo What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Maarten Jung What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Rune Haubo What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22 Maarten Jung What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure? Mar 22