Can you use Stata's predict command after runmlwin?

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >>
Post Reply
Posts: 1
Joined: Sat May 07, 2011 11:22 pm

Can you use Stata's predict command after runmlwin?

Post by jbherman »


any plan to extend the postestimation predict command to include random effects and work on out of sample data?

thanks, j
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Can you use Stata's predict command after runmlwin?

Post by GeorgeLeckie »

Dear J,

This is a good question. No we don't plan to extend Stata's postestimation predict command to work with runmlwin. This would involve working out and implementing the prediction formula for a very wide range of multilevel models. The aim of runmlwin is to make MLwiN functionality accessible to Stata users, not to directly implement MLwiN functionality in Stata. The latter would be much more ambitious!

However, the good news is that you can easily calculate a wide range of in-sample and out-of-sample predictions using runmlwin. All you need to do is to pull back the residuals from MLwiN and then do a small amount of data manipulation.

So for example, if you ran the following two-level growth trajectories model for child weight:

use, clear

. bysort id (age): gen occasion = _n

. generate cons = 1

. generate agesq = age^2

. runmlwin weight cons age agesq, ///
level2(id: cons age, residuals(u)) ///
level1(occ: cons) plugin

You would generate and graph the growth trajectory for the mean child as follows:

. generate xb = _b[cons] + _b[age]*age + _b[agesq]*agesq

. line xb age, sort

And you would generate and graph the child specific growth trajectories as follows:

. generate xbu = xb + u0 + u1*age

. line xbu age, connect(a)

For a wide range of examples, for both continuous and discrete response models, please see the runmlwin do-files for the MLwiN User Manual. ... /examples/

I hope this helps

Post Reply