PEC_norm: Predictive Expectation Criterion: Normal Model

View source: R/PEC_norm.R

PEC_normR Documentation

Predictive Expectation Criterion: Normal Model

Description

\loadmathjax

Implements the predictive expectation criterion in the normal model using the \mjseqn\ell_2 Wasserstein distance of order two.

Usage

PEC_norm(
  n,
  theta_1,
  n_1,
  theta_2,
  n_2,
  theta_D,
  n_D,
  sigma,
  v,
  plot = FALSE
)

Arguments

n

The sample size. Must be a vector of positive integers arranged in ascending order.

theta_1, n_1

The parameters of the first normal prior. Must be a finite value and a non-negative value, respectively.

theta_2, n_2

The parameters of the second normal prior. Must be a finite value and a non-negative value, respectively.

theta_D, n_D

The parameters of the design normal prior. Must be a finite value and a positive value, respectively.

sigma

A constant used to define the variance of the priors. Must be a positive value.

v

A constant used to determine the optimal sample size. Must be a value in \mjseqn(0, 1).

plot

Logical. If TRUE, a plot shows the behavior of the predictive expectation as a function of the sample size.

Details

Users can use non-informative improper priors for the first and second normal priors, whereas the design normal prior must be proper.

If the first and second normal priors are equal, the function stops with an error.

The prior variances are given by sigma squared over the prior sample sizes, that is n_1, n_2, and n_D.

Value

A list with the following components:

e_n

The predictive expectation.

t_opt

The optimal threshold.

n_opt

The optimal sample size.

Author(s)

Michele Cianfriglia michele.cianfriglia@uniroma1.it

References

Cianfriglia, M., Padellini, T., and Brutti, P. (2023). Wasserstein consensus for Bayesian sample size determination.

Examples

# Parameters of the first normal prior
prior_1 <- c(15, 25)

# Parameters of the second normal prior
prior_2 <- c(10, 15)

# Parameters of the design normal prior
prior_D <- c(13, 10)

output <- PEC_norm(n = 1:200,
                   theta_1 = prior_1[1], n_1 = prior_1[2],
                   theta_2 = prior_2[1], n_2 = prior_2[2],
                   theta_D = prior_D[1], n_D = prior_D[2],
                   sigma = 2, v = 0.1)

michelecianfriglia/SampleSizeWass documentation built on Feb. 28, 2023, 8:56 a.m.