【问题标题】:quantile function given a distribution that is not in r给定不在 r 中的分布的分位数函数
【发布时间】:2019-12-06 21:26:25
【问题描述】:

我正在尝试为给定分布生成分位数函数 (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 的“分布”参数的具体要求,那将非常有帮助。

fstar 在 0 和 5 处未定义,范围在 0 和 5 之间。我设计了一个拒绝方案来模拟此分布,并尝试通过分位数-分位数图比较理论分位数和样本分位数。

【问题讨论】:

    标签: r plot distribution simulate


    【解决方案1】:

    您的分布函数形式可能需要命名为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)
    

    【讨论】:

    • 感谢您的回复!但是,这次我收到了不同的警告:stat_qq() 计算失败:端点处的 f() 值不是相反的符号。您还有什么建议吗?
    猜你喜欢
    • 2020-09-28
    • 2021-09-29
    • 2021-02-24
    • 2020-06-08
    • 2013-02-24
    • 2019-11-22
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多