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
Omitted variables bias in GMMis it possible to have omitted variables bias in system GMM? When I don't include a regressor in my …
Issue combining foreach and runbyHi everyone, I recently came across with the -runby- command which I find extremely helpful. I hav…
Stata for FE/RE modelsDear All, Consider the following standard estimation of FE (fixed-effect) and RE (random-effect) mod…
Fixed effect model with a lagged covariate and an unbalanced panel datasetHi, I plan on using the xtewreg package so I have to use demeaned data. My actual data is an unbala…
Issues merging with duplicate observationsHi, I am using a Medicare dataset to identify patients who underwent a procedure. One patient could…
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