| sign_test_b | R Documentation |
Sign test for paired data.
sign_test_b(
x,
y,
p0 = 0.5,
prior = "jeffreys",
prior_shapes,
ROPE,
CI_level = 0.95,
plot = TRUE
)
x |
Either numeric vector or binary vector. If the former,
|
y |
Optional numeric vector to pair with |
p0 |
|
prior |
Either "jeffreys" (Beta(1/2,1/2)) or "uniform" (Beta(1,1)). This is ignored if prior_shapes is provided. |
prior_shapes |
Vector of length two, giving the shape parameters
for the beta distribution that will act as the prior on the probability
that |
ROPE |
positive numeric of length 1 or 2. If of length 1, then ROPE
is taken to be |
CI_level |
The posterior probability to be contained in the
credible interval for |
plot |
logical. Should a plot be shown? |
The sign test looks at z_i:= 1_{[x_i > y_i]} rather than trying to model the
distribution of (x_i,y_i). sign_test_b then uses the fact that
z_i \overset{iid}{\sim} Bernoulli(p)
and then makes inference on p. The prior on p is
p \sim Beta(a,b),
where a and b are given by the argument prior_shapes. If
prior_shapes is missing and prior = "jeffreys", then a
Jeffreys prior will be used (Beta(1/2,1/2)), and if
prior = "uniform", then a uniform prior will be used (Beta(1,1)).
(returned invisible) A list with the following:
posterior_mean: Posterior mean of the median difference
CI: Credible interval for the median difference
Pr_less_than_p: Posterior probability that the proportion of
differences that are positive is less than the argument p0.
ROPE_bounds: ROPE bounds for the proportion of differences
that are positive
ROPE: Posterior probability that the proportion of differences
which are positive falls in the ROPE
prop_plot: Prior and posterior plot
posterior_parameters: Posterior beta shape parameters for the
proportion of differences which are positive
# Single population
sign_test_b(x = rnorm(50))
## Change ROPE
sign_test_b(x = rnorm(50),
ROPE = 0.1)
## Change the prior
sign_test_b(x = rnorm(50),
prior = "uniform")
sign_test_b(x = rnorm(50),
prior_shapes = c(2,2))
## Two populations
sign_test_b(x = rnorm(50,1),
y = rnorm(50,0))
## Change reference probability
sign_test_b(x = rnorm(50,1),
y = rnorm(50,0),
p0 = 0.7)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.