Announcement

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

  • Confidence intervals for gradients in npregress

    Dear all,

    I'm trying to estimate confidence intervals for my gradients after performing a kernel reegression in STATA. I created a mock dataset:

    Code:
    *create dataset with 1000 obs and 3 variables (random residuals, random regressors,
    *non-random dep var; seed 1)
    set obs 1000
    set seed 1
    gen e = rnormal(0,1)
    gen x = rnormal(5,8)
    gen y = 78 + 7*x^2 + e
    and then performed:

    Code:
    npregress kernel y x
    which returns me an estimate of the mean function as well as for the gradients of y. I just could not find out if and how I can estimate confidence intervals for the gradients.

    Regards,
    Tobias

  • #2
    Hi Tobias
    To obtain the standard errors, you need to add the option vce(bootstrap) to your command line.
    Code:
    . npregress kernel y x, vce(bootstrap, seed(1))
    (running npregress on estimation sample)
    
    Bootstrap replications (50)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
    ..................................................    50
    
    Bandwidth
    ------------------------------------
                 |      Mean     Effect 
    -------------+----------------------
               x |  2.028782   3.058894 
    ------------------------------------
    
    Local-linear regression                    Number of obs      =          1,000
    Kernel   : epanechnikov                    E(Kernel obs)      =          1,000
    Bandwidth: cross validation                R-squared          =         0.9991
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                          Percentile
               y |   Estimate   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    Mean         |
               y |   744.0941   30.83909    24.13   0.000     684.1975    805.6043
    -------------+----------------------------------------------------------------
    Effect       |
               x |   71.68299   3.951594    18.14   0.000     64.68955    80.09341
    ------------------------------------------------------------------------------
    Note: Effect estimates are averages of derivatives.
    Same if you want to estimate the marginal effects at some other point of X (instead of the average).
    Code:
    margins, dydx(x) at(x=5) vce(bootstrap)
    HTH
    Fernando

    Comment

    Working...
    X