Dear Stata users,
I am having trouble with exporting odds ratios, confidence intervals and p-values from 230 different logistic regressions using filewrite. Exporting estimated beta coefficients, confidence intervals, and p-values works fine, but I would rather report the exponentiated betas (odds ratios) and associated confidence intervals as well as p-values.
The code that works but gives me beta coefficients instead of exponentiated beta coefficients (odds ratios) and confidence intervals instead of exponentiated confidence intervals is given below. The question is how do I change the code below to provide the exponentiated betas (odds ratios), confidence intervals, and p-values?
foreach bp of varlist disease2 {
cd "\\my documents\data"
file open table2 using "mytable1.txt", replace write
file write table2 _tab _tab "not adjusted" _tab _tab "Multiple adjusted" _n
file write table2 "Variable" _tab "Beta1" _tab "P-value1" _tab "Beta2" _tab "P-value2" _n
foreach lipid of varlist lipid1-lipid230 {
quietly: logistic `bp' `lipid'
file write table2 "`lipid'" _tab (round(_b[`lipid'],0.001)) " (" (round(_b[`lipid']- invnormal(0.975)*_se[`lipid'],0.001)) ", " (round(_b[`lipid']+ invnormal(0.975)*_se[`lipid'],0.001)) ")" _tab (round(2*normal(-abs(_b[`lipid']/_se[`lipid']))),0.0000000001) _tab
quietly: logistic `bp' `lipid' age sex weight
file write table2 (round(_b[`lipid'],0.001)) " (" (round(_b[`lipid']- invnormal(0.975)*_se[`lipid'],0.001)) ", " (round(_b[`lipid']+ invnormal(0.975)*_se[`lipid'],0.001)) ")" _tab (round(2*normal(-abs(_b[`lipid']/_se[`lipid']))),0.00000000001) _n
}
file close table2
}
/// Sam
Related Posts with Exporting odds ratios, confidence intervals, and p-values from multiple logistic regression models using filewrite
Combining two variables by variables namesMy variables are: country (Angola, Armenia, Azerbaizan....) and year (2004, 2006, 2009). Is it possi…
Extending gridlines in triplotHi, I am using triplot from SSC in STATA15. The triangular plot is ideal for my purposes, but diff…
Adjust space between plots in "twoway ...., by(group)"I created two scatterplots and plotted them side by side, using "twoway (scatter y x), by(binary_gro…
appropriately deleting dummy 1sHi, I got a bit of a puzzle problem for one specific application, but I feel an appropriate solutio…
setting up drug coverage days using forv loophi, I ve been trying to setup "drug dose " for each day of follow up for a pharmacoepi analysis usin…
Subscribe to:
Post Comments (Atom)
0 Response to Exporting odds ratios, confidence intervals, and p-values from multiple logistic regression models using filewrite
Post a Comment