bayesmiss: Bayesian regression with missing covariates

Description Usage Arguments Details Value

Description

bayesmiss generates JAGS model code and an R script to perform Bayesian regression, allowing for missingness in covariates.

Usage

1
bayesmiss(originaldata, smoutcome, method, order, factorcov = TRUE)

Arguments

originaldata

the data frame upon which the analysis is to be performed.

smoutcome

the name of the column corresponding to the outcome variable of the substantive model.

method

a vector of strings specifying the model type to use for each of the columns in originaldata.

order

a vector specifying the order in which the joint model should be constructed. e.g. c(0,0,1,2) specifies that the joint model be factorized as f(v3|v1,v2)f(v4|v1,v2,v3).

Details

bayesmiss faciliates running Bayesian regression models in which there are missing values in some of the covariates. The function generates two files, one a JAGS model file, and one a R script file. The JAGS model defines the user's substantive model, and models as required to handle the missing covariates, and any auxiliary variables if present. The R script file generated contains commands to generate the required JAGS data and parameter objects, and code required to fit the model. Note that bayesmiss does not actually run this code. Instead, the user is advised to check the model specification and R script to ensure it is as desired. The R code can then be run to fit the model.

The method argument specifies what model type to use for each variable. Currently the possible values are:

The element corresponding to the outcome of the substantive model should be specified as desired according to the desired type of substantive model. A model type must be specified for all auxiliary variables. Entries corresponding to variables which are covariates in the substantive model and which are fully observed should be specified as "". Variables modelled using mlogit or ologit should be stored as numeric (not factors), and coded 1:K, where K is the number of categories.

The order argument is used to specify the order in which the joint model is factorized. Elements corresponding to variables which are covariates in the substantive model should be specified as 0. Substantive model covariates which have missing values should come next. The substantive model outcome variable should come next, followed by any auxiliary variables.

Note that the MCMC options in the call to jags are just suggested defaults. It is up to the user to ensure, via the usual diagnostics for MCMC, that a sufficient number of iterations have been run to ensure convergence of the chains. In particular, the code generated by bayesmiss does not specify initial values for parameters. To assess convergence general advice is to choose different overdispersed initial values for each chain.

If it is desired to add interactions or non-linear covariate effects, first run bayesmiss omitting these terms, and then modify the JAGS code file and R code specifying the priors as needed.

Value

bayesmiss generates two files in the current working directory: bayesmissmod.bug is a JAGS model file for the constructed model, and bayesmissRscript.r is an R file containing R code for generating the required JAGS parameters and data objects, and a call to the jags function of the R2jags package for fitting the model.


jwb133/bayesmiss documentation built on May 20, 2019, 5:21 a.m.