Skip to contents

Launches a Shiny app wrapping Pvalue.binom.sim: given a population proportion and a hypothesized proportion, it simulates many samples, tests each with an approximate or exact binomial test, and plots the resulting p-values in a histogram and QQ-plot.

Usage

ShinyPvalueBinomSim(n = 100, p = 0.5, p0 = 0.5,
                     test = c("approx", "exact"),
                     alternative = c("two.sided", "less", "greater"),
                     alpha = 0.05, B = 1000)

Arguments

n

Initial sample size.

p

Initial true population proportion.

p0

Initial hypothesized proportion (null value).

test

Initial test type, "approx" or "exact".

alternative

Initial alternative hypothesis.

alpha

Initial significance level.

B

Initial number of simulated samples.

Details

This function requires the shiny package to be installed. Use the “Refresh” button to redraw the simulation with the current settings. When p == p0, the simulated p-values should approximately follow a uniform distribution; as the true proportion moves away from the hypothesized value, the distribution of p-values shifts towards 0, illustrating power.

Value

Launches the app in non-blocking mode (via startApp) and returns a ShinyAppHandle immediately, so the R console remains available while the app runs in the background. Use handle$stop() to stop the app.

Author

Greg Snow 538280@gmail.com

Examples

if(interactive()) {
  h <- ShinyPvalueBinomSim()
  # h$stop() # run this when finished with the app
}