percentiles from an empirical density obtained with DENSITY
percentiles from an empirical density obtained with DENSITY
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
Economic Research Dept.
Federal Reserve Bank of Cleveland
Re: percentiles from an empirical density obtained with DENS
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))
Re: percentiles from an empirical density obtained with DENS
Great -- thanks very much
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
Economic Research Dept.
Federal Reserve Bank of Cleveland