给定不在 r 中的分布的分位数函数
quantile function given a distribution that is not in r
我正在尝试为给定分布生成分位数函数 (f_q)。这是我的代码:
library(GoFKernel)
f_cdf <- function(x) {
integrate(fstar, 1e-10, x)$value/I
}
f_q <- inverse(f_cdf, lower=1e-10, upper=5-1e-10)
ggplot(x_plot, aes(sample=x))+
labs(title="Empirical against theoretical quantiles")+
stat_qq(distribution=f_q) +
stat_qq_line(distribution=f_q)
当我这样做时,出现以下错误:
计算在 stat_qq()
中失败:未使用的参数(p = 分位数)。
stat_qq_line()
中的计算失败:未使用的参数(p = 分位数)。
当我的绘图代码和我从 f 获得的样本时没有问题。原因是我把'distribution=f_q'改成'distribution=qnorm'能成功得到一个ggplot:
the qqplot given a 'wrong' distribution
因此,我可以确定我的 'f_q' 分位数函数存在一些错误。因此,如果有人知道 stat_qq 和 stat_qq.line 的 'distribution' 参数的具体要求,那将非常有帮助。
fstar 在 0 和 5 处未定义,范围在 0 到 5 之间。我设计了一个拒绝方案来模拟这个分布,我试图通过分位数-分位数图比较理论分位数和样本分位数.
您的正式分布函数可能需要命名为 p
。尝试:
f_q_p <- function(p) { f_q(p) }
然后
ggplot(x_plot, aes(sample=x))+
labs(title="Empirical against theoretical quantiles")+
stat_qq(distribution=f_q_p) +
stat_qq_line(distribution=f_q_p)
我正在尝试为给定分布生成分位数函数 (f_q)。这是我的代码:
library(GoFKernel)
f_cdf <- function(x) {
integrate(fstar, 1e-10, x)$value/I
}
f_q <- inverse(f_cdf, lower=1e-10, upper=5-1e-10)
ggplot(x_plot, aes(sample=x))+
labs(title="Empirical against theoretical quantiles")+
stat_qq(distribution=f_q) +
stat_qq_line(distribution=f_q)
当我这样做时,出现以下错误:
计算在 stat_qq()
中失败:未使用的参数(p = 分位数)。
stat_qq_line()
中的计算失败:未使用的参数(p = 分位数)。
当我的绘图代码和我从 f 获得的样本时没有问题。原因是我把'distribution=f_q'改成'distribution=qnorm'能成功得到一个ggplot: the qqplot given a 'wrong' distribution
因此,我可以确定我的 'f_q' 分位数函数存在一些错误。因此,如果有人知道 stat_qq 和 stat_qq.line 的 'distribution' 参数的具体要求,那将非常有帮助。
fstar 在 0 和 5 处未定义,范围在 0 到 5 之间。我设计了一个拒绝方案来模拟这个分布,我试图通过分位数-分位数图比较理论分位数和样本分位数.
您的正式分布函数可能需要命名为 p
。尝试:
f_q_p <- function(p) { f_q(p) }
然后
ggplot(x_plot, aes(sample=x))+
labs(title="Empirical against theoretical quantiles")+
stat_qq(distribution=f_q_p) +
stat_qq_line(distribution=f_q_p)