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
Correct to take log of explanatory variable already in percentages?Is it correct to take logs of a variable, e.g. tax revenue, already measured in percentage form? e.…
Analyze an increase in minimu wages on stataHi all, I'm very new to Stata and I'm doing my own research for a class to write a paper. I'm trying…
If statement with stringDear everyone, I hope you are doing well. I exported a document from Excel into Stata. One of the c…
Comparing models in Latent Class analysisI have stored the estimates for a 2-class, 3-class, 4-class and 5-class model. Now I would like to c…
Simple question about counting in specific casesDear all, The past few days I am trying to accomplish something that (I think) is probably simple, …
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