-
Notifications
You must be signed in to change notification settings - Fork 0
/
MEXHIBIT4.do
345 lines (283 loc) · 13.2 KB
/
MEXHIBIT4.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
* The code load analysis sample exported from SAS macro MANALYSIS and run mixed effect models
* 1. Run linear mixed effect model stratifying between short- vs long-stay (for main exhibit4)
* 2. Run logit mixed effect model stratifying between short- vs long-stay (for appendix etable5.)
* 3. Run linear mixed effect model stratifying between short- vs long-stay and dual vs. none-dual (for appendix etable4.)
capture log close
clear all
set more off
//
// local logdir "//prfs.cri.uchicago.edu/sanghavi-lab/Pan/NH/results/paper/final/Exhibit4/stata/log"
local indir "//prfs.cri.uchicago.edu/sanghavi-lab/Pan/NH/datasets/stata/final/linprob"
log using `"`logdir'/Exhibit4.log"', text replace
cd "`indir'"
*load analysis dataset
use exhibit4,clear
*set up factor variables
*race
egen race=group(racename)
label define race 1 "Asian" 2 "Black" 3 "Hispanic" 4 "Other" 5 "White"
label values race race
tab race
*niss_catg
egen niss_cat=group(niss_catg)
label define niss_cat 1 "1-15" 2 "16-24" 3 "25-40" 4 "40-75"
label values niss_cat niss_cat
tab niss_cat
*region
egen area=group(region)
label define area 1 "midwest" 2 "northeast" 3 "south" 4 "west"
label values area area
tab area
*ownership
egen ownership=group(cap_ownership)
label define ownership 1 "For-Profit" 2 "Government" 3 "Non-Profit" 4 "Other"
label values ownership ownership
tab ownership
*provider size
egen size=group(prvdrsize)
label define size 1 "large" 2 "medium" 3 "small"
label values size size
tab size
*set panel variable
encode m_prvdrnum, gen(prvdrnum)
xtset prvdrnum
*create age linear splines
mkspline age1 78 age2 85 age3 90 age4=bsf_age
*drop obs with missing values
keep if !missing(max_nj1900c,female,age1,age2,age3,age4,niss,niss_cat,combinedscore, ///
race,disability,dual_dm, meanbh,fallrate,area,ownership, ///
meandual,size,year,pasian,pblack,phispanic,pother)
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*Run linear mixed effect regressions for main exhibit 4;
*Shortstay, all variables;
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*calculate mean J1900C reporting rate for short-stay population
su max_nj1900c if shortstay==1, detail
*run linear mixed effect model on short-stay population
eststo: mixed max_nj1900c female age1 age2 age3 age4 niss ib(first).niss_cat ib(last).race disability dual_dm combinedscore ///
fallrate ib3.area ib(first).ownership meandual ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==1|| prvdrnum:
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_short_allvar
*calculate fixed effect variance
su p_j1900c_short_allvar,detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_short_allvar if shortstay==1|| prvdrnum:
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*Run linear mixed effect regressions for main exhibit 4;
*Short-stay, only NH-level variables;
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*run linear mixed effect model on short-stay population
eststo: mixed max_nj1900c ib(last).race fallrate ib3.area ib(first).ownership meandual ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==1|| prvdrnum:
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_short_nhvar
*calculate fixed effect variance
su p_j1900c_short_nhvar,detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_short_nhvar if shortstay==1|| prvdrnum:
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*Run linear mixed effect regressions for main exhibit 4;
*Long-stay, all variables;
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*calculate mean J1900C reporting rate for long-stay population
su max_nj1900c if shortstay==0, detail
*run linear mixed effect model on long-stay population
eststo: mixed max_nj1900c female age1 age2 age3 age4 niss ib(first).niss_cat ib(last)i.race disability dual_dm combinedscore ///
fallrate ib3.area ib(first).ownership meandual ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==0|| prvdrnum:
*Calculate between nh race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_long_allvar
*calculate fixed effect variance
su p_j1900c_long_allvar, detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_long_allvar if shortstay==0|| prvdrnum:
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*Run linear mixed effect regressions for main exhibit 4;
*Long-stay, only NH-level variables;
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*run linear mixed effect model on long-stay population
eststo: mixed max_nj1900c ib(last)i.race fallrate ib3.area ib(first).ownership meandual ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==0|| prvdrnum:
*Calculate between nh race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_long_nhvar
*calculate fixed effect variance
su p_j1900c_long_nhvar, detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_long_nhvar if shortstay==0|| prvdrnum:
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*Run logit mixed effect regressions for appendix;
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*run logit mixed effect model on short-stay population
melogit max_nj1900c i.female age1 age2 age3 age4 niss ib(first).niss_cat ib(last).race i.disability dual_dm combinedscore ///
fallrate ib3.area ib(first).ownership meandual ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==1|| prvdrnum:
*Calculate between nh race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*predict marginal effect and check against linear model
margins r.female r.ib1.niss_cat r.disability r.ib5.race r.ib3.area r.ib1.ownership ///
r.ib1.size
margins, dydx(niss)
margins, dydx(combinedscore)
margins, at(dual_dm=(-1(1)1))
margins, at(year=(2011(1)2015))
margins, at(fallrate100=(1(1)4))
*margins, at(fallrate100=(1(1)10))
margins, at(meandual=(0 1))
//
// margins, at(age1=(26(1)78))
// margins, at(age2=(0(1)7))
// margins, at(age3=(0(1)5))
// margins, at(age4=(0(1)19))
//
margins, at(age1=(74 75))
margins, at(age2=(5 6))
margins, at(age3=(4 5))
margins, at(age4=(10 11))
margins, at(pasian=(0 1))
margins, at(pblack=(0 1))
margins, at(phispanic=(0 1))
margins, at(pother=(0 1))
*------------------------------------------------------------------------------------------------------------;
*run logit mixed effect model on long-stay population
melogit max_nj1900c i.female age1 age2 age3 age4 niss ib(first).niss_cat ib(last).race i.disability dual_dm combinedscore ///
fallrate ib3.area ib(first).ownership meandual ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==0|| prvdrnum:
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*predict marginal effect: marginal effect gives coefficient values equivalent to the coefficients in linear mixed effect models
margins r.female r.ib1.niss_cat r.disability r.ib5.race r.ib3.area r.ib1.ownership ///
r.ib1.size
margins, dydx(niss)
margins, dydx(combinedscore)
margins, at(dual_dm=(-1(1)1))
margins, at(year=(2011(1)2015))
*margins, at(fallrate100=(1(1)10))
margins, at(fallrate100=(1(1)4))
margins, at(meandual=(0 1))
//
// margins, at(age1=(23(1)78))
// margins, at(age2=(0(1)7))
// margins, at(age3=(0(1)5))
// margins, at(age4=(0(1)21))
//
margins, at(age1=(74 75))
margins, at(age2=(5 6))
margins, at(age3=(4 5))
margins, at(age4=(10 11))
margins, at(pasian=(0 1))
margins, at(pblack=(0 1))
margins, at(phispanic=(0 1))
margins, at(pother=(0 1))
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*Run linear mixed effect regressions stratifying between short- versus long-stay
*and dual versus none-dual for appendix;
*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------*-------;
*calculate mean J1900C reporting rate for short-stay dual population
su max_nj1900c if shortstay==1 & dual==1, detail
*run linear mixed effect model on short-stay dual population
mixed max_nj1900c female age1 age2 age3 age4 niss ib(first).niss_cat ib(last).race disability combinedscore ///
fallrate100 ib3.area ib(first).ownership ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==1 & dual==1|| prvdrnum:
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_short_dual
*calculate fixed effect variance
su p_j1900c_short_dual,detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_short_dual if shortstay==1 & dual==1|| prvdrnum:
*------------------------------------------------------------------------------------------------------------;
*calculate mean J1900C reporting rate for short-stay non-edual population
su max_nj1900c if shortstay==1 & dual==0, detail
*run linear mixed effect model on short-stay none-dual population
mixed max_nj1900c female age1 age2 age3 age4 niss ib(first).niss_cat ib(last).race disability combinedscore ///
fallrate100 ib3.area ib(first).ownership ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==1 & dual==0|| prvdrnum:
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_short_nondual
*calculate fixed effect variance
su p_j1900c_short_nondual,detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_short_nondual if shortstay==1 & dual==0|| prvdrnum:
*------------------------------------------------------------------------------------------------------------;
*calculate mean J1900C reporting rate for long-stay dual population
su max_nj1900c if shortstay==0 & dual==1, detail
*run linear mixed effect model on long-stay dual population
mixed max_nj1900c female age1 age2 age3 age4 niss ib(first).niss_cat ib(last)i.race disability combinedscore ///
fallrate100 ib3.area ib(first).ownership ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==0 & dual==1|| prvdrnum: ///
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_long_dual
*calculate fixed effect variance
su p_j1900c_long_dual, detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_long_dual if shortstay==0 & dual==1|| prvdrnum:
*------------------------------------------------------------------------------------------------------------;
*calculate mean J1900C reporting rate for long-stay none-dual population
su max_nj1900c if shortstay==0 & dual==0, detail
*run linear mixed effect on long-stay none-dual population
mixed max_nj1900c female age1 age2 age3 age4 niss ib(first).niss_cat ib(last)i.race disability combinedscore ///
fallrate100 ib3.area ib(first).ownership ///
ib(first).size ib(first).year ///
pasian pblack phispanic pother if shortstay==0 & dual==0|| prvdrnum: ///
*Calculate between NH race effect
lincom pasian+i1.race
lincom pblack+i2.race
lincom phispanic+i3.race
lincom pother+i4.race
*Predict reporting rate using only fixed effects
predict p_j1900c_long_nonedual
*calculate fixed effect variance
su p_j1900c_long_nonedual, detail
*calculate within nh variance and bewteen nh variance
mixed p_j1900c_long_nonedual if shortstay==0 & dual==0|| prvdrnum:
log close