How to run a multilevel model using fractional polynomial

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 >> http://www.bristol.ac.uk/cmm/software/runmlwin/
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: How to run a multilevel model using fractional polynomia

Post by ChrisCharlton »

I believe that I have now tracked down the cause of the problem. To work around it you can search for the the following line in runmlwin.ado:

Code: Select all

				quietly compress `newvars'
and change it to:

Code: Select all

				if "`newvars'" ~= "" {
					quietly compress `newvars'
				}
You can find where runmlwin.ado is located with the command:

Code: Select all

which runmlwin
Once you have done this you will also need to add the option forcerecast to your command, i.e.

Code: Select all

fp <nmatpre>: noisily runmlwin normexam cons <nmatpre> level2(schoolid: cons) level1(childid: cons) nopause nogroup forcerecast
This fix will be included in the next release of -runmlwin-.
likestatistic
Posts: 39
Joined: Fri Sep 12, 2014 4:11 pm

Re: How to run a multilevel model using fractional polynomia

Post by likestatistic »

Should the section look like this after correction :?:

if _caller() >= 11 {
local 0 `.`o'.eq indepvars `e''
syntax varlist(fv)
fvexpand `varlist'
local fpname`e' `r(varlist)'
fvrevar `r(varlist)'
local fp`e' `r(varlist)'
local newvars :list fp`e' - varlist
if "`newvars'" ~= "" {
quietly compress `newvars'
}
local i = 1
foreach x in `fp`e'' {
if `:list x in newvars' & "`:type `x''" == "double" {
quietly recast float `x', force
display as error "`:word `i' of `fpname`e''' has more precision that MLwiN can handle, forcing to float"
}
local ++i
}
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: How to run a multilevel model using fractional polynomia

Post by ChrisCharlton »

My version (see below) has some additional checks, as it contains some enhancements for the next release, but that looks correct to me.

Code: Select all

			if _caller() >= 11 {
				local 0 `.`o'.eq indepvars `e''
				syntax varlist(fv)
				fvexpand `varlist'
				local fpname`e' `r(varlist)'
				fvrevar `r(varlist)'
				local fp`e' `r(varlist)'
				local newvars :list fp`e' - varlist
				capture _rmcoll `fp`e'', noconstant
				local fp`e' `r(varlist)'
				if "`newvars'" ~= "" {
					quietly compress `newvars'
				}
				local i = 1
				foreach x in `fp`e'' {
					local xname :word `i' of `fpname`e''
					if substr("`x'", 1, 2) == "o." {
						local fp`e' : list fp`e' - x
						local fpname`e' : list fpname`e' - xname
						display as text "note: `xname' omitted because of collinearity"
					}
					else {
						if `:list x in newvars' & "`:type `x''" == "double" {
							quietly recast float `x', force
							display as error "`xname' has more precision that MLwiN can handle, forcing to float"
						}					
						local ++i
					}
				}
			}
			else {
				local fpname`e' `.`o'.eq indepvars `e''
				local fp`e' `.`o'.eq indepvars `e''
			}
likestatistic
Posts: 39
Joined: Fri Sep 12, 2014 4:11 pm

Re: How to run a multilevel model using fractional polynomia

Post by likestatistic »

Hi ChrisCharlton,

I have tried to correct the section step by step to see what happen. I still have an abortion of the system after 10%. :oops:
Maybe the new release include other corrections that work with this section of the macro.
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: How to run a multilevel model using fractional polynomia

Post by ChrisCharlton »

I should have mentioned that after changing the .ado file you will either need to restart Stata or issue a

Code: Select all

discard
command. If you still have the error after doing this could confirm whether the error message is the same as you were getting before?
likestatistic
Posts: 39
Joined: Fri Sep 12, 2014 4:11 pm

Re: How to run a multilevel model using fractional polynomia

Post by likestatistic »

I still have this message :oops:

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

end of do-file

r(498);

and the programme didn't fit until 10% again
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: How to run a multilevel model using fractional polynomia

Post by ChrisCharlton »

Could you try replacing your runmlwin.ado file with the one in the attached zip file and let us know whether that works for you?
Attachments
runmlwin.zip
(49.45 KiB) Downloaded 458 times
likestatistic
Posts: 39
Joined: Fri Sep 12, 2014 4:11 pm

Re: How to run a multilevel model using fractional polynomia

Post by likestatistic »

Hi ChrisCharlton,

I changed my do file and restarted my computer but I still got the same message with my data and the example I send to you. :oops:

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

end of do-file

r(498);
ChrisCharlton
Posts: 1353
Joined: Mon Oct 19, 2009 10:34 am

Re: How to run a multilevel model using fractional polynomia

Post by ChrisCharlton »

Could you check whether you still have the same problem with the Stata example I posted?, i.e.

Code: Select all

webuse igg
gen cons = 1
gen id = _n
fp <age>: noisily runmlwin sqrtigg cons <age>, level1(id:cons) nopause nogroup
If you do then it is likely that Stata is picking up an older version from elsewhere. To check this use the command:

Code: Select all

which runmlwin
and then check that the file it references is the same as the one that you added and that the modified date stamp is recent.

If it still doesn't work then you will need to search your computer to see whether you can find other versions that it might be picking up on.
likestatistic
Posts: 39
Joined: Fri Sep 12, 2014 4:11 pm

Re: How to run a multilevel model using fractional polynomia

Post by likestatistic »

clear
webuse igg
(Immunoglobulin in children)
gen cons = 1
gen id = _n
fp <age>: noisily runmlwin sqrtigg cons <age>, level1(id:cons) nopause nogroup

I am getting these messages

age_1 is held to more precision than MLwiN can handle, to reduce the precision use recast float
> age_1, force
When fitting the model with fractional powers (-2), fp: ran the command
. noisily runmlwin sqrtigg cons age_1, level1(id:cons) nopause nogroup
and it produced the above error message.
r(198);

which runmlwin
c:\ado\plus\runmlwin.ado
*! runmlwin.ado, George Leckie and Chris Charlton, 31Jul2013
Post Reply