File size: 29,083 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
*** APPENDIX TABLES FOR Carrera, Royer, Stehr, Sydnor, and Taubinsky (2021) ***
*******************************************************************************

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

*** Set directories for data and 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
	}
	
*** Restrict sample to those exogenously assigned incentives
keep if flag_low_wtp == 0 & flag_exclude_exog == 0


*** Descriptive Statistics (table_descriptive.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 "Visits, recorded"
label var past100days_went "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"
label var flag_confusion "Indicator for inattention during survey"

gen any_info = 0 
replace any_info=1 if first_info==1 | new_info==1
gen rowvar = .

*** Produce statistics for the table ***
local counter=0
eststo clear
foreach var of varlist female imp_age ft_student fpt_working married advanced_degree imp_inc past4{
local counter=`counter'+1
local varlabel: var label `var'
label var rowvar "`varlabel'"
replace rowvar=1

eststo model0, title(""): xi: reg `var' rowvar, noconst
replace rowvar = any_info
*estadd matrix p = (.), replace

eststo model1, title(""): xi: reg `var' rowvar if wave1==1, robust

reg `var' rowvar if wave1==0, robust
eststo model2, title("")

*** Export table
if `counter'==1 {
 estout model0 model1 model2 using  "table_descriptive.tex", style(tex) label cells((b( fmt(%9.3f) label("\shortstack{Wave 1 \\ (2)}") pattern(0 1 0)) b( fmt(%9.3f) label("\shortstack{Waves 2-3 \\ (4)}") pattern(0 0 1))  b( fmt(%9.3f) label("\shortstack{Waves 1-3 \\ (1)}") pattern(1 0 0)) p(fmt(%9.2f) pattern(0 1 0) label("\shortstack{P-value \\ (3)}")) p(fmt(%9.2f) pattern(0 0 1) label("\shortstack{P-value \\ (5)}")))) drop(_cons ) margin replace  ///
title(Descriptive Statistics) mgroups("\shortstack{ \\ Overall mean}" "\shortstack{ \\ Difference in means:\\ Treatment $-$ control}" , pattern(1 1 0) ///
span prefix(\multicolumn{@span}{c}{) suffix(}))  /// 
mlabels("" "" "") msign(--) starlevels(* 0.1 ** 0.05 *** 0.01)   ///
prehead( "\begin{tabular}{l*{6}{c}}" "\hline" "\addlinespace")   ///
posthead("\hline" "\addlinespace") substitute(_ \_)
	}
	
	else if `counter'==7 {
 estout model0 model1 model2 using  "table_descriptive.tex", style(tex) mlabels("" "" "") label cells((b( fmt(%9.0fc))  p(fmt(%9.2f) pattern(0 1 1)))) drop(_cons) margin append eqlabels(none)  ///
 msign(--) starlevels(* 0.1 ** 0.05 *** 0.01)  collabels(,none) prefoot() substitute(_ \_)
	}
	
	else if `counter'==8 {
 estout model0 model1 model2 using  "table_descriptive.tex", style(tex) mlabels("" "" "") label cells((b( fmt(%9.2f))  p(pattern(0 1 1)))) drop(_cons) margin append eqlabels(none)  ///
 msign(--) starlevels(* 0.1 ** 0.05 *** 0.01)  collabels(,none) prefoot() substitute(_ \_) ///
postfoot("\hline" "\addlinespace" "N & 1,248 &  \multicolumn{2}{c}{\shortstack{166 control \\ 174 treated}}  & \multicolumn{2}{c}{\shortstack{456 control \\ 452 treated}} \\ "  "\hline\hline" "\end{tabular}")
	}
	else if `counter'>=3 & `counter'<=6{
 estout model0 model1 model2 using  "table_descriptive.tex", style(tex) mlabels("" "" "") label cells((b( fmt(%9.3f)) p(fmt(%9.2f) pattern(0 1 1)))) drop(_cons) margin append eqlabels(none)  ///
 msign(--) starlevels(* 0.1 ** 0.05 *** 0.01)  collabels(,none) substitute(_ \_)  
}
else {
 estout model0 model1 model2 using  "table_descriptive.tex", style(tex) mlabels("" "" "") label cells((b( fmt(%9.2f)) p(pattern(0 1 1)))) drop(_cons) margin append eqlabels(none)  ///
 msign(--) starlevels(* 0.1 ** 0.05 *** 0.01)  collabels(,none) substitute(_ \_)  
}
}
.
/* Note: the number of observations was manually entered; N = 1,248;

Wave 1: 166 Control and 174 Treated; and Waves 2-3: 456 Control and 452 Treated */


*** (commit_delta{,_info,_control}.tex) ***************************************

*** Generate additional variables and reshape data ***
/*** These variables are the amounts, per attendance, by which a person 

"overpays" for the increase in incentive. 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

*** Change in days of expected attendance by incentive
gen diffa1=(days_1-days_0)
gen diffa2=(days_2-days_1)
gen diffa3=(days_3-days_2)
gen diffa5=(days_5-days_3)/2
gen diffa7=(days_7-days_5)/2
gen diffa12=(days_12-days_7)/5

*** Generate z-score and mean ***	
quietly sum avg_delta_ex1
gen z_avg_delta_ex1 = (avg_delta_ex1 - r(mean))/r(sd)
loc mean : di %4.2f r(mean)
loc sd : di %4.2f r(sd)
latex_write wtpbcmean `mean' numbers
latex_write wtpbcsd `sd' numbers

*** Regress behavior change premium on commitment contract take-up ***
loc k = 1
foreach restriction in "" "if new_info == 1" "if control_info == 1"{

	forval j = 8(4)16{
	
		* Run regression under treatment restriction
		regress commit`j' z_avg_delta_ex1 wave2 wave3 `restriction', ///
			vce(cluster id)
		est store est_cd_`k'
		loc ++k

		* Store mean & fixed effects information
		ci means commit`j' if e(sample)
		local m : di %4.2f r(mean)
		local se : di %4.2f r(se)
		estadd local dvmean `m'
		estadd local dvse "(`se')"
		estadd local wavefe "Yes"
		estadd local ccfe "No"
	
		}
		
	}

preserve

* Reshape data and run regressions
reshape long commit commitnotanti, i(id) j(t)
foreach restriction in "" "if new_info == 1" "if control_info == 1"{

	* Run regression under treatment restriction
	regress commit z_avg_delta_ex1 i.t wave2 wave3 `restriction', ///
		vce(cluster id)
	est store est_cd_`k'
	loc ++k

	* Store mean & fixed effects information
	ci means commit if e(sample)
	local m : di %4.2f r(mean)
	local se : di %4.2f r(se)
	estadd local dvmean `m'
	estadd local dvse "(`se')"
	estadd local wavefe "Yes"
	estadd local ccfe "Yes"
	
	}

restore

*** Export tables
estout est_cd_1 est_cd_2 est_cd_3 est_cd_10 using "commit_delta.tex", style(tex) margin replace eqlabels(none) ///
order(z_avg_delta_ex1) keep(z_avg_delta_ex1) wrap varwidth(25) ///
mgroups("\shortstack{Take-up of \`\`more'' visits contract}" , pattern(1 0 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mlabels("\shortstack{8+ visits \\ (1)}" "\shortstack{12+ visits \\ (2)}" "\shortstack{16+ visits \\ (3)}" "\shortstack{Pooled \\ (4)}",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
varlabels(z_avg_delta_ex1 "Behavior change premium (z-score)") ///
cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
stats(dvmean dvse wavefe ccfe N N_clust, l("Dep. var. mean:" " " "\hline  Wave FEs" "Contract FEs" "N" "Clusters") fmt(%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}")

estout est_cd_4 est_cd_5 est_cd_6 est_cd_11 using "commit_delta_info.tex", style(tex) margin replace eqlabels(none) ///
order(z_avg_delta_ex1) keep(z_avg_delta_ex1) wrap varwidth(25) ///
mgroups("\shortstack{Take-up of \`\`more'' visits contract}" , pattern(1 0 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mlabels("\shortstack{8+ visits \\ (1)}" "\shortstack{12+ visits \\ (2)}" "\shortstack{16+ visits \\ (3)}" "\shortstack{Pooled \\ (4)}",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
varlabels(z_avg_delta_ex1 "Behavior change premium (z-score)") ///
cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
stats(dvmean dvse wavefe ccfe N N_clust, l("Dep. var. mean:" " " "\hline  Wave FEs" "Contract FEs" "N" "Clusters") fmt(%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}")

estout est_cd_7 est_cd_8 est_cd_9 est_cd_12 using "commit_delta_control.tex", style(tex) margin replace eqlabels(none) ///
order(z_avg_delta_ex1) keep(z_avg_delta_ex1) wrap varwidth(25) ///
mgroups("\shortstack{Take-up of \`\`more'' visits contract}" , pattern(1 0 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mlabels("\shortstack{8+ visits \\ (1)}" "\shortstack{12+ visits \\ (2)}" "\shortstack{16+ visits \\ (3)}" "\shortstack{Pooled \\ (4)}",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
varlabels(z_avg_delta_ex1 "Behavior change premium (z-score)") ///
cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
stats(dvmean dvse wavefe ccfe N N_clust, l("Dep. var. mean:" " " "\hline  Wave FEs" "Contract FEs" "N" "Clusters") fmt(%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}")


*** (regs_commitnotanti_pooled.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

* Declare restriction for following analysis
loc restrict "!missing(incentive)"
		
* Generate z-scores for variables with constant restriction
drop z_avg_delta_ex1
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'
	}	
	
*** Generate indicators for take-up of the more & not fewer contract ***
forval i = 8(4)16{
	gen commitnotanti`i' = (commit`i' == 1 & anticommit`i' == 0) ///
		if !missing(commit`i')
	}
		
*** Run regressions of take-up of a more but not fewer visits contract ***
preserve

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

* Run regressions with constant restriction
eststo clear
loc k = 1
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"{
	reg commitnotanti i.t wave2 wave3 `covar' if `restrict', vce(cluster id)
	eststo spec_`k'
	
	* Store dependent variable mean
	ci means commitnotanti 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 commitnotanti 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"
	
	loc ++k
	}
	
* Export regression output
estout spec* using "regs_commitnotanti_pooled.tex", style(tex) margin replace eqlabels(none) ///
	drop(8.t 12.t 16.t wave2 wave3 _cons) wrap varwidth(25)  ///
	order(first_info new_info z_avg_delta_ex1 z_gap_goal_exp z_gap_actual_exp ) ///
	mgroups("\shortstack{Take-up of \`\`more'' but not \`\`fewer'' \\ 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)) ///
	collabels(,none) prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
	posthead("\hline") prefoot("\hline") postfoot("\hline\hline" "\end{tabular}")

restore


*** (CCtable_{control,treatment}.tex) *****************************************
*** This table was created by hand, so no tex output is produced for it *******

foreach restriction in "new_info==1" "control_info==1"{
	preserve
	*** Keep either the treatment or control group ***
	keep if `restriction'
	
	if "`restriction'" == "new_info==1" loc name "enhancedtreat"
	else loc name "control"

	*** Summarize take-up of commitment contracts ***
	forval X = 8(4)16 {
		  * Chose "more" contract
		  summarize commit`X'
		  * Store number of observations
		  if `X' == 12 latex_write `name'obs `r(N)' 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
		}  
	restore
	}
	
	
*** (CCtakeupVbeliefs.tex) ****************************************************

*** Regress probability of meeting threshold vs. take-up, all participants ***
*** Probability of meeting "more" threshold
reg percent_meet_commit12 commit12, robust
est store est21

reg percent_meet_commit12 anticommit12, robust
est store est22

reg percent_meet_commit12 commit12 anticommit12, robust
est store est23

* Difference of coefficients ("More"-"Fewer")
test _b[commit]=_b[anticommit]
nlcom diff: _b[commit]-_b[anticommit], post

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

*** Probability of meeting "fewer" threshold
reg percent_meet_anticommit commit12, robust
est store est24

reg percent_meet_anticommit anticommit12, robust
est store est25

reg percent_meet_anticommit commit12 anticommit12, robust
est store est26

* Difference of coefficients ("More"-"Fewer")
test _b[commit]=_b[anticommit]
nlcom diff: _b[commit]-_b[anticommit], post

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

*** Export table
estout est21 est22 est23 est24 est25 est26 using CCtakeupVbeliefs.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(commit12 anticommit12) order(commit12 anticommit12) ///
stats(N diffb diffse, l("N" "\hline \`\`More'' $-$ \`\`Fewer''" " ") fmt(%8.0fc %8.0fc %8.0fc)) ///
varlabels(commit12 "Commit to \`\`more''" anticommit12 "Commit to \`\`fewer''") ///
collabels(,none) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mgroups("\shortstack{Subj. prob. succeed in \\ \`\`more'' contract}" "\shortstack{Subj. prob. succeed in \\ \`\`fewer'' contract}", pattern(1 0 0 1 0 0) ///
span prefix(\multicolumn{@span}{c}{) suffix(})) ///
prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
posthead("\hline") prefoot() postfoot("\hline\hline" "\end{tabular}")
	
	
*** (CCcorrelates.tex) ********************************************************

preserve
*** Reshape data ***
reshape long commit anticommit, i(id) j(threshold)

*** Further correlates of take-up ***
* Regress expected attendance on contract take-up
reg days_0 commit anticommit, robust
est store est31

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

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


* Regress past attendance on contract take-up
reg past4 commit anticommit, robust
est store est32

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

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


* Regress goal attendance on contract take-up
reg goal commit anticommit, robust
est store est33

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

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


*** Export table
estout est31 est32 est33 using CCcorrelates.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(commit anticommit) order(commit anticommit) ///
mgroups("Expected attendance" "Past attendance" "Goal attendance", pattern(1 1 1) ///
span prefix(\multicolumn{@span}{c}{) suffix(})) ///
stats(N diffb diffse, l("N" "\hline \`\`More'' $-$ \`\`Fewer''" " ") fmt(%8.0fc %8.0fc %8.0fc)) ///
varlabels(commit "Chose \`\`more contract''" anticommit "Chose \`\`fewer'' contract") ///
collabels(,none) mlabels("(1)" "(2)" "(3)") ///
prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
posthead("\hline") prefoot() postfoot("\hline\hline" "\end{tabular}")
	
restore


*** (Exp_{Rates,Corr}.tex) ****************************************************
*** These tables were created by hand, so no tex output is produced for them **

* Note: Attendance in the following tables is in the absence of incentives
 
cap program drop rate_table corr_table
*** Create program for table of rates of contract take-up ***
program rate_table
    syntax, attendance(string) // for expected vs. actual attendance
	
		if "`attendance'" == "expected" local attendance "days_0"
		else if "`attendance'" == "actual" local attendance "incentive == 0 & visits"
		else confirm "`attendance'" == "actual" | "`attendance'" == "expected"
	
		* Summarize take-up of commitment contracts
		forval i = 8(4)16 {
			* (1) Chose "more" contract
			di("(1) Chose more: `i' visits")
			summarize commit`i'
			* (2) Chose "more" given attendance no more than target - 2
			di("(2) Chose more | att. <= `i' - 2, `i' visits")
			summarize commit`i' if `attendance' <= `i' - 2
			* (3) Chose "more" given attendance no more than target - 4
			di("(3) Chose more | att. <= `i' - 4, `i' visits")
			summarize commit`i' if `attendance' <= `i' - 4
			* (4) Chose "fewer" contract
			di("(4) Chose fewer, `i' visits")
			summarize anticommit`i'
			* (5) Chose "fewer" given attendance at least target + 1
			di("(5) Chose fewer | att. >= `i' + 1, `i' visits")
			summarize anticommit`i' if `attendance' >= `i' + 1
			* (6) Chose "fewer" given attendance at least target + 3
			di("(6) Chose fewer | att. >= `i' + 3, `i' visits")
			summarize anticommit`i' if `attendance' >= `i' + 3
			}
end

* Obtain take-up rates for table
rate_table, attendance(expected)

*** Create program for table of contract take-up correlations ***
program corr_table
    syntax, attendance(string) // for expected vs. actual attendance
	
		if "`attendance'" == "expected" local attendance "days_0"
		else if "`attendance'" == "actual" local attendance "incentive == 0 & visits"
	
		* Summarize correlation between take-up more- & fewer-visit contracts
		forval i = 8(4)16 {
			* (1) Correlation
			di("(1) `i' visits")
			pwcorr commit`i' anticommit`i', sig
			* (2) Correlation given attendance no more than target - 2
			di("(2) att. <= `i' - 2, `i' visits")
			pwcorr commit`i' anticommit`i' if `attendance' <= `i' - 2, sig
			* (3) Correlation given attendance no more than target - 4
			di("(3) att. <= `i' - 4, `i' visits")
			pwcorr commit`i' anticommit`i' if `attendance' <= `i' - 4, sig
			* (4) Correlation given attendance at least target + 1
			di("(4) att. >= `i' + 1, `i' visits")
			pwcorr commit`i' anticommit`i' if `attendance' >= `i' + 1, sig
			* (5) Correlation given attendance at least target + 3
			di("(5) att. >= `i' + 3,`i' visits")
			pwcorr commit`i' anticommit`i' if `attendance' >= `i' + 3, sig
			* (6) Correlation given attendance no more than 6
			di("(6) att. <= 6, `i' visits")
			pwcorr commit`i' anticommit`i' if `attendance' <= 6, sig
			* (7) Correlation given attendance at least 17
			di("(7) att. >= 17, `i' visits")
			pwcorr commit`i' anticommit`i' if `attendance' >= 17, sig
			}
end
	
* Obtain correlations for table
corr_table, attendance(expected)


*** (bcp_on_behavior_change.tex) **********************************************

preserve
*** Reshape to long format
reshape long delta diffa, i(id) j(index)

*** Run regression of behavior change premium on behavior change, excl. $1
* Without wave fixed effects
reg delta diffa if index > 1, cluster(id)
est store bcpbc1

* Store mean & fixed effects information
estadd local wavefe "No"
ci means delta if e(sample)
local m : di %4.2f r(mean)
loc se : di %4.2f r(se)
estadd local dvmean `m'
estadd local dvse "(`se')"

* With wave fixed effects
reg delta diffa wave? if index > 1, cluster(id) nocons
est store bcpbc2

* Store mean & fixed effects information
estadd local wavefe "Yes"
ci means delta if e(sample)
local m : di %4.2f r(mean)
loc se : di %4.2f r(se)
estadd local dvmean `m'
estadd local dvse "(`se')"

*** Export table
estout bcpbc* using "bcp_on_behavior_change.tex", ///
style(tex) margin replace eqlabels(none) drop(wave*) ///
mgroups("\shortstack{Behavior change \\ premium}", pattern(1) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mlabels("(1)" "(2)", span prefix(\multicolumn{@span}{c}{) suffix(})) ///
varlabels(diffa "Expected behavior change" _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 wavefe N N_clust, l("Dep. var. mean:" " " "\hline Wave FEs" "N" "Clusters") fmt(%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


*** (bcp_on_risk_aversion.tex) *************************************************

/* Note: this table is not included in the paper, but the results are

   referenced in footnote 12. */

*** Generate risk aversion variables
* Generate indicator for not choosing options with more risk but no addtl. return
gen risk_averse = risk_aversion <= 5

* Generate indicator for above median risk aversion
sum risk_aversion, d
gen abovemed_risk_aversion = risk_aversion <= r(p50)

*** Run regressions on a range of risk aversion variables
eststo clear
loc k = 1
foreach covar in "risk_aversion" "abovemed_risk_aversion" "risk_averse" {

	reg avg_delta_ex1 `covar' wave2 wave3, r
	eststo spec_`k'
	loc ++k

	* Store mean & fixed effects information
	estadd local wavefe "Yes"
	ci means avg_delta_ex1 if e(sample)
	local m : di %4.2f r(mean)
	loc se : di %4.2f r(se)
	estadd local dvmean `m'
	estadd local dvse "(`se')"
	
	}
	
*** Export table
estout spec* using "bcp_on_risk_aversion.tex", ///
style(tex) margin replace eqlabels(none) drop(wave* _cons) ///
mgroups("\shortstack{Behavior change premium}", pattern(1 0 0) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mlabels("(1)" "(2)" "(3)", span prefix(\multicolumn{@span}{c}{) suffix(})) ///
varlabels(risk_aversion "Risk aversion" abovemed_risk_aversion "Above median risk aversion" risk_averse "Risk averse") ///
cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
stats(dvmean dvse wavefe N, l("Dep. var. mean:" " " "\hline Wave FEs" "N") fmt(%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}")

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

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

*** Variable Creation & Cleaning Steps ***
*** 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<.

*** Restrict sample to those exogenously assigned incentives
keep if flag_low_wtp == 0 & flag_exclude_exog == 0	


*** (DailyAttIncr.tex) ********************************************************

preserve
keep if commit12 == 1
gen got_incentive = 1 if treatment == "threshold80_12"
replace got_incentive = 0 if treatment == "control"
tab got_incentive
keep if !missing(got_incentive)
gen incentive_day = day*got_incentive

* Run regression of attendance on assignment to contract and day
reg attended day got_incentive incentive_day wave2 wave3, clus(id)
est store estday
estadd local wavefe "Yes"
restore

* Export regression output
estout estday using "DailyAttIncr.tex", style(tex) margin replace eqlabels(none) ///
order(day got_incentive incentive_day _cons) ///
drop(wave2 wave3 _cons) ///
mgroups("\shortstack{Attendance \\ likelihood}", pattern(1) span prefix(\multicolumn{@span}{c}{) suffix(})) ///
mlabels("(1)",span prefix(\multicolumn{@span}{c}{) suffix(})) ///
varlabels(day "Day" got_incentive "12+ visits contract" incentive_day "Day $\times$ 12+ visits contract") ///
cells(b(star fmt(%9.3f))  se(par fmt(%9.3f))) msign(--) starlevels(* 0.1 ** 0.05 *** 0.01) stardetach ///
stats(wavefe N N_clust, l("Wave FEs" "N" "Clusters") fmt(%8.0fc %8.0fc)) ///
collabels(,none) ///
prehead( "\begin{tabular}{l*{@M}{r @{} l}}" "\hline") ///
posthead("\hline") ///
prefoot("\hline") ///
postfoot("\hline\hline" "\end{tabular}")