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.
我正在使用数据文件,里面的观察是随机值。在这种情况下,我不知道x的分布(我的观察)。我正在使用函数密度来估计密度,因为我必须应用核估计。
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:
在此之后我必须整合它,因为我正在寻找分位数(类似于VaR,95%)。为此我有两个选择:
ecdf()
quantile()
Now I have the value of the quantile 95, but this is the data estimated by kernel.
现在我有了分位数95的值,但这是内核估计的数据。
Is there a function which I can use to know the value of the quantile 95 of the original data?
是否有一个函数可以用来知道原始数据的分位数95的值?
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()
我注意到这是一个未知的分布,为此我想把一个非参数方法想象为Newton,就像在SAS中那样解决()
1 个解决方案
#1
6
You can use quantile()
for this. Here is an example using random data:
您可以使用quantile()。以下是使用随机数据的示例:
> 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.
这里,数据均匀分布在0和1之间,因此第95百分位数接近0.95。
To perform the inverse transformation:
要执行逆变换:
> ecdf(data)(q)
[1] 0.95
#1
6
You can use quantile()
for this. Here is an example using random data:
您可以使用quantile()。以下是使用随机数据的示例:
> 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.
这里,数据均匀分布在0和1之间,因此第95百分位数接近0.95。
To perform the inverse transformation:
要执行逆变换:
> ecdf(data)(q)
[1] 0.95