glm.leap {hdbayes}R Documentation

Posterior of Latent Exchangeability Prior (LEAP)

Description

Sample from the posterior distribution of a GLM using the LEAP by Alt et al. (2023).

Usage

glm.leap(
  formula,
  family,
  data.list,
  K = 2,
  prob.conc = NULL,
  offset.list = NULL,
  beta.mean = NULL,
  beta.sd = NULL,
  disp.mean = NULL,
  disp.sd = NULL,
  iter_warmup = 1000,
  iter_sampling = 1000,
  chains = 4,
  ...
)

Arguments

formula

a two-sided formula giving the relationship between the response variable and covariates.

family

an object of class family. See ?stats::family.

data.list

a list of two data.frames giving the current data followed by one historical data set.

K

the desired number of classes to identify. Defaults to 2.

prob.conc

a scalar or a vector of length K giving the concentration parameters for Dirichlet prior. If length == 2, a beta(prob.conc[1], prob.conc[2]) prior is used. If a scalar is provided, prob.conc will be a vector of repeated elements of the given scalar. Defaults to a vector of 1s.

offset.list

a list of matrices giving the offset for current data followed by historical data. For each matrix, the number of rows corresponds to observations and columns correspond to classes. Defaults to a list of matrices of 0s.

beta.mean

a ⁠p x K⁠ matrix of mean parameters for initial prior on regression coefficients (including intercept). Defaults to a matrix of 0s.

beta.sd

a ⁠p x K⁠ matrix of sd parameters for the initial prior on regression coefficients (including intercept). Defaults to a matrix of 10s.

disp.mean

a scalar or a vector whose dimension is equal to the number of classes (K) giving the means for the half-normal hyperpriors on the dispersion parameters. If a scalar is provided, disp.mean will be a vector of repeated elements of the given scalar. Defaults to a vector of 0s.

disp.sd

a scalar or a vector whose dimension is equal to the number of classes (K) giving the sds for the half-normal hyperpriors on the dispersion parameters. If a scalar is provided, same as for disp.mean. Defaults to a vector of 10s.

iter_warmup

number of warmup iterations to run per chain. Defaults to 1000. See the argument iter_warmup in sample() method in cmdstanr package.

iter_sampling

number of post-warmup iterations to run per chain. Defaults to 1000. See the argument iter_sampling in sample() method in cmdstanr package.

chains

number of Markov chains to run. Defaults to 4. See the argument chains in sample() method in cmdstanr package.

...

arguments passed to sample() method in cmdstanr package (e.g. seed, refresh, init).

Details

The LEAP discounts the historical data by identifying the most relevant individuals from the historical data. It is equivalent to a prior induced by the posterior of a finite mixture model for the historical data set.

Value

The function returns an object of class draws_df giving posterior samples.

References

Alt, E. M., Chang, X., Jiang, X., Liu, Q., Mo, M., Xia, H. M., and Ibrahim, J. G. (2023). LEAP: The latent exchangeability prior for borrowing information from historical data. arXiv preprint.

Examples

data(actg019)
data(actg036)
# take subset for speed purposes
actg019 = actg019[1:100, ]
actg036 = actg036[1:50, ]
if (instantiate::stan_cmdstan_exists()) {
  glm.leap(
    formula = outcome ~ scale(age) + race + treatment + scale(cd4),
    family = binomial('logit'),
    data.list = list(actg019, actg036),
    K = 2,
    chains = 1, iter_warmup = 500, iter_sampling = 1000
  )
}

[Package hdbayes version 0.0.3 Index]