two.grp.random.a0: Model fitting for two groups (treatment and control group, no...

View source: R/two_grp_random.R

two.grp.random.a0R Documentation

Model fitting for two groups (treatment and control group, no covariates) with random a0

Description

Model fitting using normalized power priors for two groups (treatment and control group, no covariates) with random a_0

Usage

two.grp.random.a0(
  data.type,
  y.c,
  n.c,
  v.c,
  historical,
  prior.mu.c.shape1 = 1,
  prior.mu.c.shape2 = 1,
  prior.a0.shape1 = rep(1, 10),
  prior.a0.shape2 = rep(1, 10),
  lower.limits = rep(0, 10),
  upper.limits = rep(1, 10),
  slice.widths = rep(0.1, 10),
  nMC = 10000,
  nBI = 250
)

Arguments

data.type

Character string specifying the type of response. The options are "Normal", "Bernoulli", "Poisson" and "Exponential".

y.c

Sum of responses for the control group.

n.c

Sample size of the control group.

v.c

(For normal data only) sample variance of responses for the control group.

historical

Matrix of historical dataset(s). If data.type is "Normal", historical is a matrix with three columns:

  • The first column contains the sum of responses for the control group.

  • The second column contains the sample size of the control group.

  • The third column contains the sample variance of responses for the control group.

For all other data types, historical is a matrix with two columns:

  • The first column contains the sum of responses for the control group.

  • The second column contains the sample size of the control group.

Each row represents a historical dataset.

prior.mu.c.shape1

First hyperparameter of the initial prior for \mu_c. The default is 1. Does not apply if data.type is "Normal".

prior.mu.c.shape2

Second hyperparameter of the initial prior for \mu_c. The default is 1. Does not apply if data.type is "Normal".

prior.a0.shape1

Vector of the first shape parameters of the independent beta priors for a_0. The length of the vector should be equal to the number of historical datasets. The default is a vector of one's.

prior.a0.shape2

Vector of the second shape parameters of the independent beta priors for a_0. The length of the vector should be equal to the number of historical datasets. The default is a vector of one's.

lower.limits

Vector of lower limits for parameters to be used by the slice sampler. The length of the vector should be equal to the number of historical datasets. The default is 0 for all parameters (may not be appropriate for all situations).

upper.limits

Vector of upper limits for parameters to be used by the slice sampler. The length of the vector should be equal to the number of historical datasets. The default is 1 for all parameters (may not be appropriate for all situations).

slice.widths

Vector of initial slice widths used by the slice sampler. The length of the vector should be equal to the number of historical datasets. The default is 0.1 for all parameter (may not be appropriate for all situations).

nMC

Number of iterations (excluding burn-in samples) for the slice sampler or Gibbs sampler. The default is 10,000.

nBI

Number of burn-in samples for the slice sampler or Gibbs sampler. The default is 250.

Details

If data.type is "Bernoulli", "Poisson" or "Exponential", a single response from the treatment group is assumed to follow Bern(\mu_t), Pois(\mu_t) or Exp(rate=\mu_t), respectively, where \mu_t is the mean of responses for the treatment group. If data.type is "Normal", a single response from the treatment group is assumed to follow N(\mu_t, \tau^{-1}) where \tau is the precision parameter. The distributional assumptions for the control group data are analogous.

If data.type is "Bernoulli", the initial prior for \mu_t is beta(prior.mu.t.shape1, prior.mu.t.shape2). If data.type is "Poisson", the initial prior for \mu_t is Gamma(prior.mu.t.shape1, rate=prior.mu.t.shape2). If data.type is "Exponential", the initial prior for \mu_t is Gamma(prior.mu.t.shape1, rate=prior.mu.t.shape2). The initial priors used for the control group data are analogous.

If data.type is "Normal", historical datasets are assumed to have the same precision parameter \tau as the current dataset for computational simplicity. The initial prior for \tau is the Jeffery's prior, \tau^{-1}. The initial prior for the \mu_c is the uniform improper prior. Posterior samples of \mu_c and \tau are obtained through Gibbs sampling.

Independent beta(prior.a0.shape1,prior.a0.shape1) priors are used for a_0. Posterior samples of a_0 are obtained through slice sampling. The default lower limits for the parameters are 0. The default upper limits for the parameters are 1. The default slice widths for the parameters are 0.1. The defaults may not be appropriate for all situations, and the user can specify the appropriate limits and slice width for each parameter.

Value

The function returns a S3 object with a summary method. If data.type is "Normal", posterior samples of \mu_c, \tau and a_0 are returned. For all other data types, posterior samples of \mu_c and a_0 are returned. If there are K historical datasets, then a_0 = (a_{01},\cdots,a_{0K}).

References

Neal, Radford M. Slice sampling. Ann. Statist. 31 (2003), no. 3, 705–767.

See Also

power.two.grp.random.a0

Examples


data.type <- "Bernoulli"
y.c <- 70
n.c <- 100

# Simulate three historical datasets
historical <- matrix(0, ncol=2, nrow=3)
historical[1,] <- c(70, 100)
historical[2,] <- c(60, 100)
historical[3,] <- c(50, 100)

# Set parameters of the slice sampler
lower.limits <- rep(0, 3) # The dimension is the number of historical datasets
upper.limits <- rep(1, 3)
slice.widths <- rep(0.1, 3)

set.seed(1)
result <- two.grp.random.a0(data.type=data.type, y.c=y.c, n.c=n.c, historical=historical,
                            lower.limits=lower.limits, upper.limits=upper.limits,
                            slice.widths=slice.widths, nMC=10000, nBI=250)
summary(result)

BayesPPD documentation built on Nov. 26, 2023, 1:07 a.m.