Dear all,
below is my code for d0 maximum likelihood evaluator for a mixed logit model of household labour supply. I need to estimate parameters beta1 to beta29 by Maximum Simulated Likelihood (log-likelihood simulated 50 times; see below). What I don't know is how to specify the equations after ml model d0. Is there anyone to help me.
My dataset contains the variables C1, C2, ..., C50 (obtained previously by adding 50 random draws from a normal distribution to variable C), LM_*, LF_*, poshrsM, poshrsF, peak5M, peak5F. These are all explanatory variables. In addition, I have variable choice, equal to 1 for the chosen option, and 0 otherwise. For each household I have 36 lines of data, containing data on 36 options of the choice set that households choose from.
Here's the code for the evaluator:
I hope I have provided enough details (possibly too much).
Thanks.
Ivica Rubil
below is my code for d0 maximum likelihood evaluator for a mixed logit model of household labour supply. I need to estimate parameters beta1 to beta29 by Maximum Simulated Likelihood (log-likelihood simulated 50 times; see below). What I don't know is how to specify the equations after ml model d0. Is there anyone to help me.
My dataset contains the variables C1, C2, ..., C50 (obtained previously by adding 50 random draws from a normal distribution to variable C), LM_*, LF_*, poshrsM, poshrsF, peak5M, peak5F. These are all explanatory variables. In addition, I have variable choice, equal to 1 for the chosen option, and 0 otherwise. For each household I have 36 lines of data, containing data on 36 options of the choice set that households choose from.
Here's the code for the evaluator:
Code:
cap prog drop myclogit_d0 prog myclogit_d0 version 14.2 args todo b lnf tempvar utility numer sum denom L1 L2 c csq clm clf tempname beta1 beta2 beta3 beta4 beta5 beta6 beta7 beta8 beta9 beta10 beta11 beta12 beta13 beta14 beta15 beta16 beta17 beta18 beta19 beta20 beta21 beta22 beta23 beta24 beta25 beta26 beta27 beta28 beta29 mleval `beta1' = `b' , eq(1) scalar mleval `beta2' = `b' , eq(2) scalar mleval `beta3' = `b' , eq(3) scalar mleval `beta4' = `b' , eq(4) scalar mleval `beta5' = `b' , eq(5) scalar mleval `beta6' = `b' , eq(6) scalar mleval `beta7' = `b' , eq(7) scalar mleval `beta8' = `b' , eq(8) scalar mleval `beta9' = `b' , eq(9) scalar mleval `beta10' = `b' , eq(10) scalar mleval `beta11' = `b' , eq(11) scalar mleval `beta12' = `b' , eq(12) scalar mleval `beta13' = `b' , eq(13) scalar mleval `beta14' = `b' , eq(14) scalar mleval `beta15' = `b' , eq(15) scalar mleval `beta16' = `b' , eq(16) scalar mleval `beta17' = `b' , eq(17) scalar mleval `beta18' = `b' , eq(18) scalar mleval `beta19' = `b' , eq(19) scalar mleval `beta20' = `b' , eq(20) scalar mleval `beta21' = `b' , eq(21) scalar mleval `beta22' = `b' , eq(22) scalar mleval `beta23' = `b' , eq(23) scalar mleval `beta24' = `b' , eq(24) scalar mleval `beta25' = `b' , eq(25) scalar mleval `beta26' = `b' , eq(26) scalar mleval `beta27' = `b' , eq(27) scalar mleval `beta28' = `b' , eq(28) scalar mleval `beta29' = `b' , eq(29) scalar qui gen double `L2' = 0 forval r = 1/50 { qui gen double `c' = C`r' qui gen double `csq' = `c'^2 qui gen double `clm' = `c' * LM qui gen double `clf' = `c' * LF qui gen double `utility' = `beta1' * `c' /// + `beta2' * `csq' /// + `beta3' * `clm' /// + `beta4' * `clf' /// + `beta5' * LM_ageM /// + `beta6' * LM_agesqM /// + `beta7' * LM_edyearM /// + `beta8' * LM_nch0002C /// + `beta9' * LM_nch0306C /// + `beta10' * LM_nch0718C /// + `beta11' * LM_hslima1M /// + `beta12' * LM_hslima2M /// + `beta13' * LM /// + `beta14' * LMsq /// + `beta15' * LF_ageF /// + `beta16' * LF_agesqF /// + `beta17' * LF_edyearF /// + `beta18' * LF_nch0002C /// + `beta19' * LF_nch0306C /// + `beta20' * LF_nch0718C /// + `beta21' * LF_hslima1F /// + `beta22' * LF_hslima2F /// + `beta23' * LF /// + `beta24' * LFsq /// + `beta25' * LM_LF /// + `beta26' * poshrsM /// + `beta27' * poshrsF /// + `beta28' * peak5M /// + `beta29' * peak5F qui gen double `numer' = exp(`utility') qui by idhh_11: gen double `sum' = sum(`numer') qui by idhh_11: gen double `denom' = `sum'[_N] qui gen double `L1' = `numer' / `denom' qui replace `L2' = `L2' + `L1' drop `c' `csq' `clm' `clf' `numer' `sum' `denom' `L1' `utility' } // r mlsum `lnf' = ln(`L2'/50) if choice == 1 if (`todo' == 0 | `lnf' >= .) exit end
Thanks.
Ivica Rubil