Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to postfile glm output in IRR (relative risk)

    Dear all,

    I'd like to display glm model outputs using the postfile commend in stata (then transfer to tables in excel). Previously I have used the codes to display standard coef, 95%CI and p values from regression models. How do I modify the codes to get the results displaying as IRR instead of standard coef.?

    glm chapmsss latitude sex age, fam(poi) link(log) nolog robust eform
    matrix b = e(b)
    matrix V= e(V)
    local beta: display %3.1f b[1,1]
    local l95: display %3.1f b[1,1] - invnormal(0.975)*sqrt(V[1,(1)])
    local u95: display %3.1f b[1,1] + invnormal(0.975)*sqrt(V[1,1])

    /* A little code to display the p value as <0.001 if appropriate: NOTE: This can be expanded to the format you desire, for example if you want *s for significance*/
    local pval = 2*normprob(-abs(b[1,1]/sqrt(V[1,1])))
    if `pval' <= 0.001 {
    local pval = "p<0.001"

    }
    else if `pval' <= 0.10 {
    local pval: display %4.3f 2*normprob(-abs(b[1,1]/sqrt(V[1,1])))
    local pval = "p=`pval'"

    }
    else if `pval' <= 1 {
    local pval: display %4.3f 2*normprob(-abs(b[1,2]/sqrt(V[1,1])))
    local pval = "p=`pval'"

    }

    post temp ("`var'") ("`beta' [`l95', `u95']") ("`pval'")


    }


    Click image for larger version

Name:	Table_glm.PNG
Views:	1
Size:	53.3 KB
ID:	1557024


    Any help is appreciated!

    Maggie

  • #2
    As you notice, using the -eform- option in the regression command changes the displayed coefficients but not the stored results in e(b). Two suggestions:

    1) I would avoid using abbreviations without explaining what they are. -irr- refers to incidence-rate ratios, which are just exponentiated poisson coefficients.
    2) I would switch to esttab from Stata Journal/ SSC and use the -eform- option.

    Code:
    eststo: glm chapmsss latitude sex age, fam(poi) link(log) nolog robust
    esttab . using myfile.csv, eform

    Comment


    • #3
      Sorry for digging out this old thread but I encountered the same issue and found an alternative solution. I also used -glm- with poisson-log-eform options which generated IRR estimations. Instead of -postfile-, I used -putexcel- to post the results to excel files, and the scalar name for IRR estimations are simply _r_b in -putexcel- commands.

      Comment

      Working...
      X