Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: RE: Re: Dunnett's P-value and negative binomial regression


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: RE: Re: Dunnett's P-value and negative binomial regression
Date   Tue, 21 Jan 2014 21:36:54 +0900

Garry Anderson wrote:

By the way, I manually set k to 4 rather than e(df_m) because I had some
covariates, as well as the 5 treatment levels.

--------------------------------------------------------------------------------

If you're doing a lot of these, then you could probably automate it a bit.  
Something like that below, which you'd run immediately after your -nbreg- 
estimation command.  It assumes by default that your control group is 1.varname
after using factor variables in -nbreg-, which I think is usually the case.  
It's pretty rudimentary, but you could get elaborate and have the command query
the ereturn macros left behind by the estimation command and set the inverse
link, make it rclass and have it dump everything into return a matrix and so on.


Joseph Coveney

program define eformdunnettci
    version 13.1
    syntax varname(numeric), [control(integer 1) level(integer `c(level)')]

    quietly levelsof `varlist' if e(sample), local(levels)
    local levels : list levels - control
    local comparison_tally : list sizeof levels

    tempname Dunnett
    scalar define `Dunnett' = invdunnettprob(`comparison_tally', ///
        1e6, `level' / 100)

    local varname : variable label `varlist'
    if "`varname'" == "" local varname `varlist'

    tempname HalfCI
    foreach i of local levels {
        display in smcl as text _newline(1) ///
          "`varname' `i' versus `varname' `control'"
        quietly lincom `i'.`varlist'
        scalar define `HalfCI' = r(se) * `Dunnett'
        display in smcl as text "Estimate = " exp(r(estimate))
        display in smcl as text "Asymp. `level'% LCL = " ///
          as result exp(r(estimate) - `HalfCI')
        display in smcl as text "Asymp. `level'% UCL = " ///
          as result exp(r(estimate) + `HalfCI')
    }

end

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index