I just want to show another two plots for the statistical power of a test, since I didn't have time for this earlier
The code to produce them is just calling the methods of the power classes, for example for the one sample t-test.
I just want to show another two plots for the statistical power of a test, since I didn't have time for this earlier
The code to produce them is just calling the methods of the power classes, for example for the one sample t-test.
Just a pre-announcement because I have a nice graph.
I am looking into tests for binomial proportions, especially equivalence (TOST) and non-inferiority tests.
SAS provides a good overview over the available methods and power for it
Power and significance levels in testing for proportions have a saw tooth pattern because the observed proportions are discrete, see for example this SAS page
Unfortunately for my unit testing, I have not found any equivalence tests for proportions in R. Currently, I'm just trying to match some examples that I found on the internet.
And here is the plot for my power function. It shows the power as a function of the sample size, for either the normal approximation or the binomial distribution, of the test for equivalence, TOST two one-sided tests. The TOST test itself is based on the normal approximation.
I merged last week a branch of mine into statsmodels that contains large parts of basic power calculations and some effect size calculations. The documentation is in this section . Some parts are still missing but I thought I have worked enough on this for a while.
(Adding the power calculation for a new test now takes approximately: 3 lines of real code, 200 lines of wrapping it with mostly boiler plate and docstrings, and 30 to 100 lines of tests.)
The first part contains some information on the implementation. In the second part, I compare the calls to the function in the R pwr package to the calls in my (statsmodels') version.
I am comparing it to the pwr package because I ended up writing almost all unit tests against it. The initial development was based on the SAS manual, I used the explanations on the G-Power website for F-tests, and some parts were initially written based on articles that I read. However, during testing I adjusted the options (and fixed bugs), so I was able to match the results to pwr, and I think pwr has just the right level of abstraction and easiness of use, that I ended up with code that is pretty close to it.
If you just want to see the examples, skip to the second part.