indicator functions for logistic models

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

indicator functions for logistic models

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 marital status: (single vs. cohabiting relationship) (Kindly see attached file equation.jpg). I have 35 explanatory variables. Since, across time an individual will move from being single to cohabiting relationship, I suspect that the random effects for the singles will be correlated with the random effects for those who are in cohabiting relationship.

To allow variation according to individual's marital status, 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 couple == 1
replace `x'_C = 0 if couple == 0

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

g Xsingle = couple == 0
g Xcouple = couple == 1

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


When I estimated the model, I get sensible results for the fixed part of the model. However, I get the following results for the random parts:

cov(Xsingle,Xcouple) = .1861189
var(Xsingle) = .1041276
var(Xcouple) = .2092139

display (.1861189 )/sqrt(.1041276*.2092139) = 1.26

As you would notice, I have a correlation falling outside the unit circle. Naturally, I can not proceed to MCMC using these numbers as initial values. While I can specify different initial values, I am just wondering whether it's possible that my approach of creating the explanatory variables is causing this problem? Or is there a direct way of putting an indicator function in the model specification instead of creating two sets of X's?

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

Re: indicator functions for logistic models

Post by GeorgeLeckie »

Hi there,

The implementation that you have followed is the one I would have followed for the problem you specify.

Substantively I think you would expect to estimate a very high correlation in this particular example - individuals who are especially likely to move home when single are also likely to be the same individuals who are especially likely to move when they are cohabiting. However, clearly you do not expect a correlation which lies outside (-1,1)!

Does the correlation appear more sensible when you go on to fit the model by PQL2? (Currently you are using MQL1 the default method, but also the most approximate).

One potential problem in your model specification is that while you have in effect interacted all your covariates by cohabiting status, you don't appear to have interacted the intercept by cohabiting status. Perhaps this is the source of the strange level-2 random part parameter estimates which you obtain?

Specifically, you specify the following model

Code: Select all

. runmlwin y cons x1_S - X35_S X1_C - X35_C, ///
    level2(individual_id: Xsingle Xcouple) ///
    level1(survey_round:) ///
    discrete(distribution(binomial) link(logit) denominator(cons)) ///
    nopause 
but don't you also want to interact the intercept variable cons by cohabiting status so that you have main effects of cohabiting status as well as all the interactions with the covariates. In which case you would want the following model or

Code: Select all

. runmlwin y Xsingle Xcouple x1_S - X35_S X1_C - X35_C, ///
    level2(individual_id: Xsingle Xcouple) ///
    level1(survey_round:) ///
    discrete(distribution(binomial) link(logit) denominator(cons)) ///
    nopause 
In terms of manually editing your starting values prior to fitting the model by MCMC, use the following to save the parameter estimates from your quasilikelihood model

matrix a = e(b)

Then edit the relevant elements of the vector a. Then use the initsb(a) option when you fit the model by MCMC.

Best wishes

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

Re: indicator functions for logistic models

Post by morning03 »

Thank you very much for the detailed response, George.

I think you're right, I should also interact the intercept with cohabiting status. Hopefully, that will solve the problem. Thanks again
Post Reply