File size: 27,349 Bytes
b6c95bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
*** TABLES FOR Carrera, Royer, Stehr, Sydnor, and Taubinsky (2021) ************
*******************************************************************************

*** Initial set-up ***
clear
eststo clear
set more off

*** Set directory for output ***
cd "$main/Output"
/* Note: all tables will output to the working directory. Uses a program from

   master_do_file_for_analysis.do */


*** Load and clean experimental data ******************************************

*** Load dataset ***
use "$main/Data/cleaned_commitment_study_data", clear

*** Variable Creation & Cleaning Steps ***
*** Create an ID variable for use when reshaping long 
gen id = _n

*** Generate info treatment indicators
gen first_info = type_of_info=="1-onlygraph" 
gen new_info = type_of_info=="2-graphplus" 
gen control_info = (new_info == 0 & first_info == 0) 

*** Generate wave indicators
gen wave1 = (wave == "fall") 
gen wave2 = (wave == "winter")
gen wave3 = (wave == "spring")

*** Define anticommitment/commitment variables for each threshold
gen anticommit8 = q170 ==2 if q170<.
gen commit8 = q169 ==2 if q169<.
gen anticommit12 = chose_anticommit11
gen commit12 = chose_commit12
gen anticommit16 = q296==2 if q296<.
gen commit16 = q295 ==2 if q295<.

*** Rescale percent variable
foreach var of varlist percent*{
	replace `var' = `var'/100
	}
	
*** Store number of observations in exclusions
sum flag_low_wtp
loc lowwtp `r(sum)'
latex_write lowwtpobs `lowwtp' numbers
sum flag_exclude_exog
loc endog `r(sum)'
latex_write nexogobs `endog' numbers
loc totalexcl = `lowwtp' + `endog'
latex_write excludeobs `totalexcl' numbers

* Wave 3
sum flag_low_wtp if wave3 == 1
latex_write lowwtpobswthree `r(sum)' numbers
sum flag_exclude_exog if wave3 == 1
latex_write nexogobswthree `r(sum)' numbers

*** Store number of participants in each wave before exclusions
forval i = 1/3{

	if `i' == 1 loc wname "wone"
	else if `i' == 2 loc wname "wtwo"
	else loc wname "wthree"

	sum wave`i' if wave`i' == 1
	loc obs = r(N)
	latex_write `wname'obs `obs' numbers
	}

*** Store share of participants who prefer nothing to contingent $80
sum prefer80contingent_to_0
loc pctpreferzero : di %2.1f (1-r(mean))*100
latex_write pctpreferzero `pctpreferzero' numbers
	
*** Restrict sample to those exogenously assigned incentives
keep if flag_low_wtp == 0 & flag_exclude_exog == 0


*** Descriptive Statistics (appendix_descriptive_stats.tex) *******************

*** Generate variables and labels for the table ***
gen ft_student = student==1 if student<.
gen ft_working = working==1 if working<.
gen fpt_working = working<3 if working<.
gen advanced_degree = educ==5
replace married = married==1 if married<.
recode age  (1 = 24) (2=35.5 ) (3=45.5) (4=57.5) (5=70) , gen(imp_age)
recode income_cat  (1 = 18000) (2=37500 ) (3=75500) (4=150000) (5=.) , gen(imp_inc)

label var female "Female" 
label var imp_inc "Household income$^a$"
label var married "Married"
label var ft_student "Student, full-time"
label var fpt_working "Working, full- or part-time"
label var advanced "Advanced degree$^b$"
label var imp_age "Age$^a$"
label var past4 "Visits in the past 4 weeks, recorded"
label var visits_100 "$\hspace{0.5cm}$ Visits, recorded"
label var past100days_went "$\hspace{0.5cm}$ Visits, self-recollection"
label var past100days_should "Days that \textit{I should have gone, but didn't}"
label var days_0 "Best guess of days I will attend in next 4 weeks"
label var goal "Goal for visits in next 4 weeks"

gen wave_num = "Wave 1" if wave=="fall"
replace wave_num="Wave 2" if wave=="winter"
replace wave_num="Wave 3" if wave=="spring"
tab wave_num // N = 1248 (340 in Wave 1, 509 in Wave 2, 399 in Wave 3)

*** Produce statistics for the table ***
estpost tabstat female imp_age ft_student fpt_working married advanced_degree imp_inc past4, by(wave_num)  statistics(mean sd) columns(statistics)

*** Export table
#delimit;
estout . using `"appendix_descriptive_stats.tex"' ,
cells(mean(fmt(%3.2fc %3.2fc %3.2fc %3.2fc %3.2fc %3.2fc %8.0gc %3.2fc) star) 
sd(fmt(%3.2fc %3.2fc %3.2fc %3.2fc %3.2fc %3.2fc %8.0gc %3.2fc) par))
starlevels(\sym{*} 0.05 \sym{**} 0.01 \sym{***} 0.001, label(" \(p<@\)"))
varwidth(20) modelwidth(12) unstack delimiter(&) end(\\)
prehead(`"{"' `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"' `"\begin{tabular}{l*{@E}{c}}"' `"\hline"') posthead("\hline")
postfoot(`"\hline"' `"\addlinespace"' `"N & 340 & 509 & 399 & 1,248 \\"'  `"\hline\hline"' `"\end{tabular}"' `"}"' )
label varlabels(_cons Constant, end("" [1em]) nolast) mlabels(none) nonumbers
collabels(none) substitute(_ \_ "\_cons " \_cons "Total" "Overall")
interaction(" $\times$ ") notype level(95) style(tex) replace;

#delimit cr


*** (CCtable.tex) *************************************************************
*** This table was created by hand, so no tex output is produced for it *******

local commitlist "8 12 16"

*** Summarize take-up of commitment contracts ***
foreach X of local commitlist {
  * Declare local for labeling
  if `X' == 8 loc num "eight"
  else if `X' == 12 loc num "twelve"
  else loc num "sixteen"
  * Chose "more" contract
  summarize commit`X'
  * Store mean and number of observations
  loc takeup = round(r(mean)*100)
  loc takeup : di %2.0f `takeup'
  latex_write commit`num'rate `takeup' numbers
  local obsnum : di %5.0fc `r(N)'
  if r(N) > 1000 loc obsnum = subinstr("`obsnum'",",","{,}",.)
  latex_write commit`num'obs `obsnum' numbers
  * Chose "fewer" contract
  summarize anticommit`X'
  * Chose "more" given chose "fewer"
  summarize commit`X' if anticommit`X'==1
  * Chose "fewer" given chose "more"
  summarize anticommit`X' if commit`X'==1
  * Difference between "more" and "more" given chose "fewer" means
  gen commit`X'_cdtn = commit`X' if anticommit`X'==1
  ttest commit`X'_cdtn = commit`X', unpaired
  * Difference between "fewer" and "fewer" given chose "more" means
  gen anticommit`X'_cdtn = anticommit`X' if commit`X'==1
  ttest anticommit`X'_cdtn = anticommit`X', unpaired
}  


*** (CCBeliefs2.tex) **********************************************************

*** Regress expected days vs. probability of meeting threshold, all participants
reg days_0 percent_meet_commit12, robust
est store est11

reg days_0 percent_meet_anticommit, robust
est store est12

reg days_0 percent_meet_commit12 percent_meet_anticommit, robust
est store est13

* Difference of coefficients ("More"-"Fewer")
nlcom diff: _b[percent_meet_commit12]-_b[percent_meet_anticommit], post

* Store differences
local b : di %4.2f _b[diff]
local se : di %4.2f _se[diff]
estadd local diffb "`b'***" : est13 // know significance level via inspection
estadd local diffse "(`se')" : est13

*** Regress expected days vs. probability of meeting threshold, chose commit & anticommit
reg days_0 percent_meet_commit12 percent_meet_anticommit ///
	if commit12 == 1 & anticommit12 == 1, robust
est store est14

* Difference of coefficients ("More"-"Fewer")
nlcom diff: _b[percent_meet_commit12]-_b[percent_meet_anticommit], post

* Store differences
local b : di %4.2f _b[diff]
local se : di %4.2f _se[diff]
estadd local diffb "`b'***" : est14 // know significance level via inspection
estadd local diffse "(`se')" : est14

*** Export table
estout est11 est12 est13 est14 using CCBeliefs2.tex, style(tex) margin replace eqlabels(none) ///
cells(b(star fmt(%9.2f))  se(par fmt(%9.2f)) ) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
keep(percent_meet_commit12 percent_meet_anticommit) wrap varwidth(25) ///
order(percent_meet_commit12 percent_meet_anticommit) ///
mgroups("Subjective expected attendance without incentives", pattern(1 0 0 0) ///
span prefix(\multicolumn{@span}{c}{) suffix(})) ///
stats(N diffb diffse, l("N" "\hline \`\`More'' $-$ \`\`Fewer''" " ") fmt(%8.0fc %8.0fc %8.0fc)) ///
varlabels(percent_meet_commit12 "Subj. prob. succeed in \lq\lq more\rq\rq\, contract" percent_meet_anticommit "Subj. prob. succeed in \lq\lq fewer\rq\rq\, contract") ///
collabels(,none) mlabels("(1)" "(2)" "(3)" "(4)") ///
prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
posthead("\hline") prefoot() postfoot("\hline\hline" "\end{tabular}")


*** (regs_{avg_delta_ex_1,commit}_all.tex) ************************************
	
*** Generate variable for expected attendace w/incentive given
gen days_exp = .
foreach i in 0 1 2 3 5 7{
	replace days_exp = days_`i' if incentive == `i'
	}
	
*** Generate variables for gaps between goal, past, expected, & actual attendance
gen gap_goal_exp = goal - days_0 // under no incentive
gen gap_goal_past = goal - past4
gen gap_actual_exp = visits - days_exp


*** Generate behavior change premium variables (second-order approximation)
gen delta1=(wtp1) - (days_1+days_0)/2
gen delta2 = (wtp2-wtp1) - (days_2+days_1)/2
gen delta3=(wtp3-wtp2) - (days_3+days_2)/2
gen delta5=(wtp5-wtp3)/(5-3) - (days_5+days_3)/2
gen delta7=(wtp7-wtp5)/(7-5) - (days_7+days_5)/2
gen delta12=(wtp12-wtp7)/(12-7) - (days_12+days_7)/2
gen avg_delta_ex1 = (delta2 + delta3 + delta5 + delta7 + delta12)/5
	

** Store number of observations without an incentive
gen got_contract = (incentive == .)
sum got_contract
latex_write gotcontractobs `r(sum)' numbers


*** Perform series of analyses for whole sample

* Declare restriction for following analysis
loc restrict "!missing(incentive)"
	
* Store means and standard deviations
foreach v in gap_goal_exp gap_actual_exp{
	if "`v'" == "gap_goal_exp" loc name "goalexp"
	else loc name "actexp"
	sum `v' if `restrict'
	loc mean : di %4.2f r(mean)
	loc sd : di %4.2f r(sd)
	latex_write `name'mean `mean' numbers
	latex_write `name'sd `sd' numbers
	}
	
* Generate z-scores for variables with constant restriction
foreach dvar in gap_goal_exp gap_actual_exp avg_delta_ex1{
	sum `dvar' if `restrict'
	gen z_`dvar' = (`dvar' - r(mean)) / r(sd) if `restrict'
	}
	
* Run regressions of behavior change premium with regressors & constant restriction
eststo clear
loc k = 1
foreach controls in "" "female i.income_cat married ft_student fpt_working advanced i.age_cat"{
	foreach covar in "first_info new_info" "first_info new_info z_gap_goal_exp" "first_info new_info z_gap_actual_exp"{

		* Run regression
		reg avg_delta_ex1 wave2 wave3 `covar' `controls' if `restrict', r
		eststo spec_`k'
		
		* Store coefficients from certain regressions
		if `k' == 1{
			loc coeff : di %4.2f _b[new_info]
			latex_write enhinfobcpcoeff `coeff' numbers
			}
		else if `k' == 2{
			loc coeff : di %4.2f _b[z_gap_goal_exp]
			latex_write goalexpbcpcoeff `coeff' numbers
			}
		else if `k' == 3{
			loc coeff : di %4.2f _b[z_gap_actual_exp]
			latex_write actualexpbcpcoeff `coeff' numbers
			}
		
		* Store dependent variable mean
		ci means avg_delta_ex1 if `restrict' & !missing(gap_actual_exp)
		local m : di %4.2f r(mean)
		local se : di %4.2f r(se)
		estadd local dvmean `m'
		estadd local dvse "(`se')"
		ci means avg_delta_ex1 if `restrict' & !missing(gap_actual_exp) & ///
			control_info == 1
		local mcontrol : di %4.2f r(mean)
		local secontrol : di %4.2f r(se)
		estadd local dvmeancontrol `mcontrol'
		if `k' == 1 latex_write bcpinfoctrlmean `mcontrol' numbers
		estadd local dvsecontrol "(`secontrol')"
		estadd local wavefe "Yes"
		if `k' == 1 latex_write bcpregmean `m' numbers
		if "`controls'" != "" estadd local ctrl "Yes"
		
		loc ++k
		}
	}
			
* Export regression output
estout spec_1 spec_2 spec_3 using "regs_avg_delta_ex1_all.tex", style(tex) margin replace eqlabels(none) ///
	keep(first_info new_info z_gap_goal_exp z_gap_actual_exp) wrap varwidth(25) ///
	order(first_info new_info z_gap_goal_exp z_gap_actual_exp) ///
	mgroups("\shortstack{Behavior change premium}", pattern(1 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	mlabels("(1)" "(2)" "(3)" "(4)",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	varlabels(z_gap_goal_exp "Goal $-$ exp. attend. (z-score)" z_gap_actual_exp "Actual $-$ exp. attend. (z-score)" first_info "Basic info. treatment" new_info "Enhanced info. treatment" _cons "Constant") ///
	cells(b(star fmt(%9.2f))  se(par fmt(%9.2f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
	stats(dvmean dvse dvmeancontrol dvsecontrol wavefe N, l("Dep. var. mean:" " " "Dep. var. mean," "info. control group:" "\hline Wave FEs" "N") fmt(%8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc)) ///
	collabels(,none) prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
	posthead("\hline") prefoot("\hline") postfoot("\hline\hline" "\end{tabular}")
	
* Export regression output with demographic controls
estout spec_4 spec_5 spec_6 using "regs_avg_delta_ex1_all_demo.tex", style(tex) margin replace eqlabels(none) ///
	keep(first_info new_info z_gap_goal_exp z_gap_actual_exp) ///
	wrap varwidth(25) order(first_info new_info z_gap_goal_exp z_gap_actual_exp) ///
	mgroups("\shortstack{Behavior change premium}", pattern(1 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	mlabels("(1)" "(2)" "(3)" "(4)",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	varlabels(z_gap_goal_exp "Goal $-$ exp. attend. (z-score)" z_gap_actual_exp "Actual $-$ exp. attend. (z-score)" first_info "Basic info. treatment" new_info "Enhanced info. treatment" _cons "Constant") ///
	cells(b(star fmt(%9.2f))  se(par fmt(%9.2f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
	stats(dvmean dvse dvmeancontrol dvsecontrol ctrl wavefe N, l("Dep. var. mean:" " " "Dep. var. mean," "info. control group:" "\hline Demographic controls" "Wave FEs" "N") fmt(%8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc)) ///
	collabels(,none) prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
	posthead("\hline") prefoot("\hline") postfoot("\hline\hline" "\end{tabular}")

		
* Run regressions of contract take-up on regressors with a constant restriction
preserve

* Reshape to pool contracts
reshape long commit, i(id) j(t)

* Run regressions with constant restriction
eststo clear
loc k = 1
foreach controls in "" "female i.income_cat married ft_student fpt_working  advanced i.age_cat"{
	foreach covar in "first_info new_info" "z_avg_delta_ex1 first_info new_info" "z_gap_goal_exp first_info new_info" "z_gap_actual_exp first_info new_info"{
		
		* Run regression
		reg commit i.t wave2 wave3 `covar' `controls' if `restrict', vce(cluster id)
		eststo spec_commit`k'
		
		* Store coefficients from certain regressions
		if `k' == 1{
			loc coeff : di %2.1f abs(_b[new_info]*100)
			latex_write enhinfoMCcoeff `coeff' numbers
			}
		else if `k' == 2{
			loc coeff : di %2.0f _b[z_avg_delta_ex1]*100
			latex_write bcpMCcoeff `coeff' numbers
			}
		else if `k' == 3{
			loc coeff : di %2.1f _b[z_gap_goal_exp]*100
			latex_write goalexpMCcoeff `coeff' numbers
			}
		
		* Store dependent variable mean
		ci means commit if `restrict'
		local m : di %4.2f r(mean)
		local mpct : di %4.0f r(mean)*100
		local se : di %4.2f r(se)
		estadd local dvmean `m'
		estadd local dvse "(`se')"
		ci means commit if `restrict' & control_info == 1
		local mcontrol : di %4.2f r(mean)
		local secontrol : di %4.2f r(se)
		estadd local dvmeancontrol `mcontrol'
		estadd local dvsecontrol "(`secontrol')"
		estadd local wavefe "Yes"
		estadd local ccfe "Yes"
		if `k' == 1{
			latex_write MCregmean `m' numbers
			latex_write MCregmeanPCT `mpct' numbers
			}
		if "`controls'" != "" estadd local ctrl "Yes"
		
		loc ++k
		}
	}
	
* Export regression output
estout spec_commit1 spec_commit2 spec_commit3 spec_commit4 using "regs_commit_pooled_all.tex", ///
	style(tex) margin replace eqlabels(none) wrap varwidth(25) ///
	keep(first_info new_info z_avg_delta_ex1 z_gap_goal_exp z_gap_actual_exp) ///
	order(first_info new_info z_avg_delta_ex1 z_gap_goal_exp z_gap_actual_exp) ///
	mgroups("\shortstack{Take-up of \`\`more'' visits contracts}", pattern(1 0 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	mlabels("(1)" "(2)" "(3)" "(4)",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	varlabels(z_avg_delta_ex1 "Behavior change premium (z-score)" z_gap_goal_exp "Goal $-$ exp. attend. (z-score)" z_gap_actual_exp "Actual $-$ exp. attend. (z-score)" first_info "Basic info. treatment" new_info "Enhanced info. treatment" _cons "Constant") ///
	cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
	stats(dvmean dvse dvmeancontrol dvsecontrol wavefe ccfe N N_clust, l("Dep. var. mean:" " " "Dep. var. mean," "info. control group:" "\hline Wave FEs" "Contract FEs" "N" "Clusters") fmt(%8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc)) ///
	collabels(,none) prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
	posthead("\hline") prefoot("\hline") postfoot("\hline\hline" "\end{tabular}")
	
* Export regression output with demographic controls
estout spec_commit5 spec_commit6 spec_commit7 spec_commit8 using "regs_commit_pooled_all_demo.tex", ///
	style(tex) margin replace eqlabels(none) wrap varwidth(25) ///
	keep(first_info new_info z_avg_delta_ex1 z_gap_goal_exp z_gap_actual_exp) ///
	order(first_info new_info z_avg_delta_ex1 z_gap_goal_exp z_gap_actual_exp) ///
	mgroups("\shortstack{Take-up of \`\`more'' visits contracts}", pattern(1 0 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	mlabels("(1)" "(2)" "(3)" "(4)",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	varlabels(z_avg_delta_ex1 "Behavior change premium (z-score)" z_gap_goal_exp "Goal $-$ exp. attend. (z-score)" z_gap_actual_exp "Actual $-$ exp. attend. (z-score)" first_info "Basic info. treatment" new_info "Enhanced info. treatment" _cons "Constant") ///
	cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
	stats(dvmean dvse dvmeancontrol dvsecontrol ctrl wavefe ccfe N N_clust, l("Dep. var. mean:" " " "Dep. var. mean," "info. control group:" "\hline Demographic controls" "Wave FEs" "Contract FEs" "N" "Clusters") fmt(%8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc %8.0fc)) ///
	collabels(,none) prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
	posthead("\hline") prefoot("\hline") postfoot("\hline\hline" "\end{tabular}")

restore

	
*** additions to numbers.tex **************************************************

*** Change in visits due to 12-visit contract assignment ***
* Generate variable for comparing treatment with control
gen gotcontract = 1 if treatment == "threshold80_12"
replace gotcontract = 0 if treatment == "control"

* Test for difference and store mean difference by take-up of contract
ttest visits if wave3 == 1 & commit12 == 1, by(gotcontract)
loc takeup : di %3.2f r(mu_2)-r(mu_1)
latex_write wantgottwelvediff `takeup' numbers

ttest visits if wave3 == 1 & commit12 == 0, by(gotcontract)
loc takeup : di %3.2f r(mu_2)-r(mu_1)
latex_write rejectgottwelvediff `takeup' numbers

* Store percentage of those who took up & got the contract who met the threshold
gen wantedgot12visits = visits if treatment == "threshold80_12" & commit12 == 1
gen under12 = wantedgot12visits < 12 if !missing(wantedgot12visits)
sum under12
loc pctunder : di %2.0f round(r(mean)*100)
latex_write pctundertwelve `pctunder' numbers


*** Statistics about WTPs at the slider maximum ***
* Reshape data for one observation per participant per incentive
preserve
keep wtp* maxwtp* id
reshape long wtp maxwtp, i(id) j(incentive)

* Generate a variable for the maximum slider value
gen maxval = incentive*30

* Store percentage of participants who maxed out slider
gen slidermaxed = !missing(maxwtp)
sum slidermaxed
loc pctmaxed : di %2.1f r(mean)*100
latex_write pctmaxed `pctmaxed' numbers

* Generate variables for fill-in-blank answers relation to maximum slider value
gen overmaxval = maxwtp > maxval if !missing(maxwtp)
gen atmaxval = maxwtp == maxval if !missing(maxwtp)
gen belowmaxval = maxwtp < maxval if !missing(maxwtp)

* Store percent of participants in each category
foreach relation in over at below{
	sum `relation'maxval
	loc pct`relation'max : di %2.0f r(mean)*100
	latex_write pct`relation'max `pct`relation'max' numbers
	}
restore


*** Share of individual behavior change value measures that are negative ***
* Reshape data for one observation per participant per incentive increase
preserve
keep delta* id
reshape long delta, i(id) j(inc)

* Estimate and store relevant statistic
gen delta_negative = delta < 0
sum delta_negative
loc pctdeltaneg : di %2.0f r(mean)*100
latex_write pctdeltaneg `pctdeltaneg' numbers
restore


*** Additional summary statistics ***
* Percent female and male
sum female
loc pctfemale : di %2.0f r(mean)*100
loc pctfemalealt : di %2.1f r(mean)*100
loc pctmalealt : di %2.1f (1 - r(mean))*100
loc fracfemale : di %4.3f r(mean)
loc fracmale : di %4.3f (1 - r(mean))
foreach stat in pctfemale pctfemalealt pctmalealt fracfemale fracmale{
	latex_write `stat' ``stat'' numbers 
	}

* Mean imputed age
sum imp_age
loc meanage : di %2.0f r(mean)
latex_write meanage `meanage' numbers

* Percent students
sum ft_student
loc pctstudent : di %2.0f r(mean)*100
latex_write pctstudent `pctstudent' numbers

* Percent working
sum fpt_working
loc pctworking : di %2.0f r(mean)*100
latex_write pctworking `pctworking' numbers

* Percent married
sum married
loc pctmarried : di %2.0f r(mean)*100
latex_write pctmarried `pctmarried' numbers

* Mean visits recorded in past 100 days
sum visits_100
loc meanpastvisits : di %2.0f r(mean)
latex_write meanpastvisits `meanpastvisits' numbers

* Mean visits recalled in past 100 days
sum past100days_went
loc meanpastvisitsrecall : di %2.0f r(mean)
latex_write meanpastvisitsrecall `meanpastvisitsrecall' numbers

* Attention check 
gen failed_attention = passed_attention_check == 0
sum failed
loc pctfailed : di %2.1f r(mean)*100
latex_write pctfailedac `pctfailed' numbers

* Chose dominated option
sum areyousure_prefer0_to_20
loc dom20 = r(N)
sum areyousure_prefer0_to_80
loc dom80 = r(N)
sum id
loc pctdominated : di %2.1f ((`dom20' + `dom80')/r(N))*100
latex_write pctchosedom `pctdominated' numbers

* Comprehension check
gen failed_cc = passed_comprehension_check == 0
sum failed_cc
loc pctfailed : di %2.1f r(mean)*100
latex_write pctfailedcc `pctfailed' numbers

* Numeracy check
gen passed_nc = 1 if !missing(q137) & !missing(q138)
replace passed_nc = 0 if (q138 == "133" | q138 == "133333" | q138 == "200000" | ///
 q138 == "2500" | q138 == "40,000" | q138 == "40,000.00" | ///
 q138 == "$400,00.00" | q138 == "400" | q138 == "400,00" | q138 == "40000" | ///
 q138 == "4000000" | q138 == "500,000" | q138 == "50000" | q138 == "800000" | ///
 q138 == "four") & !missing(passed_nc)
replace passed_nc = 0 if q137 != 100 & !missing(passed_nc)
sum passed_nc
loc pctpassed : di %2.1f r(mean)*100
latex_write passednumeracy `pctpassed' numbers

* Take-up of contract for fewer visits with & without exclusions above
preserve
reshape long commit anticommit, i(id) j(t)
sum anticommit
loc takeup : di %2.0f r(mean)*100
latex_write anticommitrate `takeup' numbers

sum anticommit if passed_comprehension_check == 1 ///
	& passed_attention_check == 1 & missing(areyousure_prefer0_to_20) ///
	& missing(areyousure_prefer0_to_80)
loc takeup : di %2.0f r(mean)*100
latex_write anticommitrateexcl `takeup' numbers
restore

* Range of percent take-up of contracts for fewer visits
loc anticommitpctmin = 1 // initialize for contract with lowest take-up
loc anticommitpctmax = 0 // initialize for contract with highest take-up
forval i = 8(4)16{
	sum anticommit`i'
	if r(mean) > `anticommitpctmax' loc anticommitpctmax = r(mean)
	if r(mean) < `anticommitpctmin' loc anticommitpctmin = r(mean)
	}
foreach stat in min max{
	loc anticommitpct`stat' : di %4.0f `anticommitpct`stat''*100
	latex_write anticommitpct`stat' `anticommitpct`stat'' numbers
	}

* Number of participants in waves 2 & 3
gen wave23 = (wave2 | wave3)
sum wave23
loc obs = r(mean)*r(N)
latex_write wtwothreeobs `obs' numbers

* Average expected visits for different incentives
sum days_0
loc avgzero : di %2.1f r(mean)
latex_write avgexpnoinc `avgzero' numbers
sum days_7
loc avgseven : di %2.1f r(mean)
latex_write avgexpseveninc `avgseven' numbers
loc diff : di %2.1f `avgseven'-`avgzero'
latex_write avgexpdiffseven `diff' numbers

* Average actual visits for different incentives
sum visits if incentive==0
loc avgzero : di %2.1f r(mean)
latex_write avgactnoinc `avgzero' numbers
sum visits if incentive==7
loc avgseven : di %2.1f r(mean)
latex_write avgactseveninc `avgseven' numbers
loc diff : di %2.1f `avgseven'-`avgzero'
latex_write avgactdiffseven `diff' numbers

* Regression of attendance on average past attendance
reg visits past4
matrix temp = r(table)'
loc b : di %4.3f temp[1,1]
loc se : di %4.3f temp[1,2]
latex_write attcoeff `b' numbers
latex_write attcoeffse `se' numbers

* Effect of $2 piece-rate incentive
gen got_2 = 1 if incentive == 2
replace got_2 = 0 if treatment == "control"
* On expectations
ttest days_2 == days_0
* On realized attendance
ttest visits, by(got_2) unpaired


*** Generate pairwise correlation estimates with bootstrapping ***
* Pairwise correlation of behavior change premium at each incentive level
capture program drop avg_pwcorr_bcp
program define avg_pwcorr_bcp, rclass

	* Initialize values
	loc m = 0
	loc agg_corr = 0
	
	* Loop through each incentive level
	foreach j in 1 2 3 5 7 {
		foreach k in 2 3 5 7 12 {
			if `j' < `k'{
				pwcorr delta`j' delta`k'
				loc agg_corr = `agg_corr' + r(rho)
				loc ++m
				}
			}
		}
		
	* Average pairwise correlation
	return scalar avg_pwcorr = `agg_corr'/`m'
	
end

* Generate estimates with bootstrapping
bootstrap avg_pwcorr_bcp = r(avg_pwcorr), reps(1000) cluster(id) seed(12345) ///
	nodrop level(95): avg_pwcorr_bcp
estat bootstrap, all

* Store estimates
matrix temp_b = e(b)
loc avg : di %3.2f temp_b[1,1]
latex_write avgbcpcorr `avg' numbers
matrix temp_se = e(se)
loc stderr : di %3.2f temp_se[1,1]
latex_write avgbcpcorrse `stderr' numbers


* Pairwise correlation of take-up of each more-visits contract
capture program drop avg_pwcorr_mc
program define avg_pwcorr_mc, rclass

	* Initialize values
	loc m = 0
	loc agg_corr = 0
	
	* Loop through each more-visits contract
	foreach j in 8 12 {
		foreach k in 12 16 {
			if `j' < `k'{
				pwcorr commit`j' commit`k'
				loc agg_corr = `agg_corr' + r(rho)
				loc ++m
				}
			}
		}
		
	* Average pairwise correlation
	return scalar avg_pwcorr = `agg_corr'/`m'
	
end

* Generate estimates with bootstrapping
bootstrap avg_pwcorr_mc = r(avg_pwcorr), reps(1000) cluster(id) seed(12345) ///
	nodrop level(95): avg_pwcorr_mc
estat bootstrap, all
	
* Store estimates
matrix temp_b = e(b)
loc avg : di %3.2f temp_b[1,1]
latex_write avgMCcorr `avg' numbers
matrix temp_se = e(se)
loc stderr : di %3.2f temp_se[1,1]
latex_write avgMCcorrse `stderr' numbers