View source: R/simple_hypotheses.R
shypo | R Documentation |
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
)
mu0 |
A numeric scalar. The value of |
sd |
A positive numeric scalar. The (common) standard deviation
|
eff |
A numeric scalar. The effect size. The amount by which
the value of |
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
|
target_alpha |
A numeric scalar in (0,1). The target value of the
type I error to be achieved by setting |
target_beta |
A numeric scalar in (0,1). The target value of the
type II error to be achieved by setting |
panel_plot |
A logical parameter that determines whether the plot
is placed inside the panel ( |
hscale , vscale |
Numeric scalars. Scaling parameters for the size
of the plot when |
delta_mu0 , delta_eff , delta_a , delta_n , delta_sd |
Numeric scalars. The
respective amounts by which the values of |
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.
Nothing is returned, only the animation is produced.
movies
: a user-friendly menu panel.
smovie
: general information about smovie.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.