Announcement

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

  • Cannot estimate Margins following -npregress-

    I am trying to estimate a nonparametic regression using -npregress-. I first tried to estimate the following:

    Code:
    npregress kernel sin_totHomeExp age_female if P == 1 & age_female >= 50, vce(bootstrap, seed(1234))
    I get an error saying that there are insignificant observations to compute the bootstrapped standard errors. So I tried adding the -nodrop- option and estimated the following:

    Code:
    npregress kernel sin_totHomeExp age_female if P == 1 & age_female >= 50, vce(bootstrap, seed(1234) nodrop)
    I get results for this:
    Code:
                                  Observed Estimate        Bootstrapped Std. Err.         z                 P>|z|
    Mean
    sin_totHomeExp               5.837566                         0.411449                 141.88            0.000
    
    Effect
    age_female                  -0.0603533                       0.0048706                -12.39             0.000
    After this, I want to get the marginal effects, so I run this line of code:
    Code:
    margins, at(age_female=(50(2)85))
    and I get the following error:
    Code:
    data have changed since estimation.  Margins and predictafter npregress will not work if your covariates, your dependent variable, or the predictions from npregress have changed since estimation. r(198)
    unfortunately, I cannot share the data because I am working with a restricted data set, but I am hoping someone has some insight as to the problem. I am running the regression and margins command at the same time, so I am not changing the data or anything at all inbetween npregress and margins.

    Thanks for any help!
    Tim

  • #2
    Hi Tim
    I think this problem will be very hard to diagnose without additional information or a replicable example.
    Perhaps the most daunting problem i see is that bootstrap standard errors cannot be directly applied. My guess is that age does not have enough support (around the tails), which may be causing this.
    Can you provide a tabulation of age_female, and perhaps a tabstat (mean and standard errors) of sin_totHomeExp by age_female? In both cases using the sample defined by "if P == 1 & age_female >= 50"
    That may help have a better idea of your data, and why npregress is not working.

    Fernando

    Comment


    • #3
      Hey Fernando, age_female is just the age, ranges from 50-102. I included the -tabstat- output with mean and standard deviation
      Age_Female Mean SD
      50 6.358338 2.996968
      51 6.245804 3.573873
      52 6.927383 2.74296
      53 7.213501 2.468586
      54 6.486439 3.284938
      55 6.459813 3.494563
      56 6.718764 3.008857
      57 6.151103 3.326089
      58 6.500867 3.326089
      59 6.405158 3.308358
      60 6.830825 2.853765
      61 6.233559 3.452721
      62 6.477195 3.25382
      63 6.537533 3.374326
      64 6.374115 3.309824
      65 6.390091 3.231187
      66 6.135569 3.414742
      67 6.160622 3.362239
      68 6.075977 3.233201
      69 6.080395 3.335637
      70 5.66325 3.588735
      71 5.597188 3.50087
      72 5.769733 3.40418
      73 5.75599 3.529218
      74 5.548663 3.432273
      75 5.363811 3.494965
      76 5.850755 3.459182
      77 5.562073 3.396962
      78 5.150945 3.65316
      79 4.785413 3.703598
      80 5.390926 3.567981
      81 5.761652 3.362377
      82 5.091838 3.624754
      83 4.655346 3.605155
      84 5.026394 3.680572
      85 5.260563 3.559989
      86 4.996206 3.433092
      87 4.901424 4.169815
      88 4.922944 3.838504
      89 4.4093194 3.957232
      90 3.321275 3.821344
      91 4.769178 3.955306
      92 5.144357 4.116713
      93 5.358893 3.568693
      94 . .
      95 1.569964 3.510547
      96 . .
      97 2.273401 3.937646
      98 . .
      99 6.848347 .
      100 . .
      101 . .
      102 . .

      Comment


      • #4
        I see. So, my guess is that npregress is having problems estimating the model when age>90. Probably you do not have enough observations above that threshold to run bootstrap standard errors, or estimate the npregress kernel.
        would you try running your command, say, for age<90 ? or perhaps 80?
        Since npregress is based on local regressions, i think the estimations would not be affected much by excluding some outlier observations.

        Comment


        • #5
          Thanks Fernando, I have tried that, I guess the error is with calculating the standard errors with bootstrapping, when I run the regression without bootstrapping the standard errors it works just fine. There are insufficient observations to bootstrap the standard errors without the -nodrop- option coded.

          I saw this in this post https://www.statalist.org/forums/for...with-summarize

          Comment

          Working...
          X