computing empirical density

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

computing empirical density

Unread post 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))
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: computing empirical density

Unread post 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.
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

Re: computing empirical density

Unread post 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.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: computing empirical density

Unread post 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.
Post Reply