Page 1 of 3

How to run a multilevel model using fractional polynomial

Posted: Fri Sep 12, 2014 4:32 pm
by likestatistic
Hi All,

Need help to run a multilevel model using fractional polynomial and imputed data with runmlwin. :oops:

I imputed missing data on Realcom and tried this (below), but it doesn’t work.

fp <imputed var mean>, cmdok noisily: runmlwin outcome cons <imputed var mean> level2(area: cons) level1(indiv: cons) nopause nogroup

I am not sure I could use the mean value of my variable imputed on Realcom :shock:

Many thanks for your help :D

Likestatistic

Re: How to run a multilevel model using fractional polynomia

Posted: Fri Sep 12, 2014 6:22 pm
by GeorgeLeckie
Hi,

It is not immediately clear to us what problem you have run into.

(1) First get what you want working with Stata's regress command in place of our runmlwin command.

(2) Only once you are happy with (1) attempt to switch back to the runmlwin command.

If (1) doesn't work then the problem may lie with realcom.

If (1) works, but (2) doesn't work then the problem may lie with runmlwin, in which case please provide us with the working output from (1) so that we can have a better sense of what is going on.

Best wishes

George

Re: How to run a multilevel model using fractional polynomia

Posted: Mon Sep 15, 2014 8:53 am
by likestatistic
Hi,

I am not sure I could combine a fractional polynomial command (fp) with a runmlwin command.
Stata consider the "cmdok noisily: runmlwin" as a "fp" option and the program doesn't run.

Thanks for your help

Likestatistic

Re: How to run a multilevel model using fractional polynomia

Posted: Mon Sep 15, 2014 12:21 pm
by GeorgeLeckie
Hi Likestatistic,

We are not that familiar with fractional polynomials. So please will you provide us with an example which you have got working with Stata's regress command, but fails to work with our runmlwin command. We will then try to diagnose what the problem is. Please provide both the commands and data (simply use one of Stata's example datasets).

Best wishes

George

Re: How to run a multilevel model using fractional polynomia

Posted: Mon Sep 15, 2014 3:14 pm
by likestatistic
Hi GeorgeLeckie

Here an example:

It is not a good example because the test scores have been normalised, but I could't find a stata example with multilevel data non-normalised. nmatpre had missing values, these values have been imputed on REALCOM and imported on stata giving the following file

Code: Select all

. insheet using "N:\pract4imputRealcom.csv", clear
I can generate a model of interest: regression of normexam on nmatpre. If the data were imputed on stata it could be easy to apply:

Code: Select all

. mi estimate, cmdok noisily: runmlwin normexam cons nmatpre, ///
    level2(shoolid: cons nmatpre) ///
    level1(childid: cons) ///
    nopause
The first concern is: how to use runmlwin with these imputed values? Should I consider the mean value of the imputed variables?

((_1_nmatpre + _2_nmatpre + _3_nmatpre + _4_nmatpre + _5_nmatpre + _6_nmatpre + _7_nmatpre + _8_nmatpre + _9_nmatpre + _10_nmatpre)/10)

The second concern: considering normexam and nmatpre non normals and that there are no missing values in nmatpre. To determine the powers of the fractional polynomial we could apply the following command in stata. To allow the fractional polynomial model to work on these data we need to remove the negative values

Code: Select all

. drop if normexam<0
. drop if nmatpre<0
. fp <nmatpre>: xtmixed normexam <nmatpre> || schoolid: /*we could consider the power of 1*/
I Would like to determine the power of the fractional polynomial using runmlwin. The following command doesn't work because stata consider "cmdok noisily:" as a "fp" option

Code: Select all

. fp <nmatpre>: cmdok noisily: runmlwin normexam cons <nmatpre> level2(schoolid: cons) level1(chilid: cons) nopause nogroup
How to combine these stata commands: fp and runmlwin or mi, fp and runmlwin?

Thanks

Best wishes

Likestatistic

Re: How to run a multilevel model using fractional polynomia

Posted: Mon Sep 15, 2014 5:30 pm
by ChrisCharlton
cmdok is an option to allow the -mi- command work with non-standard estimation commands, and does not exist in the -fp- command. To replicate the first -fp- example in http://www.stata.com/help.cgi?fp with runmlwin I believe that the code would be something like:

Code: Select all

webuse igg
gen cons = 1
gen id = _n
fp <age>: noisily runmlwin sqrtigg cons <age>, level1(id:cons) nopause nogroup
If I run this I get the following error after approximately 10% of the models:

Code: Select all

e(sample) changed across estimation runs
r(498);
I have not yet looked into why this might be, and you might not get this behaviour with your model.

Re: How to run a multilevel model using fractional polynomia

Posted: Mon Sep 15, 2014 5:49 pm
by likestatistic
Hi,

When I apply it to the data I provided:
fp <nmatpre>: noisily runmlwin normexam cons <nmatpre> level2(schoolid: cons) level1(childid: cons) nopause nogroup

I get the following error:

option level1() required
fp: ran the command
. noisily runmlwin normexam cons nmatpre level2(schoolid: cons) level1(childid: cons)
nopause nogroup
and it produced the above error message.
r(198);

:oops:

Re: How to run a multilevel model using fractional polynomia

Posted: Mon Sep 15, 2014 5:53 pm
by ChrisCharlton
It looks like you're missing a comma before the level options. I think your command should be:

Code: Select all

fp <nmatpre>: noisily runmlwin normexam cons <nmatpre>, level2(schoolid: cons) level1(childid: cons) nopause nogroup

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 9:03 am
by likestatistic
Hi!

Oh Thanks :D
It run without the nopause option but abort with the same message :(

e(sample) changed across estimation runs
r(498);

:?:

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 12:06 pm
by likestatistic
Does the system abort because the option “fp <var>” allowing it to generate the different powers of var is not included on the runmlwin macro? :?

Thanks