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.

computing empirical density

Postby tclark » Mon Apr 16, 2012 4:03 pm

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
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: computing empirical density

Postby TomDoan » Mon Apr 16, 2012 4:16 pm

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: computing empirical density

Postby tclark » Mon Apr 16, 2012 4:33 pm

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
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: computing empirical density

Postby TomDoan » Mon Apr 16, 2012 7:34 pm

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 1 guest