Skip to content
Prev 1201 / 20628 Next

Fitting a ``trivial'' model with lmer().

Can you post str(Rolf's_data)? If I understand correctly, y is a
temporally ordered vector of the measurements on each student, correct?
I further assume that tstnum is a factor that associates each element in
the vector y with a point in time. So, your data are something like:

Student	y	tstnum
1		y1	1
1		y2	2
1		y3	3
2		y1	1
2		y2	2
2		y3	3
...

If this is your data structure and your lmer syntax is:

lmer(y ~ tstnum + (0 + tstnum|stdnt), data=schooldat)

Then you will get the marginal effects for each time point as (mu +
alpha_i) and the variance/covariance matrix of the ranodm effects will
be very large and probably unstable. I don't know what you mean by the
"most general covariance matrix possible". As someone who models
longitudinal educational data on a daily basis, I would approach this
problem differently. 

Again, I don't think I understand your data structure entirely correct,
but assume the data structure I pose above is what you have. I would
first start with a model where tstnum is an integer and not a factor in
the data frame. Because it seems you want the marginal effects for time,
I might do something like:

lmer(y ~ factor(tstnum) + (tstnum|stdnt), data=schooldat)

In this formulation, treating time in this manner accounts for the
serial correlation between scores and reduces the number of elements in
the variance/covariance matrix.

Now, I experimented quickly with the egsingle data set that is in
library(mlmRev). Here is how my thinking plays out:
Linear mixed-effects model fit by REML 
Formula: math ~ factor(year) + (year | schoolid) 
   Data: egsingle 
   AIC   BIC logLik MLdeviance REMLdeviance
 20546 20608 -10264      20503        20528
Random effects:
 Groups   Name        Variance  Std.Dev. Corr  
 schoolid (Intercept) 0.1933133 0.439674       
          year        0.0098065 0.099028 0.555 
 Residual             0.9664253 0.983069       
number of obs: 7230, groups: schoolid, 60

Fixed effects:
                 Estimate Std. Error t value
(Intercept)      -3.20081    0.10074  -31.77
factor(year)-1.5  1.18359    0.09304   12.72
factor(year)-0.5  2.19556    0.09552   22.99
factor(year)0.5   2.88863    0.09991   28.91
factor(year)1.5   3.48153    0.10660   32.66
factor(year)2.5   4.29051    0.11451   37.47

Correlation of Fixed Effects:
            (Intr) f()-1. f()-0. f()0.5 f()1.5
fctr(y)-1.5 -0.831                            
fctr(y)-0.5 -0.816  0.914                     
fctr(yr)0.5 -0.785  0.893  0.927              
fctr(yr)1.5 -0.739  0.853  0.903  0.933       
fctr(yr)2.5 -0.691  0.809  0.872  0.915  0.932
Warning messages:
1: In .local(x, ..., value) :
  Estimated variance-covariance for factor 'schoolid' is singular

2: In .local(x, ..., value) :
  nlminb returned message false convergence (8)

The number of elements in the variance/covariance matrix in fm2 is large
and this model also has a singularity problem, similar to what you have
encountered. Let me stop here and let you add info or experiment with
what I pose.