I am trying to use bootstrapping to get a 95% CI for Cohen's d, but the command produces coef. only. No bootstrapping SE, z, p-value, and 95% CI. And I don't get any error messages!
This is very strange because the same codes actually worked without any problem a few weeks ago. I had to revisit the analysis recently so just ran what I wrote before to review, but now, the codes are not working.
FYI, the codes below are a part of what I wrote. And the data is not real data. I used frame since I actually need to handle multiple data sets for this. But it produces the same issue.
Please advise!
Code:
frame reset
frame create sample3
frame sample3 {
* Example generated by -dataex-. For more info, type help dataex
clear
input byte id double(group outcome_t0 outcome_t1 outcome_t2)
44 2 84.860979 114.87961250000001 41.4992725
45 1 49.8758465 55.0360915 50.1319545
46 1 80.74328550000001 77.3736495 81.3353915
48 1 42.024735500000006 54.970216 57.763051000000004
49 2 52.415797 56.568540999999996 50.503508499999995
50 2 48.055269 48.4297725 46.5440855
58 2 39.3368345 37.401369 37.568878
60 2 50.3642245 45.998895000000005 46.2884515
61 2 71.5496255 71.77641600000001 70.61160749999999
62 2 49.8083935 44.5434755 47.758653499999994
63 1 57.545792000000006 65.44662199999999 66.445455
64 2 40.995180000000005 46.6467495 44.6673595
65 2 52.914714000000004 46.365172 50.470093
66 2 60.423458499999995 . .
71 2 50.232740500000006 46.5209385 43.5583465
end
label values group group_l
label def group_l 1 "S", modify
label def group_l 2 "C", modify
}
capture program drop boot_test
program boot_test, rclass
version 17
frame sample3 {
* getting mean and variance of the outcome at each time point for each group
sum `1'_t0 if group==1
local n_grp1_t0=r(N)
local dep_grp1_t0=r(mean)
local sd_grp1_t0=r(sd)
local var_grp1_t0=r(Var)
sum `1'_t1 if group==1
local n_grp1_t1=r(N)
local dep_grp1_t1=r(mean)
local sd_grp1_t1=r(sd)
local var_grp1_t1=r(Var)
* difference between two time points
local dif_grp1_t1t0=`dep_grp1_t1'-`dep_grp1_t0'
* pooled sd
local sd_pooled_grp1_t1t0=sqrt((`var_grp1_t1'+`var_grp1_t0')/2)
* Cohen's d
return scalar cohend_grp1_t1t0=`dif_grp1_t1t0'/`sd_pooled_grp1_t1t0'
}
end
bootstrap r(cohend_grp1_t1t0), reps(1010) seed(11271980): boot_test outcome
0 Response to Bootstrapping produces coef only
Post a Comment