简体   繁体   English

创建一个Beta发行版QQ图

[英]Creating a beta distribution Q-Q plot

My task is to create 100 random generated numbers from beta distribution and compare that random variable with beta distribution using quantile plot. 我的任务是根据beta分布创建100个随机生成的数字,并使用分位数图将随机变量与beta分布进行比较。
This is my attempt: 这是我的尝试:

library(MASS)
library(qualityTools)
Random_Numbers_Beta <- rbeta(100, 1, 1)
qqPlot(Random_Numbers_Beta, "beta", list(shape = 1, rate = 1))

Unfortunately something is wrong. 不幸的是出了点问题。 This is an error which occurs: 这是发生的错误:

Error in (function (x, densfun, start, ...)  : 
'start' must be a named list

Can something be done with that issue? 这个问题可以解决吗?

First, you had to specify that list(shape = 1, rate = 1) is the start parameter; 首先,您必须指定list(shape = 1, rate = 1)start参数; right now this list is being treated as a value for the confbounds parameter. 现在,此列表被视为confbounds参数的值。 Second, it's actually not shape and rate , but shape1 and shape2 , as in, eg, ?dbeta . 其次,实际上不是shaperate ,而是shape1shape2 ,例如?dbeta

qqPlot(Random_Numbers_Beta, "beta", start = list(shape1 = 1, shape2 = 1))

在此处输入图片说明

Again inspecting ?qqPlot you may see that ... is for " further graphical parameters: (see par). " Hence, you may modify the plot the way you like; 再次检查?qqPlot您可能会看到...表示“ 其他图形参数:(请参阅par)。 ”因此,您可以按自己喜欢的方式修改该图。 eg, adding col = 'red' . 例如,添加col = 'red'

Also notice that Beta(1,1) is simply the uniform distribution on [0,1] and, hence, its quantile function is the identity function. 还要注意,Beta(1,1)只是[0,1]上的均匀分布,因此,其分位数函数是恒等函数。 That is, qbeta(x, 1, 1) == x for any x in [0,1]. 也就是说,对于[0,1]中的任何xqbeta(x, 1, 1) == x So, you may also simply work directly with 因此,您也可以直接与

x <- seq(0, 1, length = 500)
plot(quantile(Random_Numbers_Beta, x), x)
abline(a = 0, b = 1, col = 'red')

在此处输入图片说明

if you don't need the confidence bounds. 如果您不需要置信区间。


One can notice, however, that the two plots are a little different. 但是,可以注意到,这两个情节略有不同。 Given your task, it would seem that you need the second one. 考虑到您的任务,您似乎需要第二个。

In the first one, it looks like qqPlot fits a beta distribution for your data and uses its quantiles, which apparently isn't exactly the identity function. 在第一个中, qqPlot看起来适合您的数据的beta分布并使用其分位数,这显然不完全是恒等函数。 That is, it doesn't use the exact knowledge about the parameters. 也就是说,它没有使用有关参数的确切知识。 The second plot uses this knowledge. 第二个情节利用了这一知识。

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

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