Announcement

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

  • help on obtaining 95% CIs after running itsa

    hello Statalisters,
    I am currently using the excellent Ariel Linden's itsa package to compute interrupted time series analyses, on my entire cohort and on several subgroups.

    I took advantage of the recent inclusion of GLM within itsa to apply the family function that best fit the series, choosing between gaussian, gamma and negative binomial. Since they will appear in the same table of the article, I always required results in eform, so that they could be comparable in terms of relative variation. And I am requiring all the coefficients that itsa can provide, including the posttrend coefficient.

    Now, a reviewer asked to provide also 95% confidence intervals of the estimated coefficients. I am having difficulties in calculating those around the coefficient of the post-intervention trend, because itsa provides the non-exponentiated coefficient for posttrend, even when the option eform is present.


    Code:
    . itsa ricpaz, single trperiod(49) posttrend replace family(nbinomial) link(log) lag(4) eform 
    
    
    
    Time variable: month, 1 to 96
            Delta: 1 unit
    note: _ricpaz has noninteger values
    
    Iteration 0:  Log likelihood = -463.75394  
    Iteration 1:  Log likelihood = -463.75136  
    Iteration 2:  Log likelihood = -463.75136  
    
    Generalized linear models                         Number of obs   =         96
    Optimization     : ML                             Residual df     =         92
                                                      Scale parameter =          1
    Deviance         =  .6191476732                   (1/df) Deviance =   .0067299
    Pearson          =   .646802594                   (1/df) Pearson  =   .0070305
    
    Variance function: V(u) = u+(1)u^2                [Neg. Binomial]
    Link function    : g(u) = ln(u)                   [Log]
    
    HAC kernel (lags): Newey–West (4)
                                                      AIC             =    9.74482
    Log likelihood   = -463.7513565                   BIC             =  -419.3009
    
    ------------------------------------------------------------------------------
                 |                 HAC
         _ricpaz |        IRR   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
              _t |   1.019932   .0023396     8.60   0.000     1.015357    1.024528
            _x49 |   .8233198   .0587424    -2.72   0.006     .7158745    .9468916
          _x_t49 |   .9756744   .0026896    -8.93   0.000     .9704171    .9809603
           _cons |   26.27674   1.264258    67.94   0.000     23.91208    28.87523
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline incidence rate.
    
    
                        Postintervention Linear Trend: 49
    
    Treated: _b[_t]+_b[_x_t49]
    ------------------------------------------------------------------------------
    Linear Trend |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         Treated |  -.0048906   .0010322    -4.74   0.000    -.0069137   -.0028675
    ------------------------------------------------------------------------------
    
    . 
    . display exp(_b[_t] + _b[_x_t49])                
    .99512137

    As you see in the end of the code, I can quite easily compute the exponentiated coefficient because I can retrieve _b[_t] and _b[_x_t49] from the stored results. However, I cannot do the same with the 95% CI because I don't see its coefficients in the matrix of stored results.

    Can anyone point me to a solution quicker than doing calculations at hand?


    Furthermore, I would suggest as an update to itsa to provide all the results in exp form when the eform option is specified, including those of the post-intervention trend. And possibly to correct the headings of the posttrend table, which currently remains "Linear trend" also when a negative binomial funcion is used

    thanks!

  • #2
    itsa is from SSC (FAQ Advice #12). If you want CIs for the exponentiated sum, use nlcom.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long state int year float(cigsale cigsale_scaled cigsale_count lnincome beer age15to24 retprice)
    3 1970   123  .9421296 24        .    . .1781583  38.8
    3 1971   121  .9189815 24        .    . .1792964  39.7
    3 1972 123.5  .9479167 24 9.930814    . .1804344  39.9
    3 1973 124.4  .9583334 24 9.955092    . .1815724  39.9
    3 1974 126.7  .9849536 25 9.947999    . .1827104  41.9
    3 1975 127.1  .9895833 25 9.937167    . .1838485    45
    3 1976   128         1 25 9.976858    . .1849865  48.3
    3 1977 126.4  .9814815 25  10.0027    . .1861245    49
    3 1978 126.1  .9780092 25 10.04556    . .1872625  58.7
    3 1979 121.9  .9293982 24 10.05469    . .1884006  60.1
    3 1980 120.2  .9097222 24 10.03784    . .1895386  62.1
    3 1981 118.6  .8912037 23 10.02863    . .1855371  66.4
    3 1982 115.4  .8541667 23 10.01253    . .1815355  72.8
    3 1983 110.8   .800926 22 10.03174    . .1775339  84.9
    3 1984 104.8  .7314815 20 10.07536   25 .1735324  94.9
    3 1985 102.8  .7083334 20  10.0997   24 .1695308    98
    3 1986  99.7  .6724537 19 10.12727 24.7 .1655293 104.4
    3 1987  97.5  .6469908 19  10.1343 24.1 .1615277 103.9
    3 1988  90.1  .5613426 18 10.14166 23.6 .1575262 117.4
    3 1989  82.4  .4722222 16 10.14231 23.7 .1535246 126.4
    3 1990  77.8  .4189815 15 10.14162 23.8  .149523 163.8
    3 1991  68.7  .3136574 13 10.11071 22.3        . 186.8
    3 1992  67.5  .2997685 13 10.11494 21.3        . 201.9
    3 1993  63.4 .25231484 12  10.0985 20.8        . 205.1
    3 1994  58.6 .19675925 11 10.09951 20.1        . 190.3
    3 1995  56.4 .17129633 11 10.15592 19.7        . 195.1
    3 1996  54.5 .14930557 10 10.17864 19.1        . 197.9
    3 1997  53.8 .14120372 10 10.17519 19.5        . 200.3
    3 1998  52.3  .1238426 10        .    .        . 207.8
    3 1999  47.2 .06481484  9        .    .        . 224.9
    3 2000  41.6         0  8        .    .        . 351.2
    end
    label values state newstate
    label def newstate 3 "California", modify
    
    tsset year
    itsa cigsale, trperiod(1989) single lag(1) posttrend 
    nlcom exp(_b[_t] + _b[_x_t1989])
    Res.:

    Code:
    . itsa cigsale, trperiod(1989) single lag(1) posttrend 
    
    
    
    Time variable: year, 1970 to 2000
            Delta: 1 unit
    
    Iteration 0:  Log likelihood = -92.844714  
    
    Generalized linear models                         Number of obs   =         31
    Optimization     : ML                             Residual df     =         27
                                                      Scale parameter =    26.8497
    Deviance         =  724.9420235                   (1/df) Deviance =    26.8497
    Pearson          =  724.9420235                   (1/df) Pearson  =    26.8497
    
    Variance function: V(u) = 1                       [Gaussian]
    Link function    : g(u) = u                       [Identity]
    
    HAC kernel (lags): Newey–West (1)
                                                      AIC             =   6.248046
    Log likelihood   = -92.84471396                   BIC             =   632.2244
    
    ------------------------------------------------------------------------------
                 |                 HAC
        _cigsale | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
              _t |  -1.779474   .3834188    -4.64   0.000    -2.530961   -1.027987
          _x1989 |   -20.0581   4.724395    -4.25   0.000    -29.31774   -10.79845
        _x_t1989 |  -1.494652   .4368201    -3.42   0.001    -2.350804   -.6385008
           _cons |   132.2258   4.253053    31.09   0.000       123.89    140.5616
    ------------------------------------------------------------------------------
    
    
                        Postintervention Linear Trend: 1989
    
    Treated: _b[_t]+_b[_x_t1989]
    ------------------------------------------------------------------------------
    Linear Trend |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         Treated |  -3.274126   .2688039   -12.18   0.000    -3.800972    -2.74728
    ------------------------------------------------------------------------------
    
    . 
    . nlcom exp(_b[_t] + _b[_x_t1989])
    
           _nl_1: exp(_b[_t] + _b[_x_t1989])
    
    ------------------------------------------------------------------------------
        _cigsale | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           _nl_1 |   .0378499   .0101742     3.72   0.000     .0179089     .057791
    ------------------------------------------------------------------------------

    Comment


    • #3
      thank you very much Andrew,
      this does what I needed!

      Comment

      Working...
      X