Download 26/replication_package/doFiles/dataManagementExpA.do from chuxuan/REPRO-Bench: direct link, hf CLI and curl.
- Browser
- Download file 17.3 kB
-
https://huggingface.co/datasets/chuxuan/REPRO-Bench/resolve/main/26/replication_package/doFiles/dataManagementExpA.do
- Command line
-
hf download hf://datasets/chuxuan/REPRO-Bench/26/replication_package/doFiles/dataManagementExpA.do
-
curl -L -o dataManagementExpA.do https://huggingface.co/datasets/chuxuan/REPRO-Bench/resolve/main/26/replication_package/doFiles/dataManagementExpA.do
17.3 kB
| clear all | |
| ******* bring Qualtrics data into stata format | |
| insheet using "data/raw/expAbatch1.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 1000 | |
| destring, replace | |
| rename treatment fined | |
| save "data/raw_1.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch2.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 2000 | |
| drop excluded | |
| destring, replace | |
| rename treatment fined | |
| save "data/raw_2.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch3.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 3000 | |
| destring, replace | |
| drop excluded | |
| rename treatment fined | |
| replace fined = 2 if fined == 1 // 2 is substance only | |
| replace fined = 3 if fined == 0 // 3 is rhetoric only | |
| save "data/raw_3.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch4.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 4000 | |
| destring, replace | |
| drop excluded | |
| rename treatment fined | |
| save "data/raw_4.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch5.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 5000 | |
| destring, replace | |
| drop excluded | |
| rename treatment fined | |
| save "data/raw_5.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch6.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 6000 | |
| destring, replace | |
| drop excluded | |
| rename treatment fined | |
| replace fined = 2 if fined == 1 // 2 is substance only | |
| replace fined = 3 if fined == 0 // 3 is rhetoric only | |
| save "data/raw_6.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch7.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 7000 | |
| destring, replace | |
| drop excluded | |
| rename treatment fined | |
| replace fined = 2 if fined == 1 // 2 is substance only | |
| replace fined = 3 if fined == 0 // 3 is rhetoric only | |
| save "data/raw_7.dta", replace | |
| clear | |
| insheet using "data/raw/expAbatch8.csv", names | |
| gen id = _n | |
| drop if id == 1 | |
| replace id = id - 1 + 8000 | |
| destring, replace | |
| drop excluded | |
| rename treatment fined | |
| replace fined = 2 if fined == 1 // 2 is substance only | |
| replace fined = 3 if fined == 0 // 3 is rhetoric only | |
| drop codewt | |
| drop codetreat | |
| save "data/raw_8.dta", replace | |
| clear | |
| use "data/raw_1.dta" | |
| append using "data/raw_2.dta" | |
| append using "data/raw_3.dta" | |
| append using "data/raw_4.dta" | |
| append using "data/raw_5.dta" | |
| append using "data/raw_6.dta" | |
| append using "data/raw_7.dta" | |
| append using "data/raw_8.dta" | |
| rename v6 ip | |
| rename v8 startDate | |
| rename v9 endDate | |
| ***** attrition | |
| gen attrited = help_test == . | |
| gen attrition_before_video = q120 == . | |
| gen started_video = (q124 == 1 | q125 == 1) | |
| preserve | |
| keep id attrited attrition_before_video started_video fined | |
| save "data/attrition.dta", replace | |
| restore | |
| drop if help_test == . | |
| drop attrited attrition_before_video started_video | |
| save "data/raw_all.dta", replace | |
| ** find switching points | |
| // strategy: | |
| // 1. reshape | |
| // 2. order | |
| // 3. generate variable in order starting from 35, going down | |
| // 4. generate second variable, set to missing if choice was 1, to order otherwise, egen min of these | |
| // 5. generate 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 | |
| preserve | |
| rename sc0_0 score | |
| gen pay_test = payment_for_test <= 25 | |
| keep id ip 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 score fined finlit* att* help_test test* startDate endDate time* | |
| save "data/non_MPL.dta", replace | |
| restore | |
| keep id impl* | |
| forvalues i = 1 / 20 { | |
| rename impl`i'_1_11 impl`i'_1 | |
| rename impl`i'_1_21 impl`i'_2 | |
| rename impl`i'_1_31 impl`i'_3 | |
| rename impl`i'_1_41 impl`i'_4 | |
| rename impl`i'_1_51 impl`i'_5 | |
| rename impl`i'_1_61 impl`i'_6 | |
| rename impl`i'_1_71 impl`i'_7 | |
| rename impl`i'_1_81 impl`i'_8 | |
| rename impl`i'_1_91 impl`i'_9 | |
| rename impl`i'_1_101 impl`i'_10 | |
| rename impl`i'_1_111 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 for each delayed reward | |
| 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 == 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 | |
| // second pricelist for each delayed reward | |
| clear all | |
| set more off | |
| use "data/raw_all.dta" | |
| keep id impl* | |
| forvalues i = 1 / 20 { | |
| rename impl`i'_2_31 impl`i'_1 | |
| rename impl`i'_2_41 impl`i'_2 | |
| rename impl`i'_2_51 impl`i'_3 | |
| rename impl`i'_2_61 impl`i'_4 | |
| rename impl`i'_2_71 impl`i'_5 | |
| rename impl`i'_2_81 impl`i'_6 | |
| rename impl`i'_2_91 impl`i'_7 | |
| rename impl`i'_2_101 impl`i'_8 | |
| rename impl`i'_2_111 impl`i'_9 | |
| rename impl`i'_2_121 impl`i'_10 | |
| drop impl`i'_1_* | |
| } | |
| 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' | |
| } | |
| 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/non_MPL.dta" | |
| drop _merge | |
| forvalues i = 1/20 { | |
| gen value`i' = value_coarse_impl`i' + value_fine_impl`i' | |
| rename time`i'1_1 timeFirstClick`i' | |
| rename time`i'1_2 timeLastClick`i' | |
| rename time`i'1_3 timeSubmit`i' | |
| rename time`i'1_4 numClicks`i' | |
| } | |
| // Label variables conveniently | |
| 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_* 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 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 == 3 | |
| replace t7 = 1 if test7 == 4 | |
| replace t8 = 1 if test8 == 2 | |
| replace t9 = 1 if test9 == 3 | |
| replace t10 = 1 if test10 == 3 | |
| 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 | |
| merge m:1 id using "data/attrition.dta" | |
| gen double startTime = clock(startDate, "YMDhms") | |
| gen double endTime = clock(endDate, "YMDhms") | |
| gen double duration = endTime - startTime | |
| replace duration = duration / (1000*60) // duration in minutes | |
| drop line1 line2 decision_index | |
| gen fl_high = fl_score_compound == 1 | |
| gen discount_unframed = v_unframed/amount * 100 | |
| gen discount_framed = v_framed/amount_precise * 100 | |
| gen discount_framed_72 = v_framed/amount * 100 | |
| sort id delay | |
| by id delay: egen min_discount_unframed = min(discount_unframed) | |
| by id delay: egen max_discount_unframed = max(discount_unframed) | |
| gen diff = discount_framed - discount_unframed | |
| gen diff72 = discount_framed - discount_unframed | |
| gen min_diff = discount_framed - min_discount_unframed | |
| gen max_diff = discount_framed - max_discount_unframed | |
| gen abs_diff = - abs(diff) | |
| gen sq_diff = - (diff/100)^2*100 | |
| gen sq_diff72 = - (diff72/100)^2*100 | |
| gen sq_diff_up = - (diff/100)^2*100 | |
| gen sq_diff_down = - (diff/100)^2*100 | |
| replace sq_diff_up = 0 if diff > 0 | |
| replace sq_diff_down = 0 if diff < 0 | |
| sort id | |
| by id: egen mean_diff = mean(diff) | |
| gen sq_mean_diff = - (mean_diff/100)^2*100 | |
| gen sq_mean_diff_up = - (mean_diff/100)^2*100 | |
| gen sq_mean_diff_down = - (mean_diff/100)^2*100 | |
| replace sq_mean_diff_up = 0 if mean_diff > 0 | |
| replace sq_mean_diff_down = 0 if mean_diff < 0 | |
| gen sqrt_diff = - sqrt(abs(diff)/100)*100 | |
| gen abs_min_diff = - abs(min_diff) | |
| gen abs_max_diff = - abs(max_diff) | |
| gen sq_min_diff = -(min_diff/100)^2*100 | |
| gen sq_max_diff = -(max_diff/100)^2*100 | |
| gen CVa = min(sq_min_diff, sq_max_diff) | |
| gen CVb = max(sq_min_diff, sq_max_diff) | |
| replace CVb = 0 if discount_framed <= max_discount_unframed & discount_framed >= min_discount_unframed | |
| gen asy_diff_up = diff | |
| replace asy_diff_up = 0 if diff > 0 | |
| gen asy_diff_down = - diff | |
| replace asy_diff_down = 0 if diff < 0 | |
| sort id delay | |
| by id delay: egen mean_disc = mean(discount_unframed) | |
| gen r72 = rule72 == 1 | |
| gen r72inv = rule72_inv == 1 | |
| // generate treatment dummies | |
| gen Control = fined == 0 // Control | |
| gen Full = fined == 1 // Full | |
| gen Rule72 = fined == 2 // Substance Only | |
| gen Rhetoric = fined == 3 // Rhetoric Only | |
| label define treatment 0 "Control" 1 "Full Treatment" 2 "Only Rule of 72" 3 "Only Rhetoric" | |
| label values fined treatment | |
| // measures of noise and inattention | |
| sort id delay | |
| by id delay: egen sdV = sd(v_framed) | |
| by id: egen mean_sdV = mean(sdV) | |
| gen slope_unframed = . | |
| gen slope_framed = . | |
| gen corr_unframed_framed = . | |
| gen r2_unframed_framed = . | |
| drop if id == -1 | |
| egen id3 = group(id) | |
| su id3 | |
| local max = r(max) | |
| forvalues i = 1/`max' { | |
| capture: reg discount_unframed amount if id3 == `i' | |
| capture: replace slope_unframed = _b[amount] if id3 == `i' | |
| capture: reg discount_framed amount_precise if id3 == `i' | |
| capture: replace slope_framed = _b[amount_precise] if id3 == `i' | |
| capture: reg discount_framed discount_unframed if id3 == `i' | |
| capture: replace corr_unframed_framed = _b[discount_unframed] if id3 == `i' | |
| capture: replace r2_unframed_framed = e(r2) if id3 == `i' | |
| } | |
| su slope_unframed, d | |
| gen lowSlope25 = slope_unframed <= r(p25) | |
| gen lowSlope50 = slope_unframed <= r(p50) | |
| gen lowSlope75 = slope_unframed <= r(p75) | |
| ***** Demographic variables | |
| 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 | |
| gen fl_high_remaining = fl4 == 1 & fl5 == 1 | |
| gen was_married = widowed == 1 | divorced == 1 | |
| gen highSchoolOrLess = highSchool == 1 | lessThanHighSchool == 1 | |
| gen vocOrSomeCollege = voc == 1 | someCollege == 1 | |
| gen hh3to5 = hh_size >= 2 & hh_size <= 5 | |
| gen hhGeq6 = hh_size >= 6 | |
| replace income = income / 1000 | |
| egen tag = tag(id) | |
| save "data/dataExpA.dta", replace | |