blma_fixed: Perform Bayesian Linear Model Averaging over all of the...

View source: R/RcppExports.R

blma_fixedR Documentation

Perform Bayesian Linear Model Averaging over all of the possible linear models where //' vy is the response, covariates that may be included are in mZ and covariates which are always included are in mX.

Description

Perform Bayesian Linear Model Averaging over all of the possible linear models where //' vy is the response, covariates that may be included are in mZ and covariates which are always included are in mX.

Usage

blma_fixed(y.t, X.f, Z.f, "BIC")

Arguments

vy

The vector of responses

mX

The matrix of fixed covariates which will be included in every model

mZ

The matrix of varying covariates, which may or may not be included in each model

prior

– the choice of mixture $g$-prior used to perform Bayesian model averaging. The choices available include:

  • "BIC"– the Bayesian information criterion obtained by using the cake prior of Ormerod et al. (2017).

  • "ZE"– special case of the prior structure described by BIC and George (2011).

  • "liang_g1"– the mixture g-prior of Liang et al. (2008) with prior hyperparameter a=3 evaluated directly using Equation (10) of Greenaway and Ormerod (2018) where the Gaussian hypergeometric function is evaluated using the gsl library. Note: this option can lead to numerical problems and is only meant to be used for comparative purposes.

  • "liang_g2"– the mixture g-prior of Liang et al. (2008) with prior hyperparameter a=3 evaluated directly using Equation (11) of Greenaway and Ormerod (2018).

  • "liang_g_n_appell"– the mixture g/n-prior of Liang et al. (2008) with prior hyperparameter a=3 evaluated using the appell R package.

  • "liang_g_approx"– the mixture g/n-prior of Liang et al. (2008) with prior hyperparameter eqna=3 using the approximation Equation (15) of Greenaway and Ormerod (2018) for model with more than two covariates and numerical quadrature (see below) for models with one or two covariates.

  • "liang_g_n_quad"– the mixture g/n-prior of Liang et al. (2008) with prior hyperparameter eqna=3 evaluated using a composite trapezoid rule.

  • "robust_bayarri1"– the robust prior of Bayarri et al. (2012) using default prior hyper choices evaluated directly using Equation (18) of Greenaway and Ormerod (2018) with the gsl library.

  • "robust_bayarri2"– the robust prior of Bayarri et al. (2012) using default prior hyper choices evaluated directly using Equation (19) of Greenaway Ormerod (2018).

modelprior

The model prior to use. The choices of model prior are "uniform", "beta-binomial" or "bernoulli". The choice of model prior dictates the meaning of the parameter modelpriorvec.

modelpriorvec

If modelprior is "uniform", then the modelpriorvec is ignored and can be null.

If modelprior is "beta-binomial" then modelpriorvec should be length 2 with the first element containing alpha hyperparameter for the beta prior and the second element containing the beta hyperparameter for beta prior.

If modelprior is "bernoulli", then modelpriorvec must be of the same length as the number columns in mX. Each element i of modelpriorvec contains the prior probability of the the ith covariate being included in the model.

cores

The number of cores to use. Defaults to 1

Value

A list containing

vR2

the vector of correlations for each model

vp_gamma

the vector of number of covariates for each model

vlogBF

the vector of logs of the Bayes Factors of each model

vinclusion_prob

the vector of inclusion probabilities for each of the covariates

References

Bayarri, M. J., Berger, J. O., Forte, A., Garcia-Donato, G., 2012. Criteria for Bayesian model choice with application to variable selection. Annals of Statistics 40 (3), 1550-1577.

Greenaway, M. J., J. T. Ormerod (2018) Numerical aspects of Bayesian linear models averaging using mixture g-priors.

Liang, F., Paulo, R., Molina, G., Clyde, M. a., Berger, J. O., 2008. Mixtures of g priors for Bayesian variable selection. Journal of the American Statistical Association 103 (481), 410-423.

Ormerod, J. T., Stewart, M., Yu, W., Romanes, S. E., 2017. Bayesian hypothesis tests with diffuse priors: Can we have our cake and eat it too?

Examples

mD <- MASS::UScrime
notlog <- c(2,ncol(MASS::UScrime))
mD[,-notlog] <- log(mD[,-notlog])

for (j in 1:ncol(mD)) {
  mD[,j] <- (mD[,j] - mean(mD[,j]))/sd(mD[,j])
}

varnames <- c(
  "log(AGE)",
  "S",
  "log(ED)",
  "log(Ex0)",
  "log(Ex1)",
  "log(LF)",
  "log(M)",
  "log(N)",
  "log(NW)",
  "log(U1)",
  "log(U2)",
  "log(W)",
  "log(X)",
  "log(prison)",
  "log(time)")

vy <- mD$y
mX <- data.matrix(cbind(mD[, 1:10]))
colnames(mX) <- varnames[1:10]
mZ <- data.matrix(cbind(mD[, 11:15]))
blma_result <- blma_fixed(vy, mX, mZ, "BIC")

certifiedwaif/blma documentation built on July 8, 2023, 10:29 p.m.