Hello George or Chris,
I tried to use runMLwin for my research (house price), but have some basic questions to ask you - I have searched to find the answer but could not quite find where I have done wrong
1) I have following the instruction to change my reference category using the following command, but it does not seem it omitted the defined catergory though.
char type[omit] 4
char new[omit] 2
2) I wish to put interaction of categorical variable (eg. type and old/new house). I remembered that we could just put the a*b, and the main effect will be correctly specified (without duplication). I therefore used the following command, but I have an error message saying "_Itype_2 _Itype_3 _Itype_4 _Inew_2 _Iduration_2 are duplicated in the fixed part". My command is as below
xi: runmlwin logeprice cons i.type*i.new i.type*i.duration i.new*i.duration level2(neighbourhood:cons) level1(house:cons) nopause
Thank you for your help!
reference group + interaction
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: reference group + interaction
1) I'm not sure why the omit syntax isn't working for you as the following seems to work as expected:
2) The documentation for xi (see http://www.stata.com/help.cgi?xi) indicates that the syntax i.varname1*i.varname2 will create dummies for all main effects and interactions of these categories. As your categorical variables are all involved in more than one interaction it is generating variables for the main effects more than once, hence the error message that you are seeing. If your second variable was continuous you could avoid duplicating the main effect with the i.varname1|varname3 syntax, but I don't see an equivalent syntax for categorical variables.
runmlwin does support the newer factor variable syntax (see http://www.stata.com/help.cgi?fvvarlist) for univariate models, which I believe does allow what you are wanting. Here is the second model from above fitted using this syntax:
I believe that the following syntax should be what you require for your model:
or if you want to use ## to avoid specifying a couple of the main effects:
This also allows an alternative method for specifying the base category via the ib#. syntax.
Code: Select all
. use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear
. xi: runmlwin normexam cons i.schgend*i.vrband, level2(school: cons) level1(student: cons) nopause
i.schgend _Ischgend_1-3 (naturally coded; _Ischgend_1 omitted)
i.vrband _Ivrband_1-3 (naturally coded; _Ivrband_1 omitted)
i.sch~d*i.vrb~d _IschXvrb_#_# (coded as above)
MLwiN 2.31 multilevel model Number of obs = 4059
Normal response model
Estimation algorithm: IGLS
-----------------------------------------------------------
| No. of Observations per Group
Level Variable | Groups Minimum Average Maximum
----------------+------------------------------------------
school | 65 2 62.4 198
-----------------------------------------------------------
Run time (seconds) = 1.45
Number of iterations = 3
Log likelihood = -4816.6846
Deviance = 9633.3691
------------------------------------------------------------------------------
normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cons | .5713802 .0601215 9.50 0.000 .4535441 .6892163
_Ischgend_2 | .1975847 .129877 1.52 0.128 -.0569695 .452139
_Ischgend_3 | .3030197 .0994147 3.05 0.002 .1081706 .4978689
_Ivrband_2 | -.7717841 .038821 -19.88 0.000 -.8478719 -.6956962
_Ivrband_3 | -1.572875 .0568076 -27.69 0.000 -1.684215 -1.461534
_IschXvr~2_2 | -.1270987 .0886994 -1.43 0.152 -.3009464 .0467491
_IschXvr~2_3 | -.2003226 .1248478 -1.60 0.109 -.4450198 .0443745
_IschXvr~3_2 | -.0974494 .0625693 -1.56 0.119 -.2200829 .0251842
_IschXvr~3_3 | -.0409024 .0941537 -0.43 0.664 -.2254402 .1436355
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school |
var(cons) | .0883445 .0175274 .0539913 .1226977
-----------------------------+------------------------------------------------
Level 1: student |
var(cons) | .6065081 .0135719 .5799077 .6331085
------------------------------------------------------------------------------
. char schgend[omit] 3
. xi: runmlwin normexam cons i.schgend*i.vrband, level2(school: cons) level1(student: cons) nopause
i.schgend _Ischgend_1-3 (naturally coded; _Ischgend_3 omitted)
i.vrband _Ivrband_1-3 (naturally coded; _Ivrband_1 omitted)
i.sch~d*i.vrb~d _IschXvrb_#_# (coded as above)
MLwiN 2.31 multilevel model Number of obs = 4059
Normal response model
Estimation algorithm: IGLS
-----------------------------------------------------------
| No. of Observations per Group
Level Variable | Groups Minimum Average Maximum
----------------+------------------------------------------
school | 65 2 62.4 198
-----------------------------------------------------------
Run time (seconds) = 1.48
Number of iterations = 3
Log likelihood = -4816.6846
Deviance = 9633.3691
------------------------------------------------------------------------------
normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cons | .8743999 .079175 11.04 0.000 .7192198 1.02958
_Ischgend_1 | -.3030197 .0994147 -3.05 0.002 -.4978689 -.1081706
_Ischgend_2 | -.1054349 .1397216 -0.75 0.450 -.3792842 .1684143
_Ivrband_2 | -.8692334 .0490698 -17.71 0.000 -.9654085 -.7730584
_Ivrband_3 | -1.613777 .0750854 -21.49 0.000 -1.760942 -1.466612
_IschXvr~1_2 | .0974494 .0625693 1.56 0.119 -.0251842 .2200829
_IschXvr~1_3 | .0409024 .0941537 0.43 0.664 -.1436355 .2254402
_IschXvr~2_2 | -.0296493 .0936395 -0.32 0.752 -.2131794 .1538808
_IschXvr~2_3 | -.1594203 .1341554 -1.19 0.235 -.4223601 .1035196
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school |
var(cons) | .0883445 .0175274 .0539913 .1226977
-----------------------------+------------------------------------------------
Level 1: student |
var(cons) | .6065081 .0135719 .5799077 .6331085
------------------------------------------------------------------------------
runmlwin does support the newer factor variable syntax (see http://www.stata.com/help.cgi?fvvarlist) for univariate models, which I believe does allow what you are wanting. Here is the second model from above fitted using this syntax:
Code: Select all
. runmlwin normexam cons i.schgend i.vrband i.schgend#i.vrband, level2(school: cons) level1(student: cons) nopause
note: 1b.schgend omitted because of collinearity
note: 1b.vrband omitted because of collinearity
note: 1b.schgend#1b.vrband omitted because of collinearity
note: 1b.schgend#2o.vrband omitted because of collinearity
note: 1b.schgend#3o.vrband omitted because of collinearity
note: 2o.schgend#1b.vrband omitted because of collinearity
note: 3o.schgend#1b.vrband omitted because of collinearity
MLwiN 2.31 multilevel model Number of obs = 4059
Normal response model
Estimation algorithm: IGLS
-----------------------------------------------------------
| No. of Observations per Group
Level Variable | Groups Minimum Average Maximum
----------------+------------------------------------------
school | 65 2 62.4 198
-----------------------------------------------------------
Run time (seconds) = 1.84
Number of iterations = 3
Log likelihood = -4816.6846
Deviance = 9633.3691
------------------------------------------------------------------------------
normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cons | .5713802 .0601215 9.50 0.000 .4535441 .6892163
_2_schgend | .1975847 .129877 1.52 0.128 -.0569695 .452139
_3_schgend | .3030197 .0994147 3.05 0.002 .1081706 .4978689
_2_vrband | -.7717841 .038821 -19.88 0.000 -.8478719 -.6956962
_3_vrband | -1.572875 .0568076 -27.69 0.000 -1.684215 -1.461534
_2_schgend~d | -.1270987 .0886994 -1.43 0.152 -.3009464 .0467491
_2_schgend~d | -.2003226 .1248478 -1.60 0.109 -.4450198 .0443745
_3_schgend~d | -.0974494 .0625693 -1.56 0.119 -.2200829 .0251842
_3_schgend~d | -.0409024 .0941537 -0.43 0.664 -.2254402 .1436355
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school |
var(cons) | .0883445 .0175274 .0539913 .1226977
-----------------------------+------------------------------------------------
Level 1: student |
var(cons) | .6065081 .0135719 .5799077 .6331085
------------------------------------------------------------------------------
Code: Select all
runmlwin logeprice cons i.type i.new i.duration i.type#i.new i.type#i.duration i.new#i.duration level2(neighbourhood:cons) level1(house:cons) nopause
Code: Select all
runmlwin logeprice cons i.type##i.new i.duration i.type#i.duration i.new#i.duration level2(neighbourhood:cons) level1(house:cons) nopause