Page 1 of 1

computing empirical density

Posted: Mon Apr 16, 2012 4:03 pm
by tclark
I would like to be able to use the empirical (non-parametric) density of a set of forecast draws to compute a predictive score. The problem I am having is with getting NAs associated with outlier observations of the last few years. This is the result of the following block of code. I set the first grid point equal to the actual observation, to get the density evaluated at that value. It works fine for most observations, except for some outliers during the crisis. If anyone has suggestions on how to do this better and avoid getting missing values, I would really appreciate it.

Code: Select all

  
stats(noprint,fractiles) oneforecast 1 availdraws
comp span2 = %fract99 - %fract01
set grid2 2 npts2 = %fract01 + (t-2)*span2/(npts2-2.)
comp grid2(1) = actuals(i)(stpt+j-1)
density(grid=input) oneforecast 1 availdraws grid2 estdens2
comp predlike(i,j) = log(estdens2(1))

Re: computing empirical density

Posted: Mon Apr 16, 2012 4:16 pm
by TomDoan
Have you tried using a Gaussian window rather than the default Epanechnikov? Epanechnikov has zero weight outside +/- one bandwidth so you could get a 0 density if the grid point that you use is distant from the forecasts. The Gaussian window has a non-zero value (theoretically) for all data points.

Re: computing empirical density

Posted: Mon Apr 16, 2012 4:33 pm
by tclark
Thanks, Tom. I'll try the Gaussian. I was trying to use the Epanechnikov to be able to say the density was non-parametric, but it clearly was posing problems.

Re: computing empirical density

Posted: Mon Apr 16, 2012 7:34 pm
by TomDoan
There's no real difference between the two when it comes to being "non-parametric" or not. Both require choice of a bandwidth which are designed to give roughly the same amount of smoothing for different window types.