简体   繁体   English

R:将[KDE]密度图转换为cdf吗?

[英]R: Turn a [KDE] density plot into a cdf?

Data: 34,46,47,48,52,53,55,56,56,56,57,58,59,59,68 数据:34,46,47,48,52,53,55,56,56,56,57,58,59,59,68

Density Plot 密度图

在此处输入图片说明

ECDF 欧洲发展基金

在此处输入图片说明

What I'd like to do is take the derived density plot and turn it into a cumulative distribution frequency to derive %'s from. 我想做的就是获取导出的密度图,然后将其转换为累积分布频率以从中导出%。 And vice versa. 反之亦然。 My hope is to use the kernel density estimation specifically to derive a smoothed cumulative distribution function. 我的希望是专门使用核密度估计来得出平滑的累积分布函数。 I don't wish to rely on the raw data points to do a ECDF, but use the KDE to do a CDF. 我不希望依靠原始数据点来进行ECDF,而是使用KDE来进行CDF。

Edit: 编辑:

I see there is a KernelSmoothing.CDF, might this be the solution? 我看到有一个KernelSmoothing.CDF,这可能是解决方案吗? If it is, I have no idea how to implement it so far. 如果是这样,到目前为止我还不知道如何实现。

Mathworks has an example of what I'm trying to do, converting from an ECDF to a KECDF under "Compute and plot the estimated cdf evaluated at a specified set of values." Mathworks提供了一个示例,说明如何将ECDF转换为KECDF,方法是“计算并绘制以指定的一组值评估的cdf”。

http://www.mathworks.com/help/stats/examples/nonparametric-estimates-of-cumulative-distribution-functions-and-their-inverses.html?requestedDomain=www.mathworks.com http://www.mathworks.com/help/stats/examples/nonparametric-estimates-of-cumulative-distribution-functions-and-their-inverses.html?requestedDomain=www.mathworks.com

在此处输入图片说明

although I think the implementation is fairly sloppy. 尽管我认为实施相当草率。 Considering a polynomial regression line would be a better fit. 考虑多项式回归线会更好。

library("DiagTest3Grp", lib.loc='~/R/win-library/3.2")

data <- c(34,46,47,48,52,53,55,56,56,56,57,58,59,59,68)
bw <- BW.ref(data)
x0 <- seq(0, 100, .1) 
KS.cdfvec <- Vectorize(KernelSmoothing.cdf, vectorize.args = "c0")
x0.cdf <- KS.cdfvec(xx = data, c0 = x0, bw = bw)
plot(x0, x0.cdf, type = "l")

I still need to figure out how to derive y given x, but this was a major help 我仍然需要弄清楚如何在给定x的情况下得出y,但这是一个重要的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM