******** ML Estimation programs *** just copy into execution window and press enter *********** *** total model. program define ML_choice_time_conf version 1.0 args lnf p mu0T sigmaT distT mu0C sigmaC distC quietly replace `lnf'=ln(binomial(total_pred, $ML_y1,`p')-binomial(total_pred, $ML_y1-1,`p')) if index==1 & miss == 0 quietly replace `lnf'=ln(binomial(total_pred, $ML_y1, 0.5)-binomial(total_pred, $ML_y1-1, 0.5)) if index==1 & miss == 1 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0T'+abs(`distT')* total_pred, `sigmaT' )) if index==2 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0C'+abs(`distC')* total_pred, `sigmaC' )) if index==3 end ** Flat time prediction program define ML_choice_time_conf_flat_time version 1.0 args lnf p mu0T sigmaT mu0C sigmaC distC quietly replace `lnf'=ln(binomial(total_pred, $ML_y1,`p')-binomial(total_pred, $ML_y1-1,`p')) if index==1 & miss == 0 quietly replace `lnf'=ln(binomial(total_pred, $ML_y1, 0.5)-binomial(total_pred, $ML_y1-1, 0.5)) if index==1 & miss == 1 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0T', `sigmaT' )) if index==2 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0C'+abs(`distC')* total_pred, `sigmaC' )) if index==3 end ** Flat Confidence Prediction program define ML_choice_time_conf_flat_conf version 1.0 args lnf p mu0T sigmaT distT mu0C sigmaC quietly replace `lnf'=ln(binomial(total_pred, $ML_y1,`p')-binomial(total_pred, $ML_y1-1,`p')) if index==1 & miss == 0 quietly replace `lnf'=ln(binomial(total_pred, $ML_y1, 0.5)-binomial(total_pred, $ML_y1-1, 0.5)) if index==1 & miss == 1 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0T'+abs(`distT')* total_pred, `sigmaT' )) if index==2 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0C', `sigmaC' )) if index==3 end ** Flat time and confidence prediction program define ML_choice_time_conf_flat_both version 1.0 args lnf p mu0T sigmaT mu0C sigmaC quietly replace `lnf'=ln(binomial(total_pred, $ML_y1,`p')-binomial(total_pred, $ML_y1-1,`p')) if index==1 & miss == 0 quietly replace `lnf'=ln(binomial(total_pred, $ML_y1, 0.5)-binomial(total_pred, $ML_y1-1, 0.5)) if index==1 & miss == 1 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0T', `sigmaT' )) if index==2 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0C', `sigmaC' )) if index==3 end ** Random Choice Model program define ML_choice_time_conf_random version 1.0 args lnf mu0T sigmaT mu0C sigmaC quietly replace `lnf'=ln(binomial(total_pred, $ML_y1, 0.5)-binomial(total_pred, $ML_y1-1, 0.5)) if index==1 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0T', `sigmaT' )) if index==2 quietly replace `lnf'=ln(normalden( $ML_y1, `mu0C', `sigmaC' )) if index==3 end ****** single estimations **choices only program define ML_choice version 1.0 args lnf p quietly replace `lnf'=ln(binomial(total_pred, $ML_y1,`p')-binomial(total_pred, $ML_y1-1,`p')) if index==1 & miss == 0 quietly replace `lnf'=ln(binomial(total_pred, $ML_y1, 0.5)-binomial(total_pred, $ML_y1-1, 0.5)) if index==1 & miss == 1 end **time only program define ML_time version 1.0 args lnf mu0T sigmaT distT quietly replace `lnf'=ln(normalden( $ML_y1, `mu0T'+`distT'* total_pred, `sigmaT' )) if index==2 end **confidence only program define ML_conf version 1.0 args lnf mu0C sigmaC distC quietly replace `lnf'=ln(normalden( $ML_y1, `mu0C'+`distC'* total_pred, `sigmaC' )) if index==3 end *********End Definition Stop *** Total estimation program for all Participants and all strategies producing a participant x strategy matrix with BIC scores matrix strat_vec = [0,1,1,0,4] *** determines which model is used per strategy: 0-full model, 1-flat decision time prediction, 2-flat confidence prediction, 3-flat both, 4-random choice model matrix N_obs_cat = [18,18,18,18,18] *** replace by number or observations matrix result = J(10,5,0) ***** replace after the two "/" by total number of participants and strategies forvalues u= 1/10 { forvalues v = 1/5 { disp "*******************************************" disp "**** Subject: "`u' " **** Strategy: "`v' if strat_vec[1,`v'] ==0 { ml model lf ML_choice_time_conf (epsilon: dv=) (mu_Time:) (sigma_Time:) (R_Time:) (mu_Conf:) (sigma_Conf:) (R_Conf:) if Participant ==`u'& strat == `v' ml init 0.5 0 2500 1000 37 45 30, copy ml maximize matrix coef = e(b) if coef[1,1] < .50 { scalar BIC = -2* e(ll)+ln(N_obs_cat[1, `v'])*7 matrix result[`u', `v'] = BIC disp "Subj: " `u' " Strat: " `v' " - BIC:" BIC } if coef[1,1] >= .50 { disp "BIC: not calculated because error bigger than .50" disp "Subj: " `u' " Strat: " `v' " - BIC: not calculated because epsilon bigger or equal than .50" } } if strat_vec[1,`v'] ==1 { ml model lf ML_choice_time_conf_flat_time (epsilon: dv=) (mu_Time:) (sigma_Time:) (mu_Conf:) (sigma_Conf:) (R_Conf:) if Participant ==`u'& strat == `v' ml init 0.5 0 2500 37 45 30, copy ml maximize matrix coef = e(b) if coef[1,1] < .50 { scalar BIC = -2* e(ll)+ln(N_obs_cat[1, `v'])*6 matrix result[`u', `v'] = BIC disp "Subj: " `u' " Strat: " `v' " - BIC:" BIC } if coef[1,1] >= .50 { disp "BIC: not calculated because error bigger than .50" disp "Subj: " `u' " Strat: " `v' " - BIC: not calculated because epsilon bigger or equal than .50" } } if strat_vec[1,`v'] ==2 { ml model lf ML_choice_time_conf_flat_conf (epsilon: dv=) (mu_Time:) (sigma_Time:) (R_Time:) (mu_Conf:) (sigma_Conf:) if Participant ==`u'& strat == `v' ml init 0.5 0 2500 1000 37 45, copy ml maximize matrix coef = e(b) if coef[1,1] < .50 { scalar BIC = -2* e(ll)+ln(N_obs_cat[1, `v'])*6 matrix result[`u', `v'] = BIC disp "Subj: " `u' " Strat: " `v' " - BIC:" BIC } if coef[1,1] >= .50 { disp "BIC: not calculated because error bigger than .50" disp "Subj: " `u' " Strat: " `v' " - BIC: not calculated because epsilon bigger or equal than .50" } } if strat_vec[1,`v'] ==3 { ml model lf ML_choice_time_conf_flat_both (epsilon: dv=) (mu_Time:) (sigma_Time:) (mu_Conf:) (sigma_Conf:) if Participant ==`u'& strat == `v' ml init 0.5 0 2500 37 45 , copy ml maximize matrix coef = e(b) if coef[1,1] < .50 { scalar BIC = -2* e(ll)+ln(N_obs_cat[1, `v'])*5 matrix result[`u', `v'] = BIC disp "Subj: " `u' " Strat: " `v' " - BIC:" BIC } if coef[1,1] >= .50 { disp "BIC: not calculated because error bigger than .50" disp "Subj: " `u' " Strat: " `v' " - BIC: not calculated because epsilon bigger or equal than .50" } } if strat_vec[1,`v'] ==4 { ml model lf ML_choice_time_conf_random (mu_Time: dv=) (sigma_Time:) (mu_Conf:) (sigma_Conf:) if Participant ==`u'& strat == 4 ml init 0 2500 37 45, copy ml maximize matrix coef = e(b) scalar BIC = -2* e(ll)+ln(N_obs_cat[1, `v'])*4 matrix result[`u', `v'] = BIC disp "Subj: " `u' " Strat: " `v' " - BIC:" BIC } } } matrix list result