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?










share|improve this question




























    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?










    share|improve this question


























      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?










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 0:00

























      asked Nov 10 at 22:09









      Hendrra

      21519




      21519
























          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))


          enter image description here



          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')


          enter image description here



          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.






          share|improve this answer























          • 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 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










          • In a similar task for normal and exponential distribution can I use identity function too?
            – Hendrra
            Nov 10 at 22:52











          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',
          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
          });


          }
          });














           

          draft saved


          draft discarded


















          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








          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))


          enter image description here



          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')


          enter image description here



          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.






          share|improve this answer























          • 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 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










          • In a similar task for normal and exponential distribution can I use identity function too?
            – Hendrra
            Nov 10 at 22:52















          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))


          enter image description here



          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')


          enter image description here



          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.






          share|improve this answer























          • 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 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










          • In a similar task for normal and exponential distribution can I use identity function too?
            – Hendrra
            Nov 10 at 22:52













          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))


          enter image description here



          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')


          enter image description here



          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.






          share|improve this answer














          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))


          enter image description here



          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')


          enter image description here



          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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 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










          • 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






          • 1




            @Hendrra, certainly, see the update.
            – Julius Vainora
            Nov 10 at 22:31






          • 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










          • 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


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python