Hi.
I need help in regards to interpreting the results of this do-file. I am new to Stata, and can't seem to find any good site to guide me through the commands of this particular do-file. Is there anyone out there who can be of help?
CODE:
clear
program drop _all
set seed 1000
set more off
program probSim, rclass
drop _all
set obs 24
gen x = _n/_N
gen Z = -2 + 4*x
gen successProb = 1/(1 + exp(-Z))
gen Y = rbinomial(1, successProb)
logit Y x
return scalar lower = _b[x]-1.96*_se[x]
return scalar upper = _b[x]+1.96*_se[x]
return scalar beta1hatRedraw = _b[x]
end
simulate beta1hatRedraw=r(beta1hatRedraw) lower = r(lower) upper = r(upper), reps(5000) : probSim
hist beta1hatRedraw
qnorm beta1hatRedraw
gen successCountAsymptotic = 1
replace successCountAsymptotic = 0 if (lower > 4) | (upper < 4)
sum successCountAsymptotic
gen beta1hatCentred = beta1hatRedraw - 4
pctile pct=beta1hatCentred, nq(1000) genp(percent)
disp "2.5%: " pct[25] ", 97.5%: " pct[975]
_pctile beta1hatCentred, p(2.5, 97.5)
disp "2.5%: " r(r1) ", 97.5%: " r(r2)
qui count if (upper < beta1hatRedraw +2.9344249) & (lower < beta1hatRedraw - 7.3806381)
disp r(N)/_N
qui count if (upper > beta1hatRedraw + 2.9344249) & (lower < beta1hatRedraw -7.3806381)
disp r(N)/_N
qui count if (upper < beta1hatRedraw + 2.9344249) & (lower > beta1hatRedraw -7.3806381)
disp r(N)/_N
qui count if (upper > beta1hatRedraw + 2.9344249) & (lower > beta1hatRedraw -7.3806381)
disp r(N)/_N
Any help would be greatly appreciated!
I need help in regards to interpreting the results of this do-file. I am new to Stata, and can't seem to find any good site to guide me through the commands of this particular do-file. Is there anyone out there who can be of help?
CODE:
clear
program drop _all
set seed 1000
set more off
program probSim, rclass
drop _all
set obs 24
gen x = _n/_N
gen Z = -2 + 4*x
gen successProb = 1/(1 + exp(-Z))
gen Y = rbinomial(1, successProb)
logit Y x
return scalar lower = _b[x]-1.96*_se[x]
return scalar upper = _b[x]+1.96*_se[x]
return scalar beta1hatRedraw = _b[x]
end
simulate beta1hatRedraw=r(beta1hatRedraw) lower = r(lower) upper = r(upper), reps(5000) : probSim
hist beta1hatRedraw
qnorm beta1hatRedraw
gen successCountAsymptotic = 1
replace successCountAsymptotic = 0 if (lower > 4) | (upper < 4)
sum successCountAsymptotic
gen beta1hatCentred = beta1hatRedraw - 4
pctile pct=beta1hatCentred, nq(1000) genp(percent)
disp "2.5%: " pct[25] ", 97.5%: " pct[975]
_pctile beta1hatCentred, p(2.5, 97.5)
disp "2.5%: " r(r1) ", 97.5%: " r(r2)
qui count if (upper < beta1hatRedraw +2.9344249) & (lower < beta1hatRedraw - 7.3806381)
disp r(N)/_N
qui count if (upper > beta1hatRedraw + 2.9344249) & (lower < beta1hatRedraw -7.3806381)
disp r(N)/_N
qui count if (upper < beta1hatRedraw + 2.9344249) & (lower > beta1hatRedraw -7.3806381)
disp r(N)/_N
qui count if (upper > beta1hatRedraw + 2.9344249) & (lower > beta1hatRedraw -7.3806381)
disp r(N)/_N
Any help would be greatly appreciated!