/* Again, the preliminaries */ clear set memory 100m set more off /* As the outcome of the lottery is known for each indivdidual, we can use a binary "choice" model to predict an individual- specific probability of being drawn. The estimates of this model may then be applied to the associated variables in the random draws dataset to generate a prediction of lottery-odds for each alternative in each individual's choice set. */ /* The following estimates a probit model of lottery outcome (drawn/not drawn) We do not use the random draws dataset; instead we use the original dataset. */ use c:\lotteries_b\1997\data\hunts_97.dta keep huntcode licenses apps95 apps96 rename huntcode choice_1 sort choice_1 save c:\lotteries_b\1997\intermediate\hunts_97_B.dta, replace clear use c:\lotteries\1997\intermediate\elk_res_1997_2.dta drop name_l name_f name_m street city state orig_zip resident dob phone resobsno generate obsno=group(_N) drop if obsno>18708 generate outcome=1 if choice_1==drawn replace outcome=0 if outcome==. generate outcome2=1 if (purchase~=. & purchase~=0) & choice_1~=drawn replace outcome2=0 if outcome2==. generate male=1 if gender=="M" replace male=0 if male==. sort choice_1 merge choice_1 using c:\lotteries_b\1997\intermediate\hunts_97_B.dta generate age_sqd=age*age drop _merge gender save c:\lotteries_b\1997\intermediate\elk_res_1997_6.dta, replace /* This is the actual "probit" statement with outcome (1/0 variable indicating whether or not the individual was drawn in the lottery. We also hold on to the estimates as they will be used with the random draws dataset to generate predicted lottery-odds across each alternative in each individual's choice set */ probit outcome age age_sqd male licenses apps96 estimates hold b_hat /* Now, we take the probit estimates to the random draws dataset and use them to calculate a new variable called "prob_prd". Important: this prob_prd variable might be simply included as a regressor in the destination choice model, implying the model is simply a traditional "random utility model". Alternatively, prob_prd could be interacted with regressors, with the resulting model being a form of "random expected utility model". */ use c:\lotteries_b\1997\intermediate\10_sorted_draws_B.dta, clear drop prob_prd estimates unhold b_hat predict prob_prd /* The following uses the pred_prob variable to generate interaction variables */ /* generate pi_tcost=tcost*prob_prd generate pi_prob=prob_tru*prob_prd generate pi_lics=licenses*prob_prd generate pi_harv=harvest*prob_prd generate pi_ne=ne*prob_prd generate pi_nw=nw*prob_prd generate pi_sw=sw*prob_prd generate pi_se=se*prob_prd generate pi_qual=quality*prob_prd generate pi_bull=bull*prob_prd generate pi_open=opening*prob_prd generate pi_late=late*prob_prd generate pi_holid=holiday*prob_prd generate pi_age=age*prob_prd generate pi_male=male*prob_prd save c:\lotteries_b\1997\intermediate\10_sorted_draws_B.dta, replace */ #delimit ; /* And finally, two destination choice models are estimated using the clogit (conditional logistic regression) command. The first is the random utility model and the second is the random expected utility model */ clogit choice tcost prob_prd licenses harvest ne sw se quality bull opening late holiday, group(id); clogit choice pi_tcost pi_lics pi_harv pi_ne pi_sw pi_se pi_qual pi_bull pi_open pi_late pi_holiday, group(id) ; /* Enjoy! */