percentiles from an empirical density obtained with 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

percentiles from an empirical density obtained with DENSITY

Unread post by tclark »

After I use DENSITY to obtain a kernel-smoothed empirical density for a given series, is there a direct way to get the percentiles from that smoothed density? One option is to use %rangrid to take draws and compute percentiles from those draws. Is there a better way? Thanks much.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: percentiles from an empirical density obtained with DENS

Unread post by TomDoan »

This will do a linear interpolation of the CDF computed from the empirical density:

Code: Select all

set x 1 1000 = %ran(1.0)
density(smoothing=1.5,grid=automatic,maxgrid=250) x / xx fx
acc(scale) fx / cdfx
stats(fract) x
sstats(max) / %if(cdfx<=.90,t,0)>>x90
compute i90=fix(x90)
disp "Interpolated 90%-ile" xx(i90-1)+(.90-cdfx(i90-1))/(cdfx(i90)-cdfx(i90-1))*(xx(i90)-xx(i90-1))
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

Re: percentiles from an empirical density obtained with DENS

Unread post by tclark »

Great -- thanks very much
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
Post Reply