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()
The exponential distribution has probability density f(x) = e–x, x ≥ 0, and therefore the cumulative distribution is the integral of the density: F(x) = 1 – e–x. This function can be explicitly inverted by solving for x in the equation F(x) = u. The inverse CDF is x = –log(1–u).
The inverse cumulative distribution function gives the value associated with a specific cumulative probability. Use the inverse CDF to determine the value of the variable associated with a specific probability.
Inverse transform sampling - CDF is not invertible.
An inverse cumulative probability function returns the value x at which the probability of the true outcome being less than or equal to x is «p». They are said to compute the fractile, percentile, quantile, etc. They perform this computation analytically, so that there is no Monte Carlo sampling error in the result.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With