-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTable_2.do
210 lines (176 loc) · 6.41 KB
/
Table_2.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
** Written by: Bryan Parthum; [email protected] ; June 2019
********************************************************************************
**************************************************** Main Results and WTP,WTV
********************************************************************* Table 2
********************************************************************************
clear all
set more off, perm
set niceness 0
** Set the working directory to the location of this file
cd ""
********************************************************************************
******************************* PANEL A - MONEY *******************************
********************************************************************************
**********************************
************************** Clean
**********************************
** Load data
use data/chicago_money, clear
append using data/portland_money
** Generate negative term
gen nmoney = -money
** Generate alternative specific constant
gen asc = alt==3
** Transform flood reduction from percent
replace fld_pctdec = fld_pctdec *100
** Random variables for MMNL
global randvars "asc fld_pctdec hd_exc pld_swm nmoney"
**********************************
************* Table 2 - Column 1
**********************************
qui{
global model "tab_2_col_1_money"
mixlogit choice, rand($randvars) 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 2 - Column 2
**********************************
qui{
global model "tab_2_col_2_money"
mixlogit choice if chic_dum==1, rand($randvars) 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 2 - Column 3
**********************************
qui{
global model "tab_2_col_3_money"
mixlogit choice if chic_dum==0, rand($randvars) 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
}
********************************************************************************
******************************* PANEL B - TIME *******************************
********************************************************************************
**********************************
************************** Clean
**********************************
** Load data
use data/chicago_time, clear
append using data/portland_time
** Generate negative term
gen ntime = -time
** Generate alternative specific constant
gen asc = alt==3
** Transform flood reduction from percent
replace fld_pctdec = fld_pctdec *100
** Random variables for MMNL
global randvars "asc fld_pctdec hd_exc pld_swm ntime"
**********************************
************* Table 2 - Column 1
**********************************
qui{
global model "tab_2_col_1_time"
mixlogit choice, rand($randvars) 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 2 - Column 2
**********************************
qui{
global model "tab_2_col_2_time"
mixlogit choice if chic_dum==1, rand($randvars) 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 2 - Column 3
**********************************
qui{
global model "tab_2_col_3_time"
mixlogit choice if chic_dum==0, rand($randvars) 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 2 **********************************
********************************************************************************
forv i = 1/3 {
est use estimates/tab_2_col_`i'_money
eststo tab_2_col_`i'_money
est use estimates/tab_2_col_`i'_time
eststo tab_2_col_`i'_time
}
**********************************
********** LIKELIHOOD RATIO TESTS
**********************************
est use estimates/tab_2_col_1_money
eststo tab_2_col_1_money
sca ll_col1 = e(ll)
est use estimates/tab_2_col_2_money
eststo tab_2_col_2_money
sca ll_col2 = e(ll)
est use estimates/tab_2_col_3_money
eststo tab_2_col_3_money
sca ll_col3 = e(ll)
est use estimates/tab_2_col_1_time
eststo tab_2_col_1_time
sca ll_col1_time = e(ll)
est use estimates/tab_2_col_2_time
eststo tab_2_col_2_time
sca ll_col2_time = e(ll)
est use estimates/tab_2_col_3_time
eststo tab_2_col_3_time
sca ll_col3_time = e(ll)
sca LRTS_money = 2*((ll_col2+ll_col3)-ll_col1)
sca LRTS_time = 2*((ll_col2_time+ll_col3_time)-ll_col1_time)
chitable 45
di LRTS_money
di LRTS_time
est use estimates/tab_2_col_1_money
estadd sca LR_tstat = LRTS_money
eststo tab_2_col_1_money
est use estimates/tab_2_col_1_time
estadd sca LR_tstat = LRTS_time
eststo tab_2_col_1_time
**********************************
*************** Table 2 - PANEL A
**********************************
esttab tab_2_col_1_money tab_2_col_2_money tab_2_col_3_money ///
using output\Table_2_money.rtf, replace ///
title(Table 2: Money) ///
mtitles("Both Cities" "Chicago" "Portland") ///
scalars("chi2 LR chi2" "p Prob > chi2" "mcfr2 McF. R2" "aic AIC" "ll Log lik." "LR_tstat LR_tstat") ///
b(3) se(3) ///
label se
** STANDARD DEVIATION OF RANDOM PARAMETERS
forv i = 1/3 {
est use estimates/tab_2_col_`i'_money
mixlcov, sd
}
**********************************
*************** Table 2 - PANEL B
**********************************
esttab tab_2_col_1_time tab_2_col_2_time tab_2_col_3_time ///
using output\Table_2_time.rtf, replace ///
title(Table 2: Time) ///
mtitles("Both Cities" "Chicago" "Portland") ///
scalars("chi2 LR chi2" "p Prob > chi2" "mcfr2 McF. R2" "aic AIC" "ll Log lik." "LR_tstat LR_tstat") ///
b(3) se(3) ///
label se
** STANDARD DEVIATION OF RANDOM PARAMETERS
forv i = 1/3 {
est use estimates/tab_2_col_`i'_time
mixlcov, sd
}
** END OF SCRIPT. Have a nice day!