How to run a multilevel model using fractional polynomial
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
How to run a multilevel model using fractional polynomial
Hi All,
Need help to run a multilevel model using fractional polynomial and imputed data with runmlwin.
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
Many thanks for your help
Likestatistic
Need help to run a multilevel model using fractional polynomial and imputed data with runmlwin.
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
Many thanks for your help
Likestatistic
-
- Site Admin
- Posts: 432
- Joined: Fri Apr 01, 2011 2:14 pm
Re: How to run a multilevel model using fractional polynomia
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
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
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: How to run a multilevel model using fractional polynomia
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
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
-
- Site Admin
- Posts: 432
- Joined: Fri Apr 01, 2011 2:14 pm
Re: How to run a multilevel model using fractional polynomia
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
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
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: How to run a multilevel model using fractional polynomia
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
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:
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
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
How to combine these stata commands: fp and runmlwin or mi, fp and runmlwin?
Thanks
Best wishes
Likestatistic
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
Code: Select all
. mi estimate, cmdok noisily: runmlwin normexam cons nmatpre, ///
level2(shoolid: cons nmatpre) ///
level1(childid: cons) ///
nopause
((_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*/
Code: Select all
. fp <nmatpre>: cmdok noisily: runmlwin normexam cons <nmatpre> level2(schoolid: cons) level1(chilid: cons) nopause nogroup
Thanks
Best wishes
Likestatistic
- Attachments
-
- pract4imputRealcom.xls
- (1.14 MiB) Downloaded 446 times
-
- Posts: 1354
- Joined: Mon Oct 19, 2009 10:34 am
Re: How to run a multilevel model using fractional polynomia
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:
If I run this I get the following error after approximately 10% of the models:
I have not yet looked into why this might be, and you might not get this behaviour with your model.
Code: Select all
webuse igg
gen cons = 1
gen id = _n
fp <age>: noisily runmlwin sqrtigg cons <age>, level1(id:cons) nopause nogroup
Code: Select all
e(sample) changed across estimation runs
r(498);
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: How to run a multilevel model using fractional polynomia
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);
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);
-
- Posts: 1354
- Joined: Mon Oct 19, 2009 10:34 am
Re: How to run a multilevel model using fractional polynomia
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
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: How to run a multilevel model using fractional polynomia
Hi!
Oh Thanks
It run without the nopause option but abort with the same message
e(sample) changed across estimation runs
r(498);
Oh Thanks
It run without the nopause option but abort with the same message
e(sample) changed across estimation runs
r(498);
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: How to run a multilevel model using fractional polynomia
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
Thanks