Page 2 of 3

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 3:18 pm
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-.

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 4:35 pm
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
}

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 4:49 pm
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''
			}

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 5:08 pm
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.

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 5:19 pm
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?

Re: How to run a multilevel model using fractional polynomia

Posted: Tue Sep 16, 2014 5:27 pm
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

Re: How to run a multilevel model using fractional polynomia

Posted: Wed Sep 17, 2014 8:52 am
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?

Re: How to run a multilevel model using fractional polynomia

Posted: Wed Sep 17, 2014 9:13 am
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);

Re: How to run a multilevel model using fractional polynomia

Posted: Wed Sep 17, 2014 10:21 am
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.

Re: How to run a multilevel model using fractional polynomia

Posted: Wed Sep 17, 2014 10:39 am
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