Announcement

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

  • Using npregress to compute local regressions at specific points (as is possible with kernmeans)

    I have some code that uses the user-defined function kernmean, which computes kernel means for bivariate regression. The code is:

    Code:
    kernmean y x if cond_a==1 & cond_b=1 & cond_c>cond_d, order(1) at(z) generate(newvar) epan bw(5)
    Where the function estimates a local kernel mean at each value of variable z using the epanechnikov kernel and a bandwidth of 5 for all observations satisfying the various conditions.

    My issue is that I need to include controls in the regression and cannot do this using the user-defined function kernmean. Instead I want to use the STATA command npregress. The code I have so far is:

    Code:
    npregress kernel y x control if if cond_a==1 & cond_b=1 & cond_c>cond_d, kernel(ep) predict(newvar1 newvar2 newvar3) bwidth(5 5 5 5, copy)
    However, this does not estimate the mean at each value of variable z.

    Is there a way to include such an option in the npregress command, or is there another command that could accomplish this?

    Cross-posted from: https://stackoverflow.com/questions/...as-is-possible

  • #2
    kernmean is presumably a community-contributed command (not a function) but you don't explain where it comes from.

    Comment


    • #3
      Hi, sorry. Kernmean is from here: https://www.openicpsr.org/openicpsr/....ado&type=file

      Comment


      • #4
        Hi Giulian
        Perhaps couple of questions on what you are working.
        1. Why use kernmean instead of lpoly (for the basic case). Do you know what the difference is? and what lpoly does?
        2. You say you want to control for other factors. In this case, what do you think the underlying model would be?

        E(y|x,z) = f(x,z1,z2,z3) or E(y|x,z) = f(x) + a1 z1+a2 z2 + a3 z3

        In which case, how do you think the E(y|x) should be estimated? Parametrically? at z's equal to their mean? using all possible values of Z's

        3. npregress kernel estimates a fully non-parametric model (E(y|x,z) = f(x,z1,z2,z3)) which may not be exactly what you need.

        So, if you can provide more information of the kind of model you are trying to estimate, and how you are defining E(y|x) so that it accounts for other controls, it may be easier to provide further guidance.
        F

        Comment

        Working...
        X