Hi,
I am encountering an error message when trying to save the the results of a sensitivity analysis to a text file with the "estout" command.
My primary analysis uses conditional logistic regression on multiply imputed data (m=20). I am now trying to run a sensitivity analysis wherein I alter exposure classification (exposed -->unexposed) among my cases (gsw) by 5%, 10%, etc to demonstrate the impact exposure missclassification might have on my results. I am randomly selecting 5% (up to 40% by increments of 5%) of cases and altering exposure status, and then recalculating my main OR of interest. I would like to run this using a loop with 100 iterations at each missclassification level (5-40%). Ideally, I would then summarize the results across the 100 random iterations and ultimately generate a summary table of the sensitivity analysis results by % missclassification.
With the code below, I am able to reclassify the exposure status of a random sample of cases (here 5%). I am then able to run my conditional logistic model and have the results show up in the STATA output screen. However, when I run the estout command, I get the following error message:
"coefficient gsw_connect2 not found
r(111);"
It seems that STATA is not storing the model estimates in a format that is compatible with the estout command.
I tried to manually save the model estimates, and then run the estout command but it still doesn’t work.
But if I type
estimates store gsw1
estimates replay gsw1
Then STATA will pull the model back up
However, the estout command still says the gsw_connect2 variable is empty.
I get the same error message if I try to keep a different variable estimate (one of my model covariates, such as alc)
I am able to run the estout command if I remove " keep(gsw_connect2)"
estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt", append cells("b se t p ci_l ci_u") eform
However, this just creates a text file with the headers "b se t p ci_l ci_u" that is otherwise empty
Any advice on how to capture the model estimates from each of these runs of my sensitivity analysis is greatly appreciated. Copying and pasting results from 800 models is definitely not an option. Is there a command other than estout that I should use? Is there a better way to save all of the model estimates across the 5-40% missclassification estimates x100 runs, that will work in a loop format?
Thanks so much!
~Alison
gsort -connect2 -gsw age3
gen random1=uniform() if gsw==1 & connect2==1
gsort random1 -connect2 -gsw age3
gen n= _n if gsw==1 & connect2==1
gen usingset=1 if _n ~=. & gsw==1 & connect2==1
bysort usingset: egen bign= max(n) if gsw==1 & connect2==1
gen keeper= n / bign
gen gsw_connect2=connect2
recode gsw_connect2 1=0 if keeper <= 0.05
tab connect2 if gsw==1
tab gsw_connect2 if gsw==1
mi estimate, or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if viol_invlv_score2==0, group(age3)
estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt", keep(gsw_connect2) append cells("b se t p ci_l ci_u") eform
I am encountering an error message when trying to save the the results of a sensitivity analysis to a text file with the "estout" command.
My primary analysis uses conditional logistic regression on multiply imputed data (m=20). I am now trying to run a sensitivity analysis wherein I alter exposure classification (exposed -->unexposed) among my cases (gsw) by 5%, 10%, etc to demonstrate the impact exposure missclassification might have on my results. I am randomly selecting 5% (up to 40% by increments of 5%) of cases and altering exposure status, and then recalculating my main OR of interest. I would like to run this using a loop with 100 iterations at each missclassification level (5-40%). Ideally, I would then summarize the results across the 100 random iterations and ultimately generate a summary table of the sensitivity analysis results by % missclassification.
With the code below, I am able to reclassify the exposure status of a random sample of cases (here 5%). I am then able to run my conditional logistic model and have the results show up in the STATA output screen. However, when I run the estout command, I get the following error message:
"coefficient gsw_connect2 not found
r(111);"
It seems that STATA is not storing the model estimates in a format that is compatible with the estout command.
I tried to manually save the model estimates, and then run the estout command but it still doesn’t work.
But if I type
estimates store gsw1
estimates replay gsw1
Then STATA will pull the model back up
However, the estout command still says the gsw_connect2 variable is empty.
I get the same error message if I try to keep a different variable estimate (one of my model covariates, such as alc)
I am able to run the estout command if I remove " keep(gsw_connect2)"
estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt", append cells("b se t p ci_l ci_u") eform
However, this just creates a text file with the headers "b se t p ci_l ci_u" that is otherwise empty
Any advice on how to capture the model estimates from each of these runs of my sensitivity analysis is greatly appreciated. Copying and pasting results from 800 models is definitely not an option. Is there a command other than estout that I should use? Is there a better way to save all of the model estimates across the 5-40% missclassification estimates x100 runs, that will work in a loop format?
Thanks so much!
~Alison
gsort -connect2 -gsw age3
gen random1=uniform() if gsw==1 & connect2==1
gsort random1 -connect2 -gsw age3
gen n= _n if gsw==1 & connect2==1
gen usingset=1 if _n ~=. & gsw==1 & connect2==1
bysort usingset: egen bign= max(n) if gsw==1 & connect2==1
gen keeper= n / bign
gen gsw_connect2=connect2
recode gsw_connect2 1=0 if keeper <= 0.05
tab connect2 if gsw==1
tab gsw_connect2 if gsw==1
mi estimate, or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if viol_invlv_score2==0, group(age3)
estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt", keep(gsw_connect2) append cells("b se t p ci_l ci_u") eform
Comment