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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
clear all






// insheet the data
if 1  {

	insheet using "data/raw/expBbatch1.csv", names
	drop if _n <= 2 // drop lines added by qualtrics
	gen batch = 1
	gen id = _n + 1000*batch
	destring, replace
	rename treatment fined /*DZ: fined=1 designates treated with BLB intervention.*/

	drop if _n == 1 // dropping text line that qualtrics adds
	destring, replace


	gen attrited = finlit3 ~= . & impl111_impl11_1 == .
	gen attritedLate = q182 ~= . & impl111_impl11_1 == .

	save "data/batch1.dta", replace 

	clear 


	insheet using "data/raw/expBbatch2.csv", names
	drop if _n <= 2 // drop lines added by qualtrics
	gen batch = 2
	gen id = _n + 1000*batch
	destring, replace
	rename treatment fined /*DZ: fined=1 designates treated with BLB intervention.*/

	drop if _n == 1 // dropping text line that qualtrics adds
	destring, replace


	gen attrited = finlit3 ~= . & impl111_impl11_1 == .
	gen attritedLate = q182 ~= . & impl111_impl11_1 == .

	save "data/batch2.dta", replace

	clear
	
	use "data/batch1.dta", replace
	append using "data/batch2.dta" 



	save "data/dataRaw.dta", replace
}

use "data/dataRaw.dta", replace


// 




** find switching points

// strategy:
// 1. reshape
// 2. order
// 3. gen variable in order starting from 35, going down
// 4. gen second variable, set to missing if choice was 1, to order otherwise, egen min of these
// 5. gen third variable, set to missing if choice was 2, to order otherwise, egen max of those
// 6. check for single switch by comparing whether max + 1 == min

***************************************************************************************************************

forvalues i = 1/10 {
	gen s`i' = 0
}

replace s1  = 1 if test1  == 2
replace s2  = 1 if test2  == 4
replace s3  = 1 if test3  == 4
replace s4  = 1 if test4  == 7
replace s5  = 1 if test5  == 6
replace s6  = 1 if test6  == 4
replace s7  = 1 if test7  == 5
replace s8  = 1 if test8  == 5
replace s9  = 1 if test9  == 5
replace s10 = 1 if test10 == 1


gen score = s1+s2+s3+s4+s5+s6+s7+s8+s9+s10



preserve
/*rename sc0_0 score*/

gen pay_test = payment_for_test <= 25
keep ip id amt_id gender age ethnicity educ marital urban income employed hh_size stocks rule72* calculate line1 line2 amt1 amt2 decision_index pay_test payment_for_test fined finlit* att* help_test test* startdate enddate durationinseconds time* score
save "data/dataNon_MPL.dta", replace
restore

*****************************************************************************************************************8

keep id impl*

forvalues i = 1 / 20 {
	rename impl`i'11_impl`i'1_1 	 impl`i'_1 	 
	rename impl`i'11_impl`i'1_2 	 impl`i'_2 	 
	rename impl`i'11_impl`i'1_3 	 impl`i'_3 	 
	rename impl`i'11_impl`i'1_4 	 impl`i'_4 	 
	rename impl`i'11_impl`i'1_5 	 impl`i'_5 	 
	rename impl`i'11_impl`i'1_6 	 impl`i'_6 	 
	rename impl`i'11_impl`i'1_7 	 impl`i'_7 	 
	rename impl`i'11_impl`i'1_8 	 impl`i'_8	 
	rename impl`i'11_impl`i'1_9 	 impl`i'_9 	 
	rename impl`i'11_impl`i'1_10 	 impl`i'_10 	 
	rename impl`i'11_impl`i'1_11 	 impl`i'_11 
}

keep impl1_* impl2_* impl3_* impl4_* impl5_* impl6_* impl7_* impl8_* impl9_* impl10_* impl11_* impl12_* impl13_* impl14_* impl15_* impl16_* impl17_* impl18_* impl19_* impl20_* id 
reshape long impl1_ impl2_ impl3_ impl4_ impl5_ impl6_ impl7_ impl8_ impl9_ impl10_ impl11_ impl12_ impl13_ impl14_ impl15_ impl16_ impl17_ impl18_ impl19_ impl20_, i(id) j(line 1-11)

forvalues i = 1 / 20 {
	rename impl`i'_ impl`i'
}

sort id line

gen sum_multi_switch_1 = 0

local varlist impl1
forvalues i=2/20 {
	local varlist `varlist' impl`i'
}


** first pricelist

foreach var in `varlist' { /*At this point varlist includes impl1, impl2, ... impl20*/

	gen line_left = line
	gen line_right = line
	replace line_left = . if `var' == 1
	replace line_right = . if `var' == 0
	
	by id: egen switch_low = max(line_left)
	by id: egen switch_high = min(line_right)
	by id: egen mll = max(line_left)
	by id: egen mlr = min(line_right)
	
	gen multi_switch_`var' = 1 - (switch_high == 1 + switch_low)
	replace multi_switch_`var' = 0 if switch_high == 11 | switch_high == . | switch_low == 1 | switch_low == .
	
	gen value_`var' = switch_high
	replace value_`var' = . if multi_switch_`var' == 1 
	replace value_`var' = 0 if mlr == 1 //case where all right selected
	replace value_`var' = 12 if mll == 11 // case where all left selected
	
	replace sum_multi_switch_1 = sum_multi_switch_1 + multi_switch_`var'
	
	drop line_left
 	drop line_right
	drop switch_high
	drop switch_low	
	drop mll
	drop mlr

	gen value_coarse_`var' = 20 - 2*(value_`var'-1)
	
}	


preserve
	drop value_impl* 
	drop impl*
	collapse (mean) value* sum_multi* (max) multi*, by(id)
	save "data/data_Coarse.dta", replace
restore




***********************************
*** fine valuations ***************
***********************************


clear all
set more off
use "data/dataRaw.dta"

keep id impl*


forvalues i = 1 / 20 {
	rename impl`i'21_impl`i'2_3 	 impl`i'_1 	 
	rename impl`i'21_impl`i'2_4 	 impl`i'_2 	 
	rename impl`i'21_impl`i'2_5 	 impl`i'_3 	 
	rename impl`i'21_impl`i'2_6 	 impl`i'_4
	rename impl`i'21_impl`i'2_7 	 impl`i'_5 	 
	rename impl`i'21_impl`i'2_8 	 impl`i'_6 	 
	rename impl`i'21_impl`i'2_9 	 impl`i'_7 	 
	rename impl`i'21_impl`i'2_10 	 impl`i'_8 
	rename impl`i'21_impl`i'2_11 	 impl`i'_9 	 
	rename impl`i'21_impl`i'2_12 	 impl`i'_10 
	
}




keep impl1_* impl2_* impl3_* impl4_* impl5_* impl6_* impl7_* impl8_* impl9_* impl10_* impl11_* impl12_* impl13_* impl14_* impl15_* impl16_* impl17_* impl18_* impl19_* impl20_*  id
reshape long impl1_ impl2_ impl3_ impl4_ impl5_ impl6_ impl7_ impl8_ impl9_ impl10_ impl11_ impl12_ impl13_ impl14_ impl15_ impl16_ impl17_ impl18_ impl19_ impl20_ , i(id) j(line 1-10)

forvalues i = 1 / 20 {
	rename impl`i'_ impl`i'
}

sort id line

gen sum_multi_switch_2 = 0

local varlist impl1
forvalues i=2/20 {
	local varlist `varlist' impl`i'
}

 



** second pricelist

foreach var in `varlist' {

	gen line_left = line
	gen line_right = line
	replace line_left = . if `var' == 1
	replace line_right = . if `var' == 0
	
	by id: egen switch_low = max(line_left)
	by id: egen switch_high = min(line_right)
	by id: egen mll = max(line_left)
	by id: egen mlr = min(line_right)


	
	gen multi_switch_`var' = 1 - (switch_high == 1 + switch_low)
	replace multi_switch_`var' = 0 if (switch_high == 1 & switch_low == .) | (switch_high == . & switch_low == 10)
	
	gen value_`var' = switch_low
	replace value_`var' = . if multi_switch_`var' == 1 
	replace value_`var' = 0 if mlr == 1 //case where all right selected
	replace value_`var' = 10 if mll == 10 // case where all left selected
	
	replace sum_multi_switch_2 = sum_multi_switch_2 + multi_switch_`var'
	
	drop line_left
 	drop line_right
	drop switch_high
	drop switch_low	
	drop mll
	drop mlr

	gen value_fine_`var' = 1.8 - 0.2*value_`var'
	replace value_fine_`var' = 0 if value_fine_`var' < 0
}	


drop value_impl* 
drop impl*

collapse (mean) value* sum_multi* (max) multi*, by(id)

save "data/data_Fine.dta", replace






***********************************
*** merge datasets  ***************
***********************************

clear all
use "data/data_Fine.dta"
merge 1:1 id  using "data/data_Coarse.dta"
drop _merge
merge 1:1 id using "data/dataNon_MPL.dta"
drop _merge

/*DZ: Slight change in naming of variables.*/
forvalues i = 1/20 {
	gen value`i' = value_coarse_impl`i' + value_fine_impl`i'

	rename time`i'1_firstclick timeFirstClick`i'
	rename time`i'1_lastclick timeLastClick`i'
	rename time`i'1_pagesubmit timeSubmit`i'
	rename time`i'1_clickcount numClicks`i'

}



***********************************



gen multi = 0
forvalues i = 1 / 20 {
	replace multi = 1 if multi_switch_impl`i' == 1
	replace multi = 1 if sum_multi_switch_1 == 1 | sum_multi_switch_2 == 1
}
drop multi_*


drop value_*



reshape long value timeFirstClick timeLastClick timeSubmit numClicks, i(id) j(treatment)




gen framed = treatment > 10

gen delay = 72
replace delay = 36 if treatment >=6 & treatment <= 10
replace delay = 36 if treatment == 11 | treatment == 13 | treatment == 15 | treatment == 17 | treatment == 19


gen amount = 20 
replace amount = 18 if treatment == 2 | treatment == 7  | treatment == 14 | treatment == 13
replace amount = 16 if treatment == 3 | treatment == 8  | treatment == 16 | treatment == 15
replace amount = 14 if treatment == 4 | treatment == 9  | treatment == 18 | treatment == 17
replace amount = 12 if treatment == 5 | treatment == 10 | treatment == 20 | treatment == 19

gen amount_precise = amount


// rename treatments such that #framed = #unframed + 10

gen tr_new = tr
replace tr_new = 1 if treat == 6
replace tr_new = 2 if treat == 1
replace tr_new = 3 if treat == 7
replace tr_new = 4 if treat == 2
replace tr_new = 5 if treat == 8
replace tr_new = 6 if treat == 3
replace tr_new = 7 if treat == 9
replace tr_new = 8 if treat == 4
replace tr_new = 9 if treat == 10
replace tr_new = 10 if treat == 5

rename treatment tr_old
rename tr_new treatment

replace treatment = treatment - 10 if framed == 1


replace amount_precise = 20.40 if treatment == 11 | treatment == 1
replace amount_precise = 20.47 if treatment == 12 | treatment == 2
replace amount_precise = 18.47 if treatment == 13 | treatment == 3
replace amount_precise = 18.73 if treatment == 14 | treatment == 4
replace amount_precise = 16.29 if treatment == 15 | treatment == 5
replace amount_precise = 16.80 if treatment == 16 | treatment == 6
replace amount_precise = 14.37 if treatment == 17 | treatment == 7
replace amount_precise = 15.16 if treatment == 18 | treatment == 8
replace amount_precise = 11.58 if treatment == 19 | treatment == 9
replace amount_precise = 11.83 if treatment == 20 | treatment == 10



gen id_alt = 1000*id+treatment
sort id_alt
order id_alt delay treatment tr_old

drop tr_old

reshape wide value timeFirstClick timeLastClick timeSubmit numClicks, i(id_alt) j(framed)

rename value0 v_unframed
rename value1 v_framed


rename timeFirstClick0 timeFirstClickUnframed
rename timeFirstClick1 timeFirstClickFramed
rename timeLastClick0 timeLastClickUnframed
rename timeLastClick1 timeLastClickFramed
rename timeSubmit0 timeSubmitUnframed
rename timeSubmit1 timeSubmitFramed
rename numClicks0 numClicksUnframed
rename numClicks1 numClicksFramed



gen difficulty = 0
replace difficulty = 1 if treatment >= 3 & treatment <= 8
replace difficulty = 2 if treatment >= 9

gen start = 10
replace start = 4.5 if treatment == 3 | treatment == 4
replace start = 2 if treatment == 5 | treatment == 6 | treatment == 9 | treatment == 10
replace start = 0.9 if treatment == 7 | treatment == 8

gen r = .
replace r = 0.02 if treatment == 1 
replace r = 0.01 if treatment == 2 
replace r = 0.04 if treatment == 3 
replace r = 0.02 if treatment == 4 
replace r = 0.06 if treatment == 5 
replace r = 0.03 if treatment == 6 
replace r = 0.08 if treatment == 7 
replace r = 0.04 if treatment == 8 
replace r = 0.05 if treatment == 9 
replace r = 0.25 if treatment == 10


gen doublings = 1
replace doublings = 2 if treatment == 3 | treatment == 4
replace doublings = 3 if treatment == 5 | treatment == 6 
replace doublings = 4 if treatment == 7 | treatment == 8  
replace doublings = 2.5 if treatment == 9 | treatment == 10


replace age = age + 17

forvalues i = 1/10 {
	gen t`i' = 0
}

replace t1  = 1 if test1  == 2
replace t2  = 1 if test2  == 4
replace t3  = 1 if test3  == 4
replace t4  = 1 if test4  == 7
replace t5  = 1 if test5  == 6
replace t6  = 1 if test6  == 4
replace t7  = 1 if test7  == 4
replace t8  = 1 if test8  == 5
replace t9  = 1 if test9  == 5
replace t10 = 1 if test10 == 5



gen score_compounding = t1+t2+t3+t4+t5
gen score_indexing = score - score_compounding

gen fl1 = finlit1 == 1
gen fl2 = finlit2 == 1
gen fl3 = finlit3 == 3
gen fl4 = finlit4 == 1
gen fl5 = finlit5 == 2
gen fl_score = (fl1 == 1) * (fl2 == 1) * (fl3 == 1) * (fl4 == 1) * (fl5 == 1)
gen fl_sum = (fl1 == 1) + (fl2 == 1) + (fl3 == 1) + (fl4 == 1) + (fl5 == 1)
gen fl_score_compound = (fl1 == 1) * (fl2 == 1) * (fl3 == 1) 
gen fl_sum_compound = (fl1 == 1) + (fl2 == 1) + (fl3 == 1)

gen size_error_simple = .
replace size_error_simple = 3.20 if treatment == 1 
replace size_error_simple = 3.27 if treatment == 2 
replace size_error_simple = 7.49 if treatment == 3 
replace size_error_simple = 7.75 if treatment == 4 
replace size_error_simple = 9.97 if treatment == 5 
replace size_error_simple = 10.48 if treatment == 6 
replace size_error_simple = 10.88 if treatment == 7 
replace size_error_simple = 11.66 if treatment == 8 
replace size_error_simple = 5.98 if treatment == 9 
replace size_error_simple = 6.23 if treatment == 10






// use midpoint of the interval for analysis
replace v_framed = v_framed + 0.1
replace v_unframed = v_unframed + 0.1

replace v_framed = 0 if v_framed <= 0
replace v_unframed = 0 if v_unframed <= 0

************ monotonicity violations
sort id
gen v_u_1_i = v_unframed if amount == 12
gen v_u_2_i = v_unframed if amount == 14
gen v_u_3_i = v_unframed if amount == 16
gen v_u_4_i = v_unframed if amount == 18
gen v_u_5_i = v_unframed if amount == 20
by id: egen v_u_1 = max(v_u_1_i) 
by id: egen v_u_2 = max(v_u_2_i) 
by id: egen v_u_3 = max(v_u_3_i) 
by id: egen v_u_4 = max(v_u_4_i) 
by id: egen v_u_5 = max(v_u_5_i) 

gen monotonic_u = (v_u_1 <= v_u_2 & v_u_2 <= v_u_3 & v_u_3 <= v_u_4 & v_u_4 <= v_u_5)

gen v_f_1_i = v_framed if amount == 12
gen v_f_2_i = v_framed if amount == 14
gen v_f_3_i = v_framed if amount == 16
gen v_f_4_i = v_framed if amount == 18
gen v_f_5_i = v_framed if amount == 20
by id: egen v_f_1 = max(v_f_1_i) 
by id: egen v_f_2 = max(v_f_2_i) 
by id: egen v_f_3 = max(v_f_3_i) 
by id: egen v_f_4 = max(v_f_4_i) 
by id: egen v_f_5 = max(v_f_5_i) 

gen monotonic_f = (v_f_1 <= v_f_2 & v_f_2 <= v_f_3 & v_f_3 <= v_f_4 & v_f_4 <= v_f_5)



egen tag_id = tag(id)


gen duration = durationinseconds/60 /* duration in minutes */


gen afram = ethnicity == 1
gen asian = ethnicity == 2
gen caucasian = ethnicity == 3
gen hispanic = ethnicity == 4
gen other = ethnicity == 5


gen lessThanHighSchool = educ <= 2
gen highSchool = educ == 3
gen voc = educ == 4
gen someCollege = educ == 5
gen college = educ == 6
gen graduate = educ >= 7

gen rural = urban == 3
gen urbanSuburban = urban <= 2

gen fullTime = employed == 3
gen partTime = employed == 2

gen hh1 = hh_size == 1
gen hh2 = hh_size == 2
gen hh3 = hh_size == 3
gen hh4 = hh_size >= 4

gen married = marital == 3 | marital == 4
gen widowed = marital == 6
gen divorced = marital == 1
gen never_married = marital == 2 | marital == 5 

gen ownStocks = stocks == 1



drop line1 line2 decision_index
drop if test10 == .
save "data/dataExpB.dta", replace