Creating a beta distribution Q-Q plot [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
add a comment |
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 |
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 '18 at 0:00
Hendrra
asked Nov 10 '18 at 22:09
HendrraHendrra
215110
215110
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 '18 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 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 '18 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 at 22:52
|
show 5 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 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 '18 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 at 22:52
|
show 5 more comments
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 '18 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 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 '18 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 at 22:52
|
show 5 more comments
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 '18 at 22:40
answered Nov 10 '18 at 22:15
Julius VainoraJulius Vainora
34.3k76079
34.3k76079
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 '18 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 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 '18 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 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 '18 at 22:22
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 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 '18 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 at 22:52
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 '18 at 22:22
Thank you! Your post is very helpful. Is it possible to change the look of the dots?
– Hendrra
Nov 10 '18 at 22:22
1
1
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 at 22:31
@Hendrra, certainly, see the update.
– Julius Vainora
Nov 10 '18 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 '18 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 '18 at 22:40
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
Your comment is really useful. Thank you! It's true that I haven't noticed it.
– Hendrra
Nov 10 '18 at 22:47
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 at 22:52
In a similar task for normal and exponential distribution can I use identity function too?
– Hendrra
Nov 10 '18 at 22:52
|
show 5 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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