Page 1 of 1
multilevel modeling using panel data - matrix must be positi
Posted: Thu Jul 05, 2012 7:30 am
by morning03
Hi. I am a new user of runmlwin. I am estimating a multilevel logistic model on the propensity of a residential move using panel data with random intercept. I am using the wave as level 1 unit and the household is as the level 2 unit... First I estimated the model using igls and the results seem fine. However, when I try to fit an mcmc model using the results from the first model as initial values, I keep on getting the "matrix must be positive definite.." error. I am not sure what is causing it.... Any help will be much appreciated.
Have a pleasant week ahead.
Thanks,
Arturo
Re: multilevel modeling using panel data - matrix must be po
Posted: Thu Jul 05, 2012 5:13 pm
by GeorgeLeckie
Hi Arturo,
You typically get this message when you have fitted a model with random coefficients and the resulting random part covariance matrix is badly behaved, typically the correlation between the random intercept and one of the random coefficient effects lies outside the -1 to +1 range. This can happen when the model is too complex for the data, or if the model is nonsensical in some way. If you continue to get this error, please paste your sytnax and output into your reply so that we can better see what the cause of the error message might be.
Best wishes
George
Re: multilevel modeling using panel data - matrix must be po
Posted: Fri Jul 06, 2012 12:04 am
by morning03
Thank you very much for the quick response, George, it's much appreciated.
Actually, before I estimated a 2-level model, I tried estimating a 3-level model since I am using individual-level panel data (i.e., wave-level1, individual id-level2, family id-level3). However, the variance for the random individual-level intercept is zero so I just proceeded to estimating a 2-level model (i.e., wave-level1, family id-level2). While the IGLS estimation worked, the MCMC estimation encountered an error that the matrix must be positive definite. I'm thinking if specifying 0 for all variance/covariance parameters will do the trick.
Anyhow, here are the codes that I'm using and the corresponding outputs from Stata and MlWin2.25:
Thank you very much for your time.
Have a nice day ahead,
Arturo
Code: Select all
sort family_id wave
runmlwin Y cons i.X1 X2 X3 X4 X5 X6 X7 X8 i.X9 X10 X11 X12 X13 i.X14 X15 X16 i.X17///
if responding_person == 1 & Xsingle == 1 & units_included_foranalysis == 1, level2(family_id: cons) level1(wave:) discrete(distribution(binomial) link(logit) denominator(cons)) ///
nopause mlwinpath(C:\Program Files\MLwiN v2.25\mlwin.exe)
MLwiN 2.25 multilevel model Number of obs = 29344
Binomial logit response model
Estimation algorithm: IGLS, MQL1
--------------------------------------------------------------------------
| No. of Observations per Group
Level Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------------------
family_id | 6756 1 4.3 35
--------------------------------------------------------------------------
Run time (seconds) = 21.75
Number of iterations = 8
----------------------------------------------------------------------------------------------
Y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------+---------------------------------------------------------------------------
cons | -1.605837 .0888317 -18.08 0.000 -1.779943 -1.43173
_1b_X1 | 0 0 . . 0 0
_2_X1 | 1.054539 .042879 24.59 0.000 .9704979 1.13858
_3_X1 | -1.298693 .957877 -1.36 0.175 -3.176098 .5787112
_4_X1 | 1.125275 .0856164 13.14 0.000 .9574701 1.29308
X2 | -.1114131 .0072013 -15.47 0.000 -.1255275 -.0972987
X3 | -.0351183 .0015105 -23.25 0.000 -.0380789 -.0321577
X4 | .000166 .0000862 1.92 0.054 -3.06e-06 .000335
X5 | -.0853965 .0367195 -2.33 0.020 -.1573654 -.0134275
X6 | .1715977 .0700068 2.45 0.014 .0343869 .3088086
X7 | -.0915078 .065917 -1.39 0.165 -.2207027 .0376871
X8 | 1.467441 .0504637 29.08 0.000 1.368534 1.566348
_1b_X9 | 0 0 . . 0 0
_2_X9 | -.0726749 .1493732 -0.49 0.627 -.3654411 .2200913
_3_X9 | -.2001464 .146699 -1.36 0.172 -.4876711 .0873783
X10 | -.0409512 .1493137 -0.27 0.784 -.3336007 .2516984
X11 | -.284316 .1538169 -1.85 0.065 -.5857916 .0171596
X12 | -.2165901 .16999 -1.27 0.203 -.5497642 .1165841
X13 | .0690696 .0455874 1.52 0.130 -.0202802 .1584193
_1b_X14 | 0 0 . . 0 0
_2_X14 | .2012782 .071133 2.83 0.005 .0618601 .3406964
_3_X14 | .4663865 .0731933 6.37 0.000 .3229302 .6098428
_4_X14 | .0057812 .0486005 0.12 0.905 -.0894741 .1010365
X15 | 4.32e-07 4.83e-07 0.89 0.371 -5.14e-07 1.38e-06
X16 | .0295688 .0172871 1.71 0.087 -.0043132 .0634508
_1b_X17 | 0 0 . . 0 0
_2_X17 | -.0532726 .0490182 -1.09 0.277 -.1493464 .0428012
_3_X17 | .1925178 .0492156 3.91 0.000 .0960569 .2889786
_4_X17 | -.1624762 .0663194 -2.45 0.014 -.2924598 -.0324926
_5_X17 | .0095187 .0659811 0.14 0.885 -.1198019 .1388393
_6_X17 | .1133617 .1024594 1.11 0.269 -.087455 .3141784
_7_X17 | .5418286 .1759747 3.08 0.002 .1969245 .8867327
_8_X17 | .0212009 .1354922 0.16 0.876 -.2443589 .2867608
----------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+---------------------------------------------------------------
Level 2: family_id |
var(cons) | .4072275 .0308308 .3468003 .4676547
--------------------------------------------------------------------------------------------
sort family_id wave
runmlwin Y cons i.X1 X2 X3 X4 X5 X6 X7 X8 i.X9 X10 X11 X12 X13 i.X14 X15 X16 i.X17///
if responding_person == 1 & Xsingle == 1 & units_included_foranalysis == 1, level2(family_id: cons) level1(wave:) mcmc(on) initsprevious discrete(distribution(binomial) link(logit) denominator(cons)) ///
nopause mlwinpath(C:\Program Files\MLwiN v2.25\mlwin.exe)
MLWin Error:
"error while obeying batch file
C:\data\Local\Temp\ST_1o000008.tmp at line number 1326: WSET
MCMC Error 0003: Matrix must be positive definite for inversion."
Re: multilevel modeling using panel data - matrix must be po
Posted: Fri Jul 06, 2012 5:09 pm
by GeorgeLeckie
Hi Arturo,
Look at your fixed part parameter estimates. Some of them are exactly zero (looks like perfect multicollinearity). I suspect that this is the source of your problem. These parameters are not identified.
I suspect if you correct your model specification so that you no longer have these model specification errors you will no longer see the error message that arises when you switch to MCMC.
The error message says
"Matrix must be positive definite for inversion"
in your example, I believe this is referring to the sampling covariance matrix (initially I had presumed the problem lay with parameter estimates covariance matrix, but this is not the case as your model does not have any random coefficients and so you only have one random part parameter at each level and so no matrices).
The sampling covariance matrix [e(V) in Stata parlance] is used in the adapting phase of the Metropolis Hastings MCMC algorithm which is used to fit discrete response models such as yours in MLwiN.
Best wishes
George
Re: multilevel modeling using panel data - matrix must be po
Posted: Sun Jul 08, 2012 10:59 pm
by morning03
Thanks a lot, George.
You're right, the 0's should not be there. However, the 0's correspond to the base categories of the categorical variables X1, X9, X14 and X17. I was able to proceed to MCMC estimation after creating dummy variables for these four variables (and excluding the base categories in the model specification) instead of using "i.X" in my stata code.
Many thanks again.
Have a nice week ahead,
Arturo
Re: multilevel modeling using panel data - matrix must be po
Posted: Mon Jul 09, 2012 8:22 am
by GeorgeLeckie
Great, I'm glad runmlwin now works for you
Best wishes
George