How to graph Wilcoxon test power R

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I've been trying to calculate and graph the correspondent power for the wilcoxon signed test and haven't had any luck.



I tried simulating two normal distributed samples, apply the wilcoxon test and finally calculating the p-value, but i'm not sure on how to obtain the graph for it, what I'm looking for is something like this posted by the user Glen_b in thw following question: In what situation would Wilcoxon's Signed-Rank Test be preferable to either t-Test or Sign Test?



enter image description here



Thank you in advance for your help.










share|cite|improve this question



























    up vote
    1
    down vote

    favorite












    I've been trying to calculate and graph the correspondent power for the wilcoxon signed test and haven't had any luck.



    I tried simulating two normal distributed samples, apply the wilcoxon test and finally calculating the p-value, but i'm not sure on how to obtain the graph for it, what I'm looking for is something like this posted by the user Glen_b in thw following question: In what situation would Wilcoxon's Signed-Rank Test be preferable to either t-Test or Sign Test?



    enter image description here



    Thank you in advance for your help.










    share|cite|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I've been trying to calculate and graph the correspondent power for the wilcoxon signed test and haven't had any luck.



      I tried simulating two normal distributed samples, apply the wilcoxon test and finally calculating the p-value, but i'm not sure on how to obtain the graph for it, what I'm looking for is something like this posted by the user Glen_b in thw following question: In what situation would Wilcoxon's Signed-Rank Test be preferable to either t-Test or Sign Test?



      enter image description here



      Thank you in advance for your help.










      share|cite|improve this question













      I've been trying to calculate and graph the correspondent power for the wilcoxon signed test and haven't had any luck.



      I tried simulating two normal distributed samples, apply the wilcoxon test and finally calculating the p-value, but i'm not sure on how to obtain the graph for it, what I'm looking for is something like this posted by the user Glen_b in thw following question: In what situation would Wilcoxon's Signed-Rank Test be preferable to either t-Test or Sign Test?



      enter image description here



      Thank you in advance for your help.







      r nonparametric simulation power wilcoxon-signed-rank






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked 5 hours ago









      Karl Jimbo

      62




      62




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          In cases where you don't know a way to compute power algebraically, you can use simulation. (That's how the power curves were obtained in the plot you show.)



          To compute a single point on the power curve you need a completely specified alternative. In the case of a Wilcoxon-Mann-Whitney test you need to specify the sample sizes, the distribution(s) - you said normal - and then the parameters - the means, and the variances in the case of the normal.



          You simulate many samples at a specific alternative and compute the sample rejection rate (in order to approximate the power at that point).



          Then you vary one of those specified things to get other points on the curve. In the case in the question (two sample location difference) it's the difference in population means (population locations more generally but I'll keep saying means) we want to look at power against.



          In that two sample case case, one mean is held constant (generally at 0 for normals) while the other is varied.



          You'll obtain a series of points each of which produces a (binomial) estimate of a probability -- the rejection rate at that point.



          See the purple points in the second plot here;
          plot of power for the one-sample t and signed rank test at the normal with n=4



          Normally you'd want to do a few more points, though. For the Wilcoxon-Mann-Whitney, there's an example of power computed at a larger set of points here:



          Plot of power at various shifts for normal samples under shift alternative at n=20 in each group



          Typically you want to end up with a curve rather than a set of points. We have a curve for the t in that first plot above because this is straightforward (indeed R has a built-in function for it which was used to produce that curve).



          If you have done many simulations, the standard error will be so small that you can treat it as known (which is why my simulated points don't tend to show standard error bars; they're usually inside the plotted points) and just join the points with a smooth curve; see the last plot at the above link:



          power curves for the Shapiro-Wilk and Lilliefors tests of general normality against increasingly skew gamma alternatives



          If time permits I generally try to do enough simulations to get the standard error below about a pixel in my display (or even smaller). In practice something below half a percent of the height the plot in a small image is generally plenty; you can probably get away with less precision than that.



          If you have done fewer simulations you can still fit a curve using a binomial model (or even weighted least squares may suffice).



          There's some discussion of smoothing power curves here How to draw the estimated power curve of a test?. There's a bit of an art to doing it well; with large samples, I often tend to work with $Phi^-1(p)$ when trying to smooth; precisely what I do depends on the circumstances -- often something simple will be sufficient but sometimes more sophisticated approaches are needed to get a good curve. You should take advantage of known facts in producing a curve. [Also see some of the discussion here]






          share|cite|improve this answer






















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "65"
            ;
            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: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f367125%2fhow-to-graph-wilcoxon-test-power-r%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            In cases where you don't know a way to compute power algebraically, you can use simulation. (That's how the power curves were obtained in the plot you show.)



            To compute a single point on the power curve you need a completely specified alternative. In the case of a Wilcoxon-Mann-Whitney test you need to specify the sample sizes, the distribution(s) - you said normal - and then the parameters - the means, and the variances in the case of the normal.



            You simulate many samples at a specific alternative and compute the sample rejection rate (in order to approximate the power at that point).



            Then you vary one of those specified things to get other points on the curve. In the case in the question (two sample location difference) it's the difference in population means (population locations more generally but I'll keep saying means) we want to look at power against.



            In that two sample case case, one mean is held constant (generally at 0 for normals) while the other is varied.



            You'll obtain a series of points each of which produces a (binomial) estimate of a probability -- the rejection rate at that point.



            See the purple points in the second plot here;
            plot of power for the one-sample t and signed rank test at the normal with n=4



            Normally you'd want to do a few more points, though. For the Wilcoxon-Mann-Whitney, there's an example of power computed at a larger set of points here:



            Plot of power at various shifts for normal samples under shift alternative at n=20 in each group



            Typically you want to end up with a curve rather than a set of points. We have a curve for the t in that first plot above because this is straightforward (indeed R has a built-in function for it which was used to produce that curve).



            If you have done many simulations, the standard error will be so small that you can treat it as known (which is why my simulated points don't tend to show standard error bars; they're usually inside the plotted points) and just join the points with a smooth curve; see the last plot at the above link:



            power curves for the Shapiro-Wilk and Lilliefors tests of general normality against increasingly skew gamma alternatives



            If time permits I generally try to do enough simulations to get the standard error below about a pixel in my display (or even smaller). In practice something below half a percent of the height the plot in a small image is generally plenty; you can probably get away with less precision than that.



            If you have done fewer simulations you can still fit a curve using a binomial model (or even weighted least squares may suffice).



            There's some discussion of smoothing power curves here How to draw the estimated power curve of a test?. There's a bit of an art to doing it well; with large samples, I often tend to work with $Phi^-1(p)$ when trying to smooth; precisely what I do depends on the circumstances -- often something simple will be sufficient but sometimes more sophisticated approaches are needed to get a good curve. You should take advantage of known facts in producing a curve. [Also see some of the discussion here]






            share|cite|improve this answer


























              up vote
              3
              down vote













              In cases where you don't know a way to compute power algebraically, you can use simulation. (That's how the power curves were obtained in the plot you show.)



              To compute a single point on the power curve you need a completely specified alternative. In the case of a Wilcoxon-Mann-Whitney test you need to specify the sample sizes, the distribution(s) - you said normal - and then the parameters - the means, and the variances in the case of the normal.



              You simulate many samples at a specific alternative and compute the sample rejection rate (in order to approximate the power at that point).



              Then you vary one of those specified things to get other points on the curve. In the case in the question (two sample location difference) it's the difference in population means (population locations more generally but I'll keep saying means) we want to look at power against.



              In that two sample case case, one mean is held constant (generally at 0 for normals) while the other is varied.



              You'll obtain a series of points each of which produces a (binomial) estimate of a probability -- the rejection rate at that point.



              See the purple points in the second plot here;
              plot of power for the one-sample t and signed rank test at the normal with n=4



              Normally you'd want to do a few more points, though. For the Wilcoxon-Mann-Whitney, there's an example of power computed at a larger set of points here:



              Plot of power at various shifts for normal samples under shift alternative at n=20 in each group



              Typically you want to end up with a curve rather than a set of points. We have a curve for the t in that first plot above because this is straightforward (indeed R has a built-in function for it which was used to produce that curve).



              If you have done many simulations, the standard error will be so small that you can treat it as known (which is why my simulated points don't tend to show standard error bars; they're usually inside the plotted points) and just join the points with a smooth curve; see the last plot at the above link:



              power curves for the Shapiro-Wilk and Lilliefors tests of general normality against increasingly skew gamma alternatives



              If time permits I generally try to do enough simulations to get the standard error below about a pixel in my display (or even smaller). In practice something below half a percent of the height the plot in a small image is generally plenty; you can probably get away with less precision than that.



              If you have done fewer simulations you can still fit a curve using a binomial model (or even weighted least squares may suffice).



              There's some discussion of smoothing power curves here How to draw the estimated power curve of a test?. There's a bit of an art to doing it well; with large samples, I often tend to work with $Phi^-1(p)$ when trying to smooth; precisely what I do depends on the circumstances -- often something simple will be sufficient but sometimes more sophisticated approaches are needed to get a good curve. You should take advantage of known facts in producing a curve. [Also see some of the discussion here]






              share|cite|improve this answer
























                up vote
                3
                down vote










                up vote
                3
                down vote









                In cases where you don't know a way to compute power algebraically, you can use simulation. (That's how the power curves were obtained in the plot you show.)



                To compute a single point on the power curve you need a completely specified alternative. In the case of a Wilcoxon-Mann-Whitney test you need to specify the sample sizes, the distribution(s) - you said normal - and then the parameters - the means, and the variances in the case of the normal.



                You simulate many samples at a specific alternative and compute the sample rejection rate (in order to approximate the power at that point).



                Then you vary one of those specified things to get other points on the curve. In the case in the question (two sample location difference) it's the difference in population means (population locations more generally but I'll keep saying means) we want to look at power against.



                In that two sample case case, one mean is held constant (generally at 0 for normals) while the other is varied.



                You'll obtain a series of points each of which produces a (binomial) estimate of a probability -- the rejection rate at that point.



                See the purple points in the second plot here;
                plot of power for the one-sample t and signed rank test at the normal with n=4



                Normally you'd want to do a few more points, though. For the Wilcoxon-Mann-Whitney, there's an example of power computed at a larger set of points here:



                Plot of power at various shifts for normal samples under shift alternative at n=20 in each group



                Typically you want to end up with a curve rather than a set of points. We have a curve for the t in that first plot above because this is straightforward (indeed R has a built-in function for it which was used to produce that curve).



                If you have done many simulations, the standard error will be so small that you can treat it as known (which is why my simulated points don't tend to show standard error bars; they're usually inside the plotted points) and just join the points with a smooth curve; see the last plot at the above link:



                power curves for the Shapiro-Wilk and Lilliefors tests of general normality against increasingly skew gamma alternatives



                If time permits I generally try to do enough simulations to get the standard error below about a pixel in my display (or even smaller). In practice something below half a percent of the height the plot in a small image is generally plenty; you can probably get away with less precision than that.



                If you have done fewer simulations you can still fit a curve using a binomial model (or even weighted least squares may suffice).



                There's some discussion of smoothing power curves here How to draw the estimated power curve of a test?. There's a bit of an art to doing it well; with large samples, I often tend to work with $Phi^-1(p)$ when trying to smooth; precisely what I do depends on the circumstances -- often something simple will be sufficient but sometimes more sophisticated approaches are needed to get a good curve. You should take advantage of known facts in producing a curve. [Also see some of the discussion here]






                share|cite|improve this answer














                In cases where you don't know a way to compute power algebraically, you can use simulation. (That's how the power curves were obtained in the plot you show.)



                To compute a single point on the power curve you need a completely specified alternative. In the case of a Wilcoxon-Mann-Whitney test you need to specify the sample sizes, the distribution(s) - you said normal - and then the parameters - the means, and the variances in the case of the normal.



                You simulate many samples at a specific alternative and compute the sample rejection rate (in order to approximate the power at that point).



                Then you vary one of those specified things to get other points on the curve. In the case in the question (two sample location difference) it's the difference in population means (population locations more generally but I'll keep saying means) we want to look at power against.



                In that two sample case case, one mean is held constant (generally at 0 for normals) while the other is varied.



                You'll obtain a series of points each of which produces a (binomial) estimate of a probability -- the rejection rate at that point.



                See the purple points in the second plot here;
                plot of power for the one-sample t and signed rank test at the normal with n=4



                Normally you'd want to do a few more points, though. For the Wilcoxon-Mann-Whitney, there's an example of power computed at a larger set of points here:



                Plot of power at various shifts for normal samples under shift alternative at n=20 in each group



                Typically you want to end up with a curve rather than a set of points. We have a curve for the t in that first plot above because this is straightforward (indeed R has a built-in function for it which was used to produce that curve).



                If you have done many simulations, the standard error will be so small that you can treat it as known (which is why my simulated points don't tend to show standard error bars; they're usually inside the plotted points) and just join the points with a smooth curve; see the last plot at the above link:



                power curves for the Shapiro-Wilk and Lilliefors tests of general normality against increasingly skew gamma alternatives



                If time permits I generally try to do enough simulations to get the standard error below about a pixel in my display (or even smaller). In practice something below half a percent of the height the plot in a small image is generally plenty; you can probably get away with less precision than that.



                If you have done fewer simulations you can still fit a curve using a binomial model (or even weighted least squares may suffice).



                There's some discussion of smoothing power curves here How to draw the estimated power curve of a test?. There's a bit of an art to doing it well; with large samples, I often tend to work with $Phi^-1(p)$ when trying to smooth; precisely what I do depends on the circumstances -- often something simple will be sufficient but sometimes more sophisticated approaches are needed to get a good curve. You should take advantage of known facts in producing a curve. [Also see some of the discussion here]







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited 4 hours ago

























                answered 4 hours ago









                Glen_b♦

                202k22381707




                202k22381707



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f367125%2fhow-to-graph-wilcoxon-test-power-r%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery