Announcement

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

  • Calculating standard deviations from wtp command

    Hi all

    I am needing to calculate the standard deviations from my wtp estimates. I have used the wtp, krinsky command and get wtp estimates and confidence levels. Is there a formula or code which will give me the standard error?

    Regards

  • #2
    So, you need to know whether you have confidence intervals with a z-distribution or t-distribution. Once you know this, backing out the standard error is straightforward. You have

    $$\text{CI} = \hat{y} \pm \text{t/z crit.}\cdot \text{s.e.}$$

    This implies

    $$\text{s.e.}= \text{abs}\left(\frac{CI-\hat{y}}{\text{t/z crit.}}\right).$$

    In Stata, you calculate the 95% t crit. value as

    Code:
     di invt(df, 0.975)
    where -df- is the degrees of freedom. Critical values for the normal distribution do not depend on the degrees of freedom, and therefore for the 95% z crit. value, you simply need

    Code:
     di invnormal(0.975)

    Below, l back out the standard error in the regression outputting t-statistics from the lower limit CI and for the regression outputting z-statistics from the upper level CI.

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . regress foreign mpg
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =     13.18
           Model |  2.39252954         1  2.39252954   Prob > F        =    0.0005
        Residual |  13.0669299        72  .181485138   R-squared       =    0.1548
    -------------+----------------------------------   Adj R-squared   =    0.1430
           Total |  15.4594595        73  .211773417   Root MSE        =    .42601
    
    ------------------------------------------------------------------------------
         foreign |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |   .0312915   .0086182     3.63   0.001     .0141114    .0484716
           _cons |  -.3691266   .1901085    -1.94   0.056    -.7481011    .0098478
    ------------------------------------------------------------------------------
    
    . mat r= r(table)
    
    . mat list r
    
    r[9,2]
                   mpg       _cons
         b   .03129148  -.36912663
        se   .00861823   .19010853
         t   3.6308484  -1.9416626
    pvalue   .00052542   .05609126
        ll   .01411136  -.74810105
        ul    .0484716    .0098478
        df          72          72
      crit   1.9934636   1.9934636
     eform           0           0
    
    . di abs(r[5,1] - _b[mpg])/invt(e(df_r), 0.975)
    .00861823
    
    . logit foreign mpg
    
    Iteration 0:   log likelihood =  -45.03321  
    Iteration 1:   log likelihood = -39.380959  
    Iteration 2:   log likelihood = -39.288802  
    Iteration 3:   log likelihood =  -39.28864  
    Iteration 4:   log likelihood =  -39.28864  
    
    Logistic regression                             Number of obs     =         74
                                                    LR chi2(1)        =      11.49
                                                    Prob > chi2       =     0.0007
    Log likelihood =  -39.28864                     Pseudo R2         =     0.1276
    
    ------------------------------------------------------------------------------
         foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |   .1597621   .0525876     3.04   0.002     .0566922     .262832
           _cons |  -4.378866   1.211295    -3.62   0.000    -6.752961   -2.004771
    ------------------------------------------------------------------------------
    
    . mat r2= r(table)
    
    . mat list r2
    
    r2[9,2]
               foreign:    foreign:
                   mpg       _cons
         b   .15976213   -4.378866
        se   .05258764   1.2112952
         z   3.0380166   -3.615028
    pvalue   .00238141   .00030032
        ll   .05669225  -6.7529609
        ul   .26283202   -2.004771
        df           .           .
      crit    1.959964    1.959964
     eform           0           0
    
    . di abs(r2[6,1] - _b[mpg])/invnormal(0.975)
    .05258764

    Comment

    Working...
    X