[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: non-nested random effects

From   Jacob Wegelin <>
Subject   Re: st: non-nested random effects
Date   Fri, 10 Apr 2009 15:05:50 -0400

On Tue, Apr 7, 2009 at 12:20 PM, Roberto G. Gutierrez, StataCorp
<> wrote:
> Continuing the thread, Jacob Wegelin <> writes:
>> Thanks very much for your replies. Now the code leads to an error as
>> follows:
>> . xtmixed FinishTime Sex01F PL2Age2 Sex01FxPL2Age2 PL2Age3 nFin1974toPrev
>> MinCC PzCDrp MinCCxPzCDrp || _all:R.NAME || Year:
>> Performing EM optimization:
>> likelihood evaluates to missing
>> r(430);
> [...]
>> When I attempted to fit this model in SAS using GLIMMIX, the software hung
>> for several hours. My guess is that only software specifically designed for
>> sparse matrices can fit this model on these data (5000 observations, 22 Year
>> levels, 2900 NAME levels). If this is the case, does Stata plan to add
>> sparse matrix capability?
> In that case, Jacob should reverse the order of the levels.  Try
> . xtmixed FinishTime Sex01F PL2Age2 Sex01FxPL2Age2 PL2Age3 nFin1974toPrev
>   MinCC PzCDrp MinCCxPzCDrp || _all:R.Year || NAME:
> Jacob's original example had a matrix dimension of 2901.  The above has a
> dimension of 23.  Both fit the same model, but the latter assumes that "NAME"
> values are nested within all the data and can thus be treated as just random
> intercepts, realizations of a vector of dimension one.  As a general rule, in
> a crossed-effects model always put the "big" level variable last.

Thank you for the tip. With your suggested syntax (see below), Stata
fit the model and returned coefficients and SEs very close to what I
had obtained in R. But

(1) Why is different syntax needed for the two different random
effects? That is, why are the two random effects (group variables) not
treated symmetrically?

(2) Why does Stata's ability to fit the model depend on the order of
the random effects in the -xtmixed- command?

(3) Where do you check the matrix dimension of your model in Stata? Do
you refer to the number of columns of Z in the standard notation Y=X
beta + Z b + epsilon?

(4) How could Stata fit a model with 2930 + 22 BLUPs and a matrix
dimension of only 23? (Using -xtmixed postestimation- I obtained the
BLUPs for both random effects and confirmed that Stata computed 22
BLUPs for Year and 2930 for NAME.)

(5) Why does the output below state that the first group variable is
"_all" rather than Year; why does it not plainly state that Year has
22 levels?

(6) Finally, does this syntax extend to three or more non-nested
grouping variables?

. xtmixed FinishTime Sex01F PL2Age2 PL2Age3 nFin1974toPrev MinCC
PzCDrp Sex01FxMinCC PL2Age2xnFin1974toPrev PL2Age3xnFin1974toPrev
nFin1974toPrevxPzCDrp PL2Age3xMinCC  if FinYes==1 || _all:R.Year ||

Performing EM optimization:

Performing gradient-based optimization:

Iteration 0:   log restricted-likelihood = -11953.355
Iteration 1:   log restricted-likelihood = -11953.354

Computing standard errors:

Mixed-effects REML regression                   Number of obs      =      5276

                |   No. of       Observations per Group
 Group Variable |   Groups    Minimum    Average    Maximum
           _all |        1       5276     5276.0       5276
           NAME |     2933          1        1.8         21

Thanks again

Jacob A. Wegelin
Assistant Professor
Department of Biostatistics
Virginia Commonwealth University
730 East Broad Street Room 3006
P. O. Box 980032
Richmond VA 23298-0032

> As for sparse-matrix support, although we're very interested in how that area
> of research has developed, this is not an area of current active development.
> --Bobby
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index