-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-RegressionAll-v4.do
1598 lines (1089 loc) · 63 KB
/
05-RegressionAll-v4.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
global project "C:\Users\xinxi\Purdue\PublicGood_SecondOption4Rich\Experiment\"
* directory "$project\DataAnalysis"
global datafolder "$project\ProcessedData"
global outputfolder "$project\Output"
***This version is for main_Text_v03.tex; pool up all results L, LG, for the main treatment variables and control for sequence
*************************************************************
import delimited "$datafolder\data_Oppor_allB.csv", clear
gen WithGlobal = 1
tempfile allB
save `allB', replace
import delimited "$datafolder\individual_type_allInfor.csv", clear
keep participantcode type*
tempfile type
save `type', replace
import delimited "$datafolder\data_noOppor_AllA.csv", clear
gen WithGlobal = 0
append using `allB'
merge m:1 participantcode using "$datafolder\individual_data"
drop _m
merge m:1 participantcode using `type'
tab WithGlobal
* Generate variables
//super game
tab subsessionsg
tab sequence
gen super_game = subsessionsg
// ABA
replace super_game = subsessionsg+1 if sequence == "B1"
replace super_game = subsessionsg+4 if sequence == "A2"
// BAB
replace super_game = subsessionsg+3 if sequence == "A2_bab"
replace super_game = subsessionsg+4 if sequence == "B2_bab"
tab super_game
// Round
gen round_whole = subsessionround_number
// ABA
replace round_whole = subsessionround_number + 10 if sequence == "B1"
replace round_whole = subsessionround_number + 60 if sequence == "A2"
// BAB
replace round_whole = subsessionround_number + 50 if sequence == "A2_bab"
replace round_whole = subsessionround_number + 70 if sequence == "B2_bab"
encode participantcode, gen(subject_id)
xtset subject_id round_whole
// No Local Interaction
gen no_local = 0
replace no_local = 1 if sequence=="B1_bab"
gen interaction_term = WithGlobal * no_local
label var interaction_term "With global * No previous local only interaction "
gen lowFC = fc==20
gen hetero = treatment == "HETERO"
gen highFC = 1- lowFC
gen endowment_adj = endowment
replace endowment = 10 if endowment<=10
replace endowment = 20 if endowment>10 & endowment<=20
replace endowment = 30 if endowment>20
gen hetero_high = hetero * (endowment==30)
gen hetero_low = hetero * (endowment==10)
gen hetero_lowCost = hetero * lowFC
gen hetero_highCost = hetero * highFC
gen With_High_Cost = WithGlobal* (lowFC==0)
gen With_High_Cost_Join = WithGlobal* (lowFC==0) *playerjoin_club
// Hetero * WithGlobal
gen hetero_with = hetero * WithGlobal
gen hetero_high_with = hetero_high * WithGlobal
// triple interaction
gen WithGlobal_join = WithGlobal * playerjoin_club
gen hetero_with_join = hetero_with * playerjoin_club
gen hetero_high_with_join = hetero_high_with * playerjoin_club
// encode some string variables
encode age, gen(age_g)
gen male=gender=="Male"
// replace male = . if gender=="Prefer Not to Say" // 2 subjects prefer not to say
gen age_under20 = age=="Under 20"
gen major_SorE = 0
replace major_SorE = 1 if strpos(major, "Economics or Management" )|strpos(major, "STEM" )
tab major_SorE major
// ? do I want to control others' contribution?
gen share_contr = tot_contr * 10 / playerendowment
// generate others' contribution
gen global_o = grouptotal_contribution_global - playercontribution_global
gen local_o = playertotal_contribution_local - playercontribution_local
bys sessioncode round_whole groupid_in_subsession: gen clubSize = sum(playerjoin_club)
bys sessioncode round_whole playerlocal_community: gen club_LocalN = sum(playerjoin_club)
gen club_LocalMembersNotMe = club_LocalN - playerjoin_club
gen club_OtherCommunityMembers = clubSize - club_LocalN
gen join_HighE = playerjoin_club * (endowment==30)
gen join_LowE = playerjoin_club * (endowment==10)
bys sessioncode round_whole groupid_in_subsession: gen clubJoinH = sum(join_HighE)
gen share_club_joinH = clubJoinH / clubSize
replace share_club_joinH = 0 if clubSize==0
gen clubSize_join = clubSize * playerjoin_club
* Whether the benefit from club exceeds the entry cost
gen dummy_payoff = 0
gen benefit_club = grouptotal_contribution_global*0.6
replace dummy_payoff=1 if benefit_club >fc
tabstat grouptotal_contribution_global if fc==20 & strpos(sequence,"B"), by(dummy_payoff)
tabstat grouptotal_contribution_global if fc==80 & strpos(sequence,"B"), by(dummy_payoff)
tabstat dummy_payoff if fc==20 & strpos(sequence,"B"), by(treatment)
tabstat dummy_payoff if fc==80 & strpos(sequence,"B"), by(treatment)
gen hetero_join = hetero * playerjoin_club
// Additional control variables
xtset subject_id round_whole
//hard coding, relevant to the random number realization: B1 = [6,18,17]; B2 = [8]
gen round_within = subsessionround_number
replace round_within = round_within - 10 if subsessionround_number>10 & subsessionround_number <=30
replace round_within = round_within - 30 if subsessionround_number>30
// round 1 join decision vs next round join decision
gen round1_join = playerjoin_club if subsessionperiod==1
bys subject_id: gen join_nextRound = f.playerjoin_club
// replace join_nextRound = round1_join if subsessionperiod==1
//hard coding, relevant to the random number realization: B1 = [6,18,17]; B2 = [8]
replace join_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
gen round1_globalCtr = playercontribution_global if subsessionperiod==1
bys subject_id: gen globalContr_nextRound = f.playercontribution_global
replace globalContr_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
gen round1_localCtr = playercontribution_local if subsessionperiod==1
bys subject_id: gen localContr_nextRound = f.playercontribution_local
replace localContr_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
bys subject_id: gen clubSize_nextRound = f.clubSize
replace clubSize_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
// for round 1, use the same variable (WHY?)
// replace clubSize_nextRound = clubSize if subsessionround_number==1
bys subject_id: gen clubJoinH_nextRound = f.clubJoinH
replace clubJoinH_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
// for round 1, use the same variable
// replace clubJoinH_nextRound = clubJoinH if subsessionround_number==1
bys subject_id: gen club_LocalMembersNotMe_nextRound = f.club_LocalMembersNotMe
replace club_LocalMembersNotMe_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
bys subject_id: gen club_OtherCommunity_nextRound = f.club_OtherCommunityMembers
replace club_OtherCommunity_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
gen round1_totCtr = tot_contr if subsessionperiod==1
bys subject_id: gen totCtr_nextRound = f.tot_contr
replace totCtr_nextRound = . if (subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50 ) & strpos(sequence, "B1")
replace totCtr_nextRound = . if subsessionround_number==10 & strpos(sequence, "A1")
replace totCtr_nextRound = . if subsessionround_number==20 & strpos(sequence, "A2")
replace totCtr_nextRound = . if subsessionround_number==10 & strpos(sequence, "B2")
gen share_totalContr = tot_contr / endowment_adj * 100
sum share_totalContr share_contr
gen round1_totCtr_share = share_totalContr if subsessionperiod==1
bys subject_id: gen totCtr_share_nextRound = f.share_totalContr
replace totCtr_share_nextRound = . if (subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50 ) & strpos(sequence, "B1")
replace totCtr_share_nextRound = . if subsessionround_number==10 & strpos(sequence, "A1")
replace totCtr_share_nextRound = . if subsessionround_number==20 & strpos(sequence, "A2")
replace totCtr_share_nextRound = . if subsessionround_number==10 & strpos(sequence, "B2")
// replace totCtr_nextRound = tot_contr if subsessionperiod==1
// To check
br round_whole subsessionsg tot_contr totCtr_nextRound round1_totCtr subsessionround_number
gen globalCtr_share = playercontribution_global / playerendowment*1000 if playerjoin_club==1
replace globalCtr_share = 0 if playerjoin_club==0 & WithGlobal==1
gen round1_share_tt = share_contr*100 if subsessionperiod==1
bys subject_id: gen share_tt_nextRound = f.share_contr*100
replace share_tt_nextRound = . if subsessionround_number==10 | subsessionround_number==30 | subsessionround_number==50
replace share_tt_nextRound = round1_share_tt if subsessionperiod==1
// for round 1, use the same variable
// replace share_tt_nextRound = share_contr if subsessionround_number==1
* Obtain contribution history (lagged)
bys subject_id: gen totCtr_lastRound = l.tot_contr
replace totCtr_lastRound = . if subsessionperiod == 1
foreach var of varlist playercontribution_local playercontribution_global local_o {
bys subject_id: gen `var'_lastR = l.`var'
replace `var'_lastR = . if subsessionperiod == 1
}
// FIll in the round 1 data (for the control variable)
bys subject_id super_game : replace round1_join = round1_join[_n-1] if round1_join==. & _n >1
bys subject_id super_game : replace round1_globalCtr = round1_globalCtr[_n-1] if round1_globalCtr==. & _n >1
bys subject_id super_game : replace round1_localCtr = round1_localCtr[_n-1] if round1_localCtr==. & _n >1
bys subject_id super_game : replace round1_totCtr = round1_totCtr[_n-1] if round1_totCtr==. & _n >1
bys subject_id super_game : replace round1_totCtr_share = round1_totCtr_share[_n-1] if round1_totCtr_share==. & _n >1
bys sessioncode sequence subsessionround_number groupid_in_subsession: egen join_t = sum(playerjoin_club)
sum join_t clubsize if strpos(sequence, "B1")
gen join_lastGC = playercontribution_global_lastR * playerjoin_club
bys sessioncode sequence subsessionround_number groupid_in_subsession: egen join_lastGC_t = sum(join_lastGC)
gen join_lastGC_t_o = join_lastGC_t - join_lastGC
sum join_lastGC_t_o if strpos(sequence, "A")
gen highFC_j = highFC * join_nextRound
replace highFC_j = highFC * playerjoin_club if subsessionperiod==1
gen hetero_j = hetero * join_nextRound
replace hetero_j = hetero * playerjoin_club if subsessionperiod==1
gen hetero_highCost_j = hetero * highFC * join_nextRound
replace hetero_highCost_j = hetero * highFC * playerjoin_club if subsessionperiod==1
gen global_share_r1 = round1_globalCtr/round1_totCtr * 100
gen global_share = globalContr_nextRound/totCtr_nextRound * 100
replace global_share = 0 if global_share==. & totCtr_nextRound!=.
* Dress up the variable names
gen round_d80 = round_whole/80
replace local_o = local_o/100
replace global_o = global_o /100
replace tot_contr = tot_contr
gen tot_contr_o100 = tot_contr/100
gen round_o10 = subsessionperiod/10
gen local_contr_o100 = playercontribution_local/100
label var round_d80 "Round Number / 80"
label var hetero "Hetero"
label var lowFC "Low entry cost"
label var hetero_lowCost "Hetero $\times$ LowC"
label var super_game "Super game number"
label var round_whole "Round number"
label var tot_contr "Own total contribution in round t / 100"
label var local_o "Other's local contribution in round t / 100 "
label var global_o "Other's global contribution in round t / 100 "
label var local_contr_o100 "Own local contribution in round t / 100"
label var age_under20 "Age under 20"
label var male "Male"
label var social_x "Disadvantageous inequality aversion"
label var social_y "Advantageous inequality aversion"
label var clubSize "Global club size in round t"
label var share_club_joinH "Club share of the high-endowed in round t"
label var hetero_join "Hetero $\times$ Join"
label var playerjoin_club "Join in round t"
label var join_HighE "Join * High endowment "
label var join_LowE "Join * Low endowment "
label var clubSize_join "Club size upon joining"
label var subsessionperiod "Round number"
label var club_OtherCommunityMembers "Number of other community's members in the club"
label var club_LocalMembersNotMe "Number of local members in the club"
label var dummy_payoff "Dummy of benefit from club exceeding the entry cost"
label var round_o10 "Round number / 10"
gen super_game_o5 = super_game/5
label var super_game_o5 "Supergame number / 5"
gen L_Environment = strpos(sequence,"A")
gen L_First = 1
replace L_First = 0 if strpos(sequence,"_bab")
tab L_First sequence
* To ensure that this file reports all the regression results for the main text
// keep if subsessionperiod<=10
// drop if sequence=="B2_bab" | sequence=="A2"
tab sequence
egen localCommunity = group(sessioncode playerlocal_community)
replace share_contr = share_contr*100
gen local_share = playercontribution_local / playerendowment * 10 * 100
sum local_share share_contr if WithGlobal==0
sum local_share share_contr
*##############################################
************ REGRESSIONS *****************************************
*##############################################
****************Order effect (contribution and join)
local indep L_First hetero highFC hetero_highCost
local game_contr super_game_o5 round_o10
// round_d80
local indiv_char age_under20 male major_SorE social_x social_y
// type*
local contr `game_contr' `indiv_char'
local filename "$outputfolder\05-RegressionAll-v4-RandomEF-DID-order.xls"
local settings "onecol nonotes label dec(2) pdec(3) "
* Random effect regression
local contr `game_contr' `indiv_char'
xi: xtreg share_contr `indep' `contr' if super_game==2, re cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle(" total \% LG2")
xi: xtreg globalCtr_share `indep' `contr' if super_game==2, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("global \% LG2")
xi: xtreg local_share `indep' `contr' if super_game==2, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("local \% LG2")
xi: xtreg playerjoin_club `indep' `contr' if super_game==2, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Join LG2")
xi: xtreg playerpayoff `indep' `contr' if super_game==2, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Payoff LG2")
xi: xtreg share_contr `indep' `contr' if super_game>=2, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle(" total \% LG2+")
xi: xtreg playerpayoff `indep' `contr' if super_game>=2 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Payoff LG2+")
xi: xtreg globalCtr_share `indep' `contr' if super_game>=2 & WithGlobal==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("global \% LG2+")
xi: xtreg local_share `indep' `contr' if super_game>=2, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("local \% LG2+")
xi: xtreg playerjoin_club `indep' `contr' if super_game>=2 & WithGlobal==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Join LG2+")
*********Individual analysis (join and tradeoff)
****************Local Only: contribution ****************
local treatment_related hetero highFC hetero_highCost
local game_contr super_game_o5 round_o10 L_First
// i.localCommunity // if control local community then the difference of heterogeneous communities are much stronger
local indiv_char age_under20 male major_SorE social_x social_y
local all_controls `game_contr' `indiv_char'
local settings "onecol nonotes drop(_Ilocal* ) label dec(3) pdec(3) "
local filename "$outputfolder\05-RegressionAll-v4-RandomEF-Contr-L.xls"
* L, Contribution %
xi: xtreg share_totalContr hetero `all_controls' if WithGlobal==0 & subsessionperiod<=10 , re cluster(sessioncode)
outreg2 using `filename' , replace `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 1-10")
xi: xtreg totCtr_share_nextRound hetero `all_controls' local_o if WithGlobal==0 & subsessionperiod<10 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-10")
xi: xtreg totCtr_share_nextRound hetero `all_controls' local_o if WithGlobal==0 & subsessionperiod<20 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-20")
***************************Global Only: Join behavior *****************************************
* Prob of joining the club
local settings "onecol nonotes label dec(3) pdec(3) "
local independentVar highFC hetero
local independentVar2 highFC hetero hetero_highCost
*IF by costs:
local endowment_diff hetero_high hetero_low
local game_contr super_game_o5 round_o10 L_First
local indiv_char age_under20 male major_SorE social_x social_y
// type*
local myC round1_join local_contr_o100
local othersC local_o
local club_infor dummy_payoff global_o share_club_joinH clubSize
local club_infor2 dummy_payoff global_o share_club_joinH club_LocalMembersNotMe club_OtherCommunityMembers
local filename "$outputfolder\05-RegressionAll-v4-RandomEF-Join.xls"
* Random effect regression
xi: xtreg playerjoin_club `independentVar2' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod<=10, re cluster(sessioncode)
outreg2 using `filename' , replace `settings' addstat(Overall R-squared, `e(r2_o)')
xi: xtreg join_nextRound `independentVar2' `game_contr' `myC' `othersC' `club_infor2' `indiv_char' if WithGlobal==1 & subsessionperiod<10, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)')
xi: xtreg join_nextRound `independentVar2' `game_contr' `myC' `othersC' `club_infor2' `indiv_char' if WithGlobal==1 & subsessionperiod<20, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)')
;
gen global_over_total = playercontribution_global / (playercontribution_global + playercontribution_local) *100
replace global_over_total=. if playerjoin_club==0
tab global_over_total if playerjoin_club==1,mi
replace global_over_total = 0 if playercontribution_global + playercontribution_local==0 & global_over_total==. & playerjoin_club==1
local settings "onecol nonotes label dec(3) pdec(3) "
local treatment_related highFC hetero hetero_highCost
local game_contr super_game_o5 round_o10 L_First
local indiv_char age_under20 male major_SorE social_x social_y
// type*
* Stage 2 contribution share depends on stage 1 choice
local factors club_LocalMembersNotMe club_OtherCommunityMembers
local contr_previous round1_join playercontribution_local_lastR join_lastGC_t_o local_o_lastR share_club_joinH `factors'
label var playercontribution_local_lastR "Own local contribution in round t-1"
label var join_lastGC_t_o "Other joined members' total global contribution in round t-1"
label var local_o_lastR "Local contribution from others in round t-1"
// local contr_previous round1_join tot_contr global_o local_o share_club_joinH `factors'
//clubJoinH clubSize
local filename "$outputfolder\05-RegressionAll-v4-Main-Treatment-Contr-LG.xls"
// xi: xtreg globalCtr_share `treatment_related' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod<=10, re cluster(sessioncode)
// outreg2 using `filename' , replace `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 1-10")
//
// xi: xtreg globalCtr_share `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod<=10, re cluster(sessioncode)
// outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-10")
//
// xi: xtreg globalCtr_share `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod<=20, re cluster(sessioncode)
// outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-20")
//
xi: xtreg globalCtr_share `treatment_related' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod<=10 & playerjoin_club==1, re cluster(sessioncode)
outreg2 using `filename' , replace `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 1-10 Joined")
xi: xtreg globalCtr_share `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod<=10 & playerjoin_club==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-10 Joined")
xi: xtreg globalCtr_share `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod<=20 & playerjoin_club==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-20 Joined")
xi: xtreg global_over_total `treatment_related' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod<=10, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 1-10 Joined (Global Fraction)")
xi: xtreg global_over_total `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod<=10, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-10 Joined (Global Fraction)")
xi: xtreg global_over_total `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod<=20, re cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Overall R-squared, `e(r2_o)') ctitle("Round 2-20 Joined (Global Fraction)")
;;;
************ Probit regression results*************************************
local settings "onecol nonotes label dec(3) pdec(3) "
local independentVar2 highFC hetero hetero_highCost
*IF by costs:
local endowment_diff hetero_high hetero_low
local game_contr super_game_o5 round_o10 L_First
local indiv_char age_under20 male major_SorE social_x social_y
// type*
local myC round1_join local_contr_o100
local othersC local_o
local club_infor dummy_payoff global_o share_club_joinH clubSize
local club_infor2 dummy_payoff global_o share_club_joinH club_LocalMembersNotMe club_OtherCommunityMembers
local filename "$outputfolder\05-RegressionAll-v4-Probit-Join-Main.xls"
* Probit regression
xi: prob playerjoin_club `independentVar2' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod<=10 , cluster(sessioncode)
outreg2 using `filename' , replace `settings' addstat(Pseudo R-squared, `e(r2_p)')
xi: prob join_nextRound `independentVar2' `game_contr' `myC' `othersC' `club_infor2' `indiv_char' if WithGlobal==1 & subsessionperiod<10, cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Pseudo R-squared, `e(r2_p)')
xi: prob join_nextRound `independentVar2' `game_contr' `myC' `othersC' `club_infor2' `indiv_char' if WithGlobal==1 & subsessionperiod<20, cluster(sessioncode)
outreg2 using `filename' , append `settings' addstat(Pseudo R-squared, `e(r2_p)')
************ end of Probit regression results*************************************
*************************** Global: Join % *****************************************
*************************** Global: Contribution % *****************************************
************** Independent variable: treatment variables
************** Purpose: establish a comparison of contribution pattern
*********** Use contribution share, it is not directly compariable because high FC makes the contribution share larger
local settings "onecol nonotes label dec(3) pdec(3) "
local treatment_related highFC hetero hetero_highCost
local game_contr super_game round_o10
local indiv_char age_under20 male major_SorE social_x social_y
// type*
* Stage 2 contribution share depends on stage 1 choice
local factors club_LocalMembersNotMe club_OtherCommunityMembers
local contr_previous round1_join playercontribution_local_lastR join_lastGC_t_o local_o_lastR share_club_joinH `factors'
label var playercontribution_local_lastR "Own local contribution in round t-1"
label var join_lastGC_t_o "Other joined members' total global contribution in round t-1"
label var local_o_lastR "Local contribution from others in round t-1"
// local contr_previous round1_join tot_contr global_o local_o share_club_joinH `factors'
//clubJoinH clubSize
local filename "$outputfolder\05-RegressionAll-v3-Main-Treatment-Contr-Shares-LG.xls"
xi: xtreg globalCtr_share `treatment_related' if WithGlobal==1 & subsessionperiod==1 , re cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle("Contribution in round 1")
xi: xtreg globalCtr_share `treatment_related' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod==1 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Contribution in round 1")
xi: xtreg globalCtr_share `treatment_related' if WithGlobal==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Contribution in round t+1")
xi: xtreg globalCtr_share `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Contribution in round t+1")
preserve
keep if subsessionperiod<=10
local filename "$outputfolder\05-RegressionAll-v3-Main-Treatment-Contr-Shares-LG-R(first10).xls"
xi: xtreg globalCtr_share `treatment_related' if WithGlobal==1 & subsessionperiod==1 , re cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle("Contribution in round 1")
xi: xtreg globalCtr_share `treatment_related' `game_contr' `indiv_char' if WithGlobal==1 & subsessionperiod==1 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Contribution in round 1")
xi: xtreg globalCtr_share `treatment_related' if WithGlobal==1 & subsessionperiod>1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Contribution in round t+1")
xi: xtreg globalCtr_share `treatment_related' `game_contr' `contr_previous' `indiv_char' if WithGlobal==1 & subsessionperiod>1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("Contribution in round t+1")
restore
***************************end of Global: Contribution % *****************************************
**************end of individual analysis***************************
*********** DID add L-first
***************************Both : DID *****************************************
local indep WithGlobal hetero hetero_with //interaction_term
// local indep2 WithGlobal_join hetero_with_join
// local indep WithGlobal hetero hetero_high hetero_with hetero_high_with
local game_contr2 i.super_game*i.subsessionperiod L_First
// local contr_previous tot_contr global_o local_o clubSize share_club_joinH
local game_contr super_game round_d80 L_First
local indiv_char age_under20 male major_SorE social_x social_y
// type*
* Regression for global contribution
* Separate all, high, low entry cost
local filename "$outputfolder\05-RegressionAll-v4-RandomEF-DID.xls"
local settings "onecol nonotes label dec(2) pdec(3) "
* Random effect regression
// start with all
local contr `game_contr' `indiv_char'
// lowFC
xi: xtreg tot_contr `indep' `contr' if lowFC==1, re cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle(" tot_contr Low cost")
xi: xtreg share_contr `indep' `contr' if lowFC==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("share_contr Low cost")
xi: xtreg playerpayoff `indep' `contr' if lowFC==1 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Low cost")
// highFC
xi: xtreg tot_contr `indep' `contr' if lowFC==0, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("tot_contr High cost")
xi: xtreg share_contr `indep' `contr' if lowFC==0, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("share_contr High cost")
xi: xtreg playerpayoff `indep' `contr' if lowFC==0, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff High cost")
preserve
keep if subsessionperiod<=10
local indep WithGlobal hetero hetero_with //interaction_term
// hetero
local game_contr2 i.super_game*i.round_d80
local game_contr super_game round_d80 L_First
local indiv_char age_under20 male major_SorE social_x social_y
* Regression for global contribution
* Separate all, high, low entry cost
local filename "$outputfolder\05-RegressionAll-v4-RandomEF-DID-R(first10).xls"
local settings "onecol nonotes label dec(2) pdec(3) "
* Random effect regression
// start with all
local contr `game_contr' `indiv_char'
// lowFC
xi: xtreg tot_contr `indep' `contr' if lowFC==1, re cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle(" tot_contr Low cost")
xi: xtreg share_contr `indep' `contr' if lowFC==1, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("share_contr Low cost")
xi: xtreg playerpayoff `indep' `contr' if lowFC==1 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Low cost")
// highFC
xi: xtreg tot_contr `indep' `contr' if lowFC==0, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("tot_contr High cost")
xi: xtreg share_contr `indep' `contr' if lowFC==0, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("share_contr High cost")
xi: xtreg playerpayoff `indep' `contr' if lowFC==0, re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff High cost")
restore
**************Linear for DID************
{
preserve
keep if subsessionperiod<=10
local indep WithGlobal hetero hetero_with //interaction_term
local game_contr2 i.super_game*i.subsessionperiod
local game_contr super_game round_d80 L_First
// i.playerlocal_community
// local game_contr super_game round_d80
local indiv_char age_under20 male major_SorE social_x social_y
* Regression for global contribution
* Separate all, high, low entry cost
local filename "$outputfolder\05-RegressionAll-v3-Linear-DID-R(first10).xls"
local settings "onecol nonotes label dec(2) pdec(3) "
local contr `game_contr' `indiv_char'
// lowFC
xi: reg tot_contr `indep' `contr' if lowFC==1, cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle(" tot_contr Low cost")
xi: reg share_contr `indep' `contr' if lowFC==1, cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("share_contr Low cost")
xi: reg playerpayoff `indep' `contr' if lowFC==1 , cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Low cost")
// highFC
xi: reg tot_contr `indep' `contr' if lowFC==0, cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("tot_contr High cost")
xi: reg share_contr `indep' `contr' if lowFC==0, cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("share_contr High cost")
xi: reg playerpayoff `indep' `contr' if lowFC==0, cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff High cost")
restore
}
**************end of Linear for DID
***************************************
*********Hausman test to justify the use of RE model*************
******************* ********************
* Only appropriate for within-subject test
preserve
keep if subsessionperiod<=10
local indep WithGlobal hetero_with //interaction_term
// hetero hetero_with
local game_contr2 i.super_game*i.subsessionperiod
// local game_contr super_game round_o10
local game_contr super_game round_d80 //what used in v1
local indiv_char age_under20 male major_SorE social_x social_y
* Regression for global contribution
* Separate all, high, low entry cost
* endowment_adj
* Random effect regression
// start with all
local contr `game_contr'
* For shares
xi: xtreg share_totalContr `indep' `contr' if lowFC==1, fe cluster(sessioncode)
estimates store fixed
xi: xtreg share_totalContr `indep' `contr' if lowFC==1, re cluster(sessioncode)
hausman fixed ., force sigmamore
xi: xtreg share_totalContr `indep' `contr' if lowFC==0, fe cluster(sessioncode)
estimates store fixed
xi: xtreg share_totalContr `indep' `contr' if lowFC==0, re cluster(sessioncode)
hausman fixed ., force sigmamore
//
// xi: xtreg tot_contr `indep' `contr' endowment_adj if lowFC==1, fe
// estimates store fixed
// xi: xtreg tot_contr `indep' `contr' endowment_adj if lowFC==1, re
// hausman fixed ., force sigmamore
// xi: xtreg tot_contr `indep' `contr' if lowFC==0, fe cluster(sessioncode)
// estimates store fixed
// xi: xtreg tot_contr `indep' `contr' if lowFC==0, re cluster(sessioncode)
// hausman fixed ., force sigmamore
//
//
xi: xtreg playerpayoff `indep' `contr' if lowFC==1, fe
estimates store fixed
xi: xtreg playerpayoff `indep' `contr' if lowFC==1, re
hausman fixed ., force sigmamore
xi: xtreg playerpayoff `indep' `contr' if lowFC==0, fe cluster(sessioncode)
estimates store fixed
xi: xtreg playerpayoff `indep' `contr' if lowFC==0, re cluster(sessioncode)
hausman fixed ., force sigmamore
//
//
***************************************
* Regression for payoffs, use vs not join
* Separate all, high, low entry cost
*****************************************************8
preserve
keep if subsessionperiod<=10
local filename "$outputfolder\05-RegressionAll-v3-RandomEF-DID-payoff(first10).xls"
// local filename "$outputfolder\05-RegressionAll-v3-RandomEF-DID-payoff.xls"
local settings "onecol nonotes label dec(2) pdec(3) "
* Random effect regression
// start with all
local indep WithGlobal With_High_Cost //interaction_term: High_cost lowFC WithGlobal_join With_High_Cost_Join
local indep2 With_High_Cost_Join // WithGlobal_join
local game_contr super_game round_d80 L_First //what used in v1
local indiv_char age_under20 male major_SorE social_x social_y
local contr `game_contr' `indiv_char'
xi: xtreg playerpayoff `indep' `contr' if endowment==30 , re cluster(sessioncode)
outreg2 using `filename' , replace `settings' ctitle("payoff Hetero (H)")
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==30 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Hetero (H)")
xi: xtreg playerpayoff `indep' `contr' if endowment==10 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Hetero (L)")
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==10 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Hetero (L)")
// HOMO
xi: xtreg playerpayoff `indep' `contr' if endowment==20 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Homo")
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==20 , re cluster(sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Homo | Join")
;
*******Linear
preserve
keep if subsessionperiod<=10
local filename "$outputfolder\05-RegressionAll-v3-Linear-DID-payoff(first10).xls"
// local filename "$outputfolder\05-RegressionAll-v3-RandomEF-DID-payoff.xls"
local settings "onecol nonotes label dec(2) pdec(3) "
* Random effect regression
// start with all
local indep WithGlobal With_High_Cost //interaction_term: High_cost lowFC WithGlobal_join With_High_Cost_Join
local indep2 With_High_Cost_Join // WithGlobal_join
local game_contr super_game round_d80 //what used in v1
local indiv_char age_under20 male major_SorE social_x social_y
local contr `game_contr' `indiv_char'
xi: reg playerpayoff `indep' `contr' if endowment==30 , vce(cluster sessioncode)
outreg2 using `filename' , replace `settings' ctitle("payoff Hetero (H)")
xi: reg playerpayoff `indep' `indep2' `contr' if endowment==30 , vce(cluster sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Hetero (H)")
xi: reg playerpayoff `indep' `contr' if endowment==10 , vce(cluster sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Hetero (L)")
xi: reg playerpayoff `indep' `indep2' `contr' if endowment==10 , vce(cluster sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Hetero (L)")
// HOMO
xi: reg playerpayoff `indep' `contr' if endowment==20 , vce(cluster sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Homo")
xi: reg playerpayoff `indep' `indep2' `contr' if endowment==20 , vce(cluster sessioncode)
outreg2 using `filename' , append `settings' ctitle("payoff Homo | Join")
**********Linear
***************************************
*********Hausman test to justify the use of RE model*************
******************* ********************
preserve
keep if subsessionperiod<=10
// local filename "$outputfolder\05-RegressionAll-v3-RandomEF-DID-payoff.xls"
local settings "onecol nonotes label dec(2) pdec(3) "
* Random effect regression
// start with all
local indep WithGlobal With_High_Cost //interaction_term: High_cost lowFC WithGlobal_join With_High_Cost_Join
local indep2 With_High_Cost_Join // WithGlobal_join
local game_contr super_game round_d80 //what used in v1
// local game_contr super_game subsessionperiod
local indiv_char age_under20 male major_SorE social_x social_y
local contr `game_contr'
// xi: xtreg playerpayoff `indep' `contr' if endowment==30 , fe cluster(sessioncode)
// estimates store fixed
// xi: xtreg playerpayoff `indep' `contr' if endowment==30 , re cluster(sessioncode)
// hausman fixed ., force sigmamore
//
// xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==30 , fe cluster(sessioncode)
// estimates store fixed
// xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==30 , re cluster(sessioncode)
// hausman fixed ., force sigmamore
xi: xtreg playerpayoff `indep' `contr' if endowment==10 , fe cluster(sessioncode)
estimates store fixed
xi: xtreg playerpayoff `indep' `contr' if endowment==10 , re cluster(sessioncode)
hausman fixed ., force sigmamore
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==10 , fe cluster(sessioncode)
estimates store fixed
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==10 , re cluster(sessioncode)
hausman fixed ., force sigmamore
// HOMO
xi: xtreg playerpayoff `indep' `contr' if endowment==20 , fe cluster(sessioncode)
estimates store fixed
xi: xtreg playerpayoff `indep' `contr' if endowment==20 , re cluster(sessioncode)
hausman fixed ., force sigmamore
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==20 , fe cluster(sessioncode)
estimates store fixed
xi: xtreg playerpayoff `indep' `indep2' `contr' if endowment==20 , re cluster(sessioncode)
hausman fixed ., force sigmamore
;
***************************************
***************************************
*********Hausman test to justify the use of RE model*************
******************* ********************
* Only appropriate for within-subject test
preserve
keep if subsessionperiod<=10
local indep WithGlobal
// hetero_with //interaction_term
// hetero hetero_with
local game_contr2 i.super_game*i.subsessionperiod
local game_contr super_game subsessionperiod
// local game_contr super_game round_d80 //what used in v1
local indiv_char age_under20 male major_SorE social_x social_y
* Regression for global contribution
* Separate all, high, low entry cost
* endowment_adj
* Random effect regression
// start with all
// local contr `game_contr'
// xi: xtreg playerpayoff `indep' `contr' if lowFC==1 & treatment=="HOMO", fe cluster(sessioncode)
// estimates store fixed
// xi: xtreg playerpayoff `indep' `contr' if lowFC==1 & treatment=="HOMO", re cluster(sessioncode)
// hausman fixed ., force sigmamore
// local contr `game_contr'
// xi: xtreg playerpayoff `indep' `contr' if lowFC==0 & treatment=="HOMO", fe cluster(sessioncode)
// estimates store fixed
// xi: xtreg playerpayoff `indep' `contr' if lowFC==0 & treatment=="HOMO", re cluster(sessioncode)
// hausman fixed ., force sigmamore
// local contr `game_contr'
// xi: xtreg playerpayoff `indep' `contr' if lowFC==1 & treatment=="HETERO", fe cluster(sessioncode)
// estimates store fixed
// xi: xtreg playerpayoff `indep' `contr' if lowFC==1 & treatment=="HETERO", re cluster(sessioncode)
// hausman fixed ., force sigmamore
local contr `game_contr'
xi: xtreg playerpayoff `indep' `contr' if lowFC==0 & treatment=="HETERO", fe cluster(sessioncode)
estimates store fixed
xi: xtreg playerpayoff `indep' `contr' if lowFC==0 & treatment=="HETERO", re cluster(sessioncode)
hausman fixed ., force sigmamore
*****Side task: collapse by individuals, contribution shares in L and LG; sort by their L contribution, compare difference
collapse share_contr, by(participantcode WithGlobal treatment fc)
reshape wide share_contr, i(participantcode ) j(WithGlobal)
gen dff = share_contr1 - share_contr0
scatter dff share_contr0
scatter dff share_contr0 if treatment=="HOMO"
scatter dff share_contr0 if treatment=="HETERO"