A movie to illustrate statistical concepts involved in the testing of one simple hypothesis against another. The example used is a random sample from a normal distribution whose variance is assumed to be known. The simple hypotheses relate to the value of the mean \(\mu\).

shypo(
  mu0 = 0,
  sd = 6,
  eff = sd,
  n = 10,
  a = mu0 + eff/2,
  target_alpha = 0.05,
  target_beta = 0.1,
  panel_plot = TRUE,
  hscale = NA,
  vscale = hscale,
  delta_n = 1,
  delta_a = sd/(10 * sqrt(n)),
  delta_eff = sd,
  delta_mu0 = 1,
  delta_sd = 1
)

Arguments

mu0

A numeric scalar. The value of \(\mu\) under the null hypothesis H0 with which to start the movie.

sd

A positive numeric scalar. The (common) standard deviation \(\sigma\) of the normal distributions of the data under the two hypotheses.

eff

A numeric scalar. The effect size. The amount by which the value of \(\mu\) under the alternative hypothesis is greater than the value mu0 under the null hypothesis. That is, mu1 = eff + mu0. eff must be non-negative.

n

A positive integer scalar. The sample size with which to start the movie.

a

A numeric scalar. The critical value of the test with which to start the movie. H0 is rejected if the sample mean is greater than a.

target_alpha

A numeric scalar in (0,1). The target value of the type I error to be achieved by setting a and/or n if the user asks for this using a radio button.

target_beta

A numeric scalar in (0,1). The target value of the type II error to be achieved by setting a and/or n if the user asks for this using a radio button.

panel_plot

A logical parameter that determines whether the plot is placed inside the panel (TRUE) or in the standard graphics window (FALSE). If the plot is to be placed inside the panel then the tkrplot library is required.

hscale, vscale

Numeric scalars. Scaling parameters for the size of the plot when panel_plot = TRUE. The default values are 1.4 on Unix platforms and 2 on Windows platforms.

delta_mu0, delta_eff, delta_a, delta_n, delta_sd

Numeric scalars. The respective amounts by which the values of mu0, eff, a, n and sd are increased (or decreased) after one click of the + (or -) button in the parameter window.

Value

Nothing is returned, only the animation is produced.

Details

The movie is based on two plots.

The top plot shows the (normal) probability density functions of the sample mean under the null hypothesis H0 (mean mu0) and the alternative hypothesis H1 (mean mu1, where mu1 > mu0), with the values of mu0 and mu1 indicated by vertical dashed lines. H0 is rejected if the sample mean exceeds the critical value a, which is indicated by a vertical black line.

The bottom plot shows how the probabilities of making a type I or type II error (alpha and beta respectively) depend on the value of a, by plotting these probabilities against a.

A parameter window enables the user to change the values of n, a, mu0, eff = mu1 - mu0 or sd by clicking the +/- buttons.

Radio buttons can be used either to:

  • set a to achieve the target type I error probability target_alpha, based on the current value of n;

  • set a and (integer) n to achieve (or better) the respective target type I and type II error probabilities of target_alpha and target_beta.

If eff = 0 then a plot will be produced even though this case is not practically meaningful. In the "set a and n to achieve target alpha and beta" case, the plot will be the same as the case "set a and n by hand" case.

See also

movies: a user-friendly menu panel.

smovie: general information about smovie.

Examples

# 1. Change a (for fixed n) to achieve alpha = 0.05
# 2. Change a and n to achieve alpha <= 0.05 and beta <= 0.1
shypo(mu0 = 0, eff = 5, n = 16, a = 2.3, delta_a = 0.01)