Page 1 of 1
percentiles from an empirical density obtained with DENSITY
Posted: Tue Jul 13, 2021 7:30 pm
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.
Re: percentiles from an empirical density obtained with DENS
Posted: Wed Jul 14, 2021 10:10 am
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))
Re: percentiles from an empirical density obtained with DENS
Posted: Wed Jul 14, 2021 10:40 am
by tclark
Great -- thanks very much