给定的分位数函数不在r中

问题描述 投票:1回答:1

我正在尝试为给定分布生成分位数函数(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之间。我设计了一种拒绝方案,可以根据这种分布进行模拟,并且我试图通过分位数-分位数图比较理论分位数和样本分位数。

r plot distribution simulate
1个回答
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)
© www.soinside.com 2019 - 2024. All rights reserved.