Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Re: xtmixed slope cross validation

From (Yulia Marchenko, StataCorp)
Subject   st: Re: xtmixed slope cross validation
Date   Thu, 01 Dec 2011 10:39:49 -0600

Petra <> uses -predict, reffects- after -xtmixed- on
a test dataset which does not include the original data used in estimation and
receives a "no observations" error:

> I have predicted the slopes for memory decline in a sample of demented
> patients - in order to validate my model I split my sample into a "training"
> and "test" set with the idea to fit a model on the training set and then
> predict the slopes of the "test"set and compare these to the slopes of the
> whole sample.
> in the help for the predict command says that you can run a model using one
> dataset (I used the "train"), use a different dataset (then used the "test")
> and then used predict (in my case I typed:  predict r_slope1 r_inter1,
> reffects)- However, I get that message: no observations.  Does anyone have
> any idea of how to predict the slopes for the "test" set, using the slopes
> of the "train" set?

Unlike linear prediction, fitted values, etc., the computation of the
estimates (BLUPs) of random effects requires the original data used in
estimation be in memory.  We will improve the error message to clarify this.

To obtain BLUPs of random effects for the test data, Petra can do the

 . use <entire_data>                               // load training+test data
 . generate byte training = ...   // create indicator for the training sample
 . xtmixed ... if training            // run -xtmixed- on the training sample
 . predict ... if !training, reffects          // predict REs for test sample

-- Yulia
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index