Skip to contents

Launches a Shiny app wrapping Pvalue.norm.sim: given population and hypothesized parameters, it simulates many datasets, analyzes each with a z- or t-test, and plots the resulting p-values in a histogram and QQ-plot.

Usage

ShinyPvalueNormSim(n = 50, mu = 10, mu0 = 10, sigma = 3, sigma0 = 3,
                    test = c("z", "t"),
                    alternative = c("two.sided", "less", "greater"),
                    alpha = 0.05, B = 1000)

Arguments

n

Initial sample size.

mu

Initial true population mean.

mu0

Initial hypothesized mean (null value).

sigma

Initial true population standard deviation.

sigma0

Initial hypothesized standard deviation (used for the z-test).

test

Initial test type, "z" or "t".

alternative

Initial alternative hypothesis.

alpha

Initial significance level.

B

Initial number of simulated datasets.

Details

This function requires the shiny package to be installed. Use the “Refresh” button to redraw the simulation with the current settings. When mu == mu0 and other assumptions are met, the simulated p-values should follow a uniform distribution; as the true mean moves away from the hypothesized value, the distribution of p-values shifts towards 0, illustrating power. The demo can also be used to explore what happens when assumptions (such as equal variance) are violated.

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 <- ShinyPvalueNormSim()
  # h$stop() # run this when finished with the app
}