Announcement

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

  • npregress derivatives at different points instead of average of total

    I am running a nonparametric regression using the following code:

    Code:
    npregress kernel log_totExp age, vce(bootstrap, reps(20) seed(12345))
    margins, at(age = (55(5)85)) vce(bootstrap, reps(20) seed(12345))
    I get a nice margins plot and an average derivative of -.023. But what I would like to have is what is the average derivative from age 55-65 and then from 66+. Is there a way to do that?

    Thanks!
    Tim
    Last edited by Tim Murray; 08 Mar 2020, 19:26. Reason: added tags

  • #2
    Tim: I wonder if the predict command with the derivatives option, rather than the margins command, may be what you need. E.g. consider the following code:
    Code:
    cap preserve
    cap drop _all
    set obs 200
    gen age=floor(25+50*runiform())
    gen log_totExp=10+.5*age-.005*age^2+rnormal(0 5)
    npregress kernel log_totExp age, vce(bootstrap, reps(20) seed(12345))
    predict mage, derivatives
    sum mage
    sum mage if age>=55 & age<=65
    sum mage if age>=66
    cap restore

    Comment


    • #3
      Thanks John, that is exactly what I needed. I appreciate your insights!

      Comment

      Working...
      X