Creating a beta distribution Q-Q plot [R]
up vote
2
down vote
favorite
My task is to create 100 random generated numbers from beta distribution and compare that random variable with beta distribution using quantile plot.
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?
r
add a comment |
up vote
2
down vote
favorite
My task is to create 100 random generated numbers from beta distribution and compare that random variable with beta distribution using quantile plot.
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?
r
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
My task is to create 100 random generated numbers from beta distribution and compare that random variable with beta distribution using quantile plot.
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?
r
My task is to create 100 random generated numbers from beta distribution and compare that random variable with beta distribution using quantile plot.
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?
r
r
edited Nov 11 at 0:00
asked Nov 10 at 22:09
Hendrra
21519
21519
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
First, you had to specify that list(shape = 1, rate = 1)
is the start
parameter; right now this list is being treated as a value for the confbounds
parameter. Second, it's actually not shape
and rate
, but shape1
and shape2
, as in, e.g., ?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; e.g., adding 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. That is, qbeta(x, 1, 1) == x
for any x
in [0,1]. 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. That is, it doesn't use the exact knowledge about the parameters. The second plot uses this knowledge.
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
1
@Hendrra, also I added a comment about the choice ofqqPlot
, it may be not the right approach (given how you formulated your task).
– Julius Vainora
Nov 10 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
|
show 5 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
First, you had to specify that list(shape = 1, rate = 1)
is the start
parameter; right now this list is being treated as a value for the confbounds
parameter. Second, it's actually not shape
and rate
, but shape1
and shape2
, as in, e.g., ?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; e.g., adding 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. That is, qbeta(x, 1, 1) == x
for any x
in [0,1]. 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. That is, it doesn't use the exact knowledge about the parameters. The second plot uses this knowledge.
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
1
@Hendrra, also I added a comment about the choice ofqqPlot
, it may be not the right approach (given how you formulated your task).
– Julius Vainora
Nov 10 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
|
show 5 more comments
up vote
3
down vote
accepted
First, you had to specify that list(shape = 1, rate = 1)
is the start
parameter; right now this list is being treated as a value for the confbounds
parameter. Second, it's actually not shape
and rate
, but shape1
and shape2
, as in, e.g., ?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; e.g., adding 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. That is, qbeta(x, 1, 1) == x
for any x
in [0,1]. 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. That is, it doesn't use the exact knowledge about the parameters. The second plot uses this knowledge.
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
1
@Hendrra, also I added a comment about the choice ofqqPlot
, it may be not the right approach (given how you formulated your task).
– Julius Vainora
Nov 10 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
|
show 5 more comments
up vote
3
down vote
accepted
up vote
3
down vote
accepted
First, you had to specify that list(shape = 1, rate = 1)
is the start
parameter; right now this list is being treated as a value for the confbounds
parameter. Second, it's actually not shape
and rate
, but shape1
and shape2
, as in, e.g., ?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; e.g., adding 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. That is, qbeta(x, 1, 1) == x
for any x
in [0,1]. 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. That is, it doesn't use the exact knowledge about the parameters. The second plot uses this knowledge.
First, you had to specify that list(shape = 1, rate = 1)
is the start
parameter; right now this list is being treated as a value for the confbounds
parameter. Second, it's actually not shape
and rate
, but shape1
and shape2
, as in, e.g., ?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; e.g., adding 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. That is, qbeta(x, 1, 1) == x
for any x
in [0,1]. 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. That is, it doesn't use the exact knowledge about the parameters. The second plot uses this knowledge.
edited Nov 10 at 22:40
answered Nov 10 at 22:15
Julius Vainora
26.7k75877
26.7k75877
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
1
@Hendrra, also I added a comment about the choice ofqqPlot
, it may be not the right approach (given how you formulated your task).
– Julius Vainora
Nov 10 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
|
show 5 more comments
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
1
@Hendrra, also I added a comment about the choice ofqqPlot
, it may be not the right approach (given how you formulated your task).
– Julius Vainora
Nov 10 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 at 22:22
1
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 at 22:31
1
1
@Hendrra, also I added a comment about the choice of
qqPlot
, it may be not the right approach (given how you formulated your task).– Julius Vainora
Nov 10 at 22:40
@Hendrra, also I added a comment about the choice of
qqPlot
, it may be not the right approach (given how you formulated your task).– Julius Vainora
Nov 10 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 at 22:52
|
show 5 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243919%2fcreating-a-beta-distribution-q-q-plot-r%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown