-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTable_A2_2_city.do
134 lines (110 loc) · 4.27 KB
/
Table_A2_2_city.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
** Written by: Bryan Parthum; [email protected] ; June 2019
********************************************************************************
*********************** POOLED WTP,WTV ***************************
*********************** FROM Table 2 and Table 3 ***************************
********************************************************************************
clear all
set more off, perm
set niceness 0
** Set the working directory to the location of this file
cd ""
********************************************************************************
******************************* PANEL A - MONEY *******************************
********************************************************************************
** Load data
use data/pooled_money_time, clear
** Generate negative term
gen nmoney = -money * (1-time_survey)
gen ntime = -time * time_survey
** Generate alternative specific constant
gen asc = alt==3
** Transform flood reduction from percent
replace fld_pctdec = fld_pctdec *100
** Generate interactions
gen asc_chi = asc*chic_dum
gen fld_pctdec_chi = fld_pctdec*chic_dum
gen hd_exc_chi = hd_exc*chic_dum
gen pld_swm_chi = pld_swm*chic_dum
gen nmoney_chi = nmoney*chic_dum
gen ntime_chi = ntime*chic_dum
** Random variables for MMNL
global randvars_1 "asc fld_pctdec hd_exc pld_swm asc_chi fld_pctdec_chi hd_exc_chi pld_swm_chi nmoney_chi nmoney"
global randvars_2 "asc fld_pctdec hd_exc pld_swm asc_chi fld_pctdec_chi hd_exc_chi pld_swm_chi ntime_chi ntime"
**********************************
********** Table A2_2 - Column 1
**********************************
qui{
global model "tab_A2_2_col_1"
mixlogit choice, rand($randvars_1) group(c_id) id(id) ln(1) nrep(500) cluster(id) corr
estadd sca mcfr2 = 1-(e(ll)/e(ll_0)), r
eststo $model
est save estimates/$model, replace
}
**********************************
********** Table A2_2 - Column 2
**********************************
qui{
global model "tab_A2_2_col_2"
mixlogit choice, rand($randvars_2) group(c_id) id(id) ln(1) nrep(500) cluster(id) corr
estadd sca mcfr2 = 1-(e(ll)/e(ll_0)), r
eststo $model
est save estimates/$model, replace
*mat b = e(b)
*mat g = b*0.01
*mat $model = b + g
*matsave $model, replace p("matrices") s
}
**********************************
********** Table A2_2 - Column 3
**********************************
** Load data
use data/pooled_money_time, clear
** Generate negative term
gen nmoney = -money * (1-time_survey)
gen ntime = -time * time_survey
recode nmoney .=0
recode ntime .=0
*gen nmoney_chi = nmoney*chic_dum
*gen ntime_chi = ntime*chic_dum
** Generate alternative specific constant
gen asc = alt==3
** Transform flood reduction from percent
replace fld_pctdec = fld_pctdec *100
** Generate interactions
gen asc_chi = asc*chic_dum
gen fld_pctdec_chi = fld_pctdec*chic_dum
gen hd_exc_chi = hd_exc*chic_dum
gen pld_swm_chi = pld_swm*chic_dum
gen nmoney_chi = nmoney*chic_dum
gen ntime_chi = ntime*chic_dum
** Random variables for MMNL
global randvars_3 "asc fld_pctdec hd_exc pld_swm asc_chi fld_pctdec_chi hd_exc_chi pld_swm_chi nmoney_chi ntime_chi nmoney ntime"
qui{
global model "tab_A2_2_col_3"
mixlogit choice, rand($randvars_3) group(c_id) id(id) ln(2) nrep(500) cluster(id) corr
estadd sca mcfr2 = 1-(e(ll)/e(ll_0)), r
eststo $model
est save estimates/$model, replace
}
********************************************************************************
********************************* Table A2_2 *********************************
********************************************************************************
forv i = 1/3 {
est use estimates/tab_A2_2_col_`i'
eststo tab_A2_2_col_`i'
}
**********************************
************** Table A2 - PANEL A
**********************************
esttab tab_A2_2_col_1 tab_A2_2_col_2 tab_A2_2_col_3 ///
using output\Table_A2_2.rtf, replace ///
title(Table A2-2: MMNL with Interactions to Test Parameter Differences between Cities) ///
mtitles("Money" "Time" "Both") ///
scalars("chi2 LR chi2" "p Prob > chi2" "mcfr2 McF. R2" "aic AIC" "ll Log lik.") ///
b(3) se(3) ///
label se
** STANDARD DEVIATION OF RANDOM PARAMETERS
forv i = 1/3 {
est use estimates/tab_A2_2_col_`i'
mixlcov, sd
}