can't proceed to multiple membership model

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/
Post Reply
morning03
Posts: 12
Joined: Thu Jul 05, 2012 7:17 am

can't proceed to multiple membership model

Post by morning03 »

Hi.

Using panel data, I am trying to estimate a logistic model (on the probability of a residential move) that varies according to an individual's hhld membership: (single-person household vs. couple/multiple-member hhld) (Kindly see attached file equation.jpg). I have 35 explanatory variables. Since, over time an individual will move to different households, I suspect that the random effects for the single-hhlds will be correlated with the random effects for those who are in multiple-member hhld.

To allow variation according to hhld membership, I created two sets of explanatory variables using the stata codes below. Hence, instead of the original 35 explanatory variables, now I have 70 X's.

foreach x of varlist x1 - x35 {

g `x'_C = `x' if single_multiple == 0
replace `x'_C = 0 if single_multiple == 1

g `x'_S = `x' if single_multiple== 1
replace `x'_S = 0 if single_multiple == 0
}

g Xsingle = multiple == 1
g Xmultiple = multiple == 0

sort individual_id survey_round
runmlwin y Xsingle Xmultiple x1_S - X35_S X1_C - X35_C, level2(individual_id: Xsingle Xmultiple) level1(survey_round:) discrete(distribution(binomial) link(logit) denominator(cons) pql2) nopause


When I estimated the model (using pql2), I get sensible results for the fixed part and the random part of the model. However, I get the following results for the random parts:

Xlone -1.20876
Xmultiple -2.16036
X~3_dummy2_S 0.833651
Xduratio~2_S -0.2658277
Xduratio~3_S -0.7484888
Xduratio~4_S -0.9980441
Xduratio~5_S -1.107969
Xduratio~6_S -1.040654
Xduratio~7_S -1.198664
Xduratio~8_S -1.012838
Xduratio~9_S -1.051786
Xduratio~0_S -1.305826
Xage_S -0.0370093
Xagesq_S 0.0004113
Xsex_S -0.0564445
Xunion_for~S 1.163148
Xcount_d~2_S -0.0704926
Xcount_d~3_S -0.2510984
XYounges~2_S -0.0355757
XYounges~3_S -0.1854347
XYounges~4_S -0.0609936
Xbirth_o~2_S 0.1123636
Xbirth_o~3_S 0.3094418
Xbirth_o~4_S 0.1860407
Xbachelor_S 0.0104119
Xemployed_S 0.0781567
Xdisposabl~S -0.0136075
Xrooms_f~2_S -0.3622691
Xrooms_f~3_S -0.3467808
Xrooms_f~4_S -0.2675135
Xstate_d~2_S 0.0098394
Xstate_d~3_S 0.2527815
Xstate_d~4_S -0.1358728
Xstate_d~5_S 0.011654
Xstate_d~6_S -0.0160611
Xstate_d~7_S 0.5865496
Xstate_d~8_S 0.0413127
Xremote_~2_S 0.1837123
Xremote_~3_S 0.0382212
Xremote_~4_S 0.0971053
X~3_dummy2_C 1.325249
Xduratio~2_C -0.2336334
Xduratio~3_C -0.3403614
Xduratio~4_C -0.4833024
Xduratio~5_C -0.6244527
Xduratio~6_C -0.6558545
Xduratio~7_C -0.763012
Xduratio~8_C -0.5978259
Xduratio~9_C -0.9004535
Xduratio~0_C -1.090067
Xage_C -0.0292599
Xagesq_C 0.0002226
Xsex_C -0.0051237
Xliving_wi~C 0.1740561
Xunion_for~C 2.791115
Xunion_dis~C 1.651798
Xcount_d~2_C 0.1020503
Xcount_d~3_C -0.0524026
XYounges~2_C -0.1085454
XYounges~3_C -0.2272663
XYounges~4_C -0.4325886
Xbirth_o~2_C 0.0589249
Xbirth_o~3_C 0.2571513
Xbirth_o~4_C 0.0725413
Xbachelor_C 0.0805691
Xbachel~er_C 0.0614389
Xemployed_C 0.067457
Xemploye~r_C -0.0838872
Xdisposabl~C 0.0134741
Xrooms_f~2_C -0.1373251
Xrooms_f~3_C -0.0143071
Xrooms_f~4_C 0.2658966
Xstate_d~2_C -0.0605082
Xstate_d~3_C 0.1859525
Xstate_d~4_C -0.2454838
Xstate_d~5_C 0.0804148
Xstate_d~6_C 0.0089504
Xstate_d~7_C 0.0593975
Xstate_d~8_C -0.0818213
Xremote_~2_C 0.1057225
Xremote_~3_C 0.2880648
Xremote_~4_C 0.3106011

var(Xsingle) 0.1495671
cov(Xsingle,Xmultiple) 0.1146221
var(Xsingle) 0.1297719


Since I suspect that other household members within the household might influence the decision of an individual to move, I tried estimating a multiple membership model using the following code:

sort individual_id survey_round
runmlwin y Xsingle Xmultiple x1_S - X35_S X1_C - X35_C, level2(individual_id: Xlone Xmultiple, mmids(individual_id id_mem2 id_mem3 id_mem4 id_mem5 id_mem6) mmweights(weight_mem1 /// weight_mem2 weight_mem3 weight_mem4 weight_mem5 weight_mem6)) level1(survey_round:) discrete(distribution(binomial) link(logit) denominator(cons)) /// mcmc(burnin(1000) chain(10000)) initsprevious nopause mlwinpath(C:\Program Files\MLwiN v2.25\mlwin.exe)


However, mlwin keeps on returning an error message that says: "matrix must be positive definite for inversion". I am not sure what is causing this. The correlation between the two random effects in the previous model is within the unit circle (0.82). I also checked the diagonal elements of the system matrix e(V) and all of them are non-zero and positive (except for the last column which is 0 for var(bcons_1) which seems to be natural since I am using a logistic model).

Thank you very much for your insights.
Attachments
equation.jpg
equation.jpg (12.33 KiB) Viewed 5653 times
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: can't proceed to multiple membership model

Post by GeorgeLeckie »

Hi morning03,

Two points about your intercepts

(1) You define Xsingle and Xmultiple and enter these into the level-2 random part of your PQL2 model. But you enter Xlone Xmultiple into the level-2 random part of your MCMC model. This mismatch may be the source of your error message

(2) You define Xsingle and Xmultiple as follows

g Xsingle = multiple == 1
g Xmultiple = multiple == 0

From the variable names you use, I would have thought you would want the following

g Xsingle = multiple == 0
g Xmultiple = multiple == 1

If the above does not solve your problem, then please simplify your model and paste the log file output. Simplify teh model by removing all the fixed effects except the intercepts. Paste the log-file output for two models. First the PQL2 two-level hierarchical model then then MCMC two-level multiple membership model.

Best wishes

George
morning03
Posts: 12
Joined: Thu Jul 05, 2012 7:17 am

Re: can't proceed to multiple membership model

Post by morning03 »

Thanks for the quick response, George.

You are right about the intercepts, this should be the case:

g Xlone = single_multiple == 1
g Xmultiple = single_multiple == 0


But the problem still persisted. Per your advice, I removed all the fixed parts and retained only the intercepts: Xsingle and Xmultiple . I am attaching the log file for reference.

Code: Select all

. sort pid wave
. capture noisily runmlwin Ymove Xlone Xmultiple if responding_person == 1 & units_included_foranalysis == 1, level2(pid: Xlone Xmultiple) level1(wave:) ///
> discrete(distribution(binomial) link(logit) denominator(cons) pql2) nopause mlwinpath(C:\Program Files\MLwiN v2.25\mlwin.exe)
 
MLwiN 2.25 multilevel model                     Number of obs      =     99195
Binomial logit response model
Estimation algorithm: IGLS, PQL2

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
            pid |    16333          1        6.1          9
-----------------------------------------------------------

Run time (seconds)   =      42.93
Number of iterations =         10
------------------------------------------------------------------------------
       Ymove |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       Xlone |  -1.747223   .0299691   -58.30   0.000    -1.805961   -1.688484
   Xmultiple |   -2.31899   .0182907  -126.78   0.000    -2.354839   -2.283141
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: pid                 |
                  var(Xlone) |   2.523837   .0944917      2.338636    2.709037
        cov(Xlone,Xmultiple) |   1.913494   .0711305      1.774081    2.052907
              var(Xmultiple) |   1.767622   .0510521      1.667562    1.867682
------------------------------------------------------------------------------


. sort pid wave
. capture noisily runmlwin Ymove Xlone Xmultiple if responding_person == 1 & units_included_foranalysis == 1, level2(pid: Xlone Xmultiple, mmids(pid pid_mem2 p
> id_mem3 pid_mem4 pid_mem5 pid_mem6) mmweights(weight_decisionmaker1 weight_decisionmaker2 weight_decisionmaker3 weight_decisionmaker4 weight_decisionmaker5 w
> eight_decisionmaker6)) ///
> level1(wave:) discrete(distribution(binomial) link(logit) denominator(cons)) mcmc(burnin(500) chain(1000)) initsprevious nopause mlwinpath(C:\Program Files\M
> LwiN v2.25\mlwin.exe)
 
MLwiN 2.25 multilevel model                     Number of obs      =     99195
Binomial logit response model
Estimation algorithm: MCMC

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
            pid |    16333          1        6.1          9
-----------------------------------------------------------

Burnin                     =        500
Chain                      =       1000
Thinning                   =          1
Run time (seconds)         =        529
Deviance (dbar)            =   61117.41
Deviance (thetabar)        =   54296.30
Effective no. of pars (pd) =    6821.11
Bayesian DIC               =   67938.52
------------------------------------------------------------------------------
       Ymove |      Mean    Std. Dev.     ESS     P       [95% Cred. Interval]
-------------+----------------------------------------------------------------
       Xlone |  -1.770133   .0401944       23   0.000    -1.845479   -1.698214
   Xmultiple |  -2.579714   .0288064       22   0.000    -2.630401   -2.522676
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |     Mean   Std. Dev.   ESS     [95% Cred. Int]
-----------------------------+------------------------------------------------
Level 2: pid                 |
                  var(Xlone) |  3.072655  .1558467      8   2.801842  3.373882
        cov(Xlone,Xmultiple) |  3.904105  .1414697     10   3.675077  4.226225
              var(Xmultiple) |  7.515737   .267692      9   7.050663  8.041766
------------------------------------------------------------------------------

Thank you very much.

Cheers,
Arturo
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: can't proceed to multiple membership model

Post by GeorgeLeckie »

Hi Arturo,

The syntax looks fine to me. Also the log file output reports the results for the fitted multiple membership model by MCMC. Did you still get the "matrix must be positive definite for inversion" error message when fitting this simple version of the multiple membership model? If so, then please email me the simplest and smallest Stata dataset and do-file which will allow me to replicate this message. I will then take a look.

George
Post Reply