问题
I'm working with a data file, the observations inside are random values. In this case I don't know the distribution of x (my observations). I'm using the function density in order to estimate the density, because I must apply a kernel estimation.
T=density(datafile[,1],bw=sj,kernel="epanechnikov")
After this I must integrate this because I'm looking for a quantile (similar to VaR, 95%). For this I have 2 options:
ecdf()
quantile()
Now I have the value of the quantile 95, but this is the data estimated by kernel.
Is there a function which I can use to know the value of the quantile 95 of the original data?
I remark that this is a distribution unknown, for this I would like to imagine a non parametric method as Newton, like the one that is in SAS solve()
回答1:
You can use quantile() for this. Here is an example using random data:
> data<-runif(1000)
> q<-quantile(data, .95)
> q
95%
0.9450324
Here, the data is uniformly distributed between 0 and 1, so the 95th percentile is close to 0.95.
To perform the inverse transformation:
> ecdf(data)(q)
[1] 0.95
来源:https://stackoverflow.com/questions/14446569/inverse-function-of-an-unknown-cumulative-function