/* LabMPLswitch.do gets the number of switches */ * get the personal choice data use LabMPLRisk, clear tab Rtask tab choice * only look at mpl drop if mpl==0 * get the data sorted sort id Rtask RowProbA * list some data list id Rtask RowProbA RowProbB choice in 1/30, noobs sepby(Rtask) * count switches generate ns=0 bysort id Rtask: egen row=seq() bysort id Rtask: replace ns=1 if choice[_n] ~= choice[_n-1] & row~=1 bysort id Rtask: egen NS=sum(ns) list id Rtask row RowProbA RowProbB choice ns NS if NS>2, noobs sepby(id Rtask) list id Rtask row RowProbA RowProbB choice ns NS if NS==2, noobs sepby(id Rtask) * tabulate multiple switchers tab NS if row==1 * generate problematic switchers generate Bad=0 replace Bad=1 if NS>2 tab Bad if row==1