KDE Confidence Interval

Viewed 36

Can anyone help with below code?Please see the plot below I was trying to find the lower and upper limit of the distribution.

My code as below

In[152]:

sample = kde.resample(43826)
5 ** np.percentile(sample, 5)

In[153]:

 def resample_kde_percentile(kde):
    sample = kde.resample(kde.n)
    return 5 ** np.percentile(sample, 5)

In[154]:

def summarize(t, digits=2):
     table = pd.DataFrame(columns=['Estimate', 'SE', 'CI90'])
     est = np.mean(t).round(digits)
     SE = np.std(t).round(digits)
     CI95 = np.percentile(t, [5, 95]).round(digits)
     table.loc[''] = est, SE, CI95
     return table

In[155]:

t10 = [resample_kde_percentile(kde)
   for i in range(1000)]

summary10 = summarize(t10)
summary10

I am trying to find the upper and lower limit using KDE bootstrapping.

steps

  1. Find residual of Actual and prediction.
  2. Normalize the residuals
  3. KDE of residuals
  4. resampling KDE
  5. find the upper and lower limit
  6. create Prediction interval.
0 Answers
Related