Hello Statalisters, I'm trying to collect results from a logistic regression, but also classification statistics and an AUC for some 20 variables and want to place them all in a table.
I have code that I developed that sort of works but I know it's not quite right and I am unsuccessful placing it all in a loop to pass over every variable. I have some categorical and continuous variables too.
code is below:
Is there a way to place all that in a loop to make 1 big table of these specific results?
Thank you kindly.
I have code that I developed that sort of works but I know it's not quite right and I am unsuccessful placing it all in a loop to pass over every variable. I have some categorical and continuous variables too.
code is below:
Code:
collect clear
collect or=_r_b lower=_r_lb upper=_r_ub,:logistic concussed c.severity if _mi_m==0
lsens, genprob(cutoff) gensens(sens) genspec(spec) replace
generate float youden = (sens + spec) - 1
egen float max_youden = max(youden)
sum cutoff if youden == max_youden
scalar cutoffs = r(mean)
collect sens = r(P_1n) spec=r(P_0p) correct=r(P_corr),:estat classification,cutoff(`=cutoffs')
collect auc = r(area):lroc
collect dims
collect levelsof result
collect label list result, all
collect levelsof labels
collect levelsof cmdset
collect levelsof colname
collect levelsof result_type
collect style cell result, nformat(%7.4f)
collect style showbase off
collect style column, extraspace(1)
collect style header result, level(label)
collect layout () (colname[severity]#result[or lower upper] result[sens spec correct auc])
collect preview
drop spec sens cutoff youden max_youden
. collect preview
--------------------------------------------------------------------
severity severity severity sens spec correct auc
or lower upper
--------------------------------------------------------------------
1.0812 1.0738 1.0886 3.9335 77.1323 79.2265 0.7841
--------------------------------------------------------------------
Thank you kindly.

Comment