This function uses Bayesian Additive Regression Trees (BART) to extrapolate survey data to a level of geographic aggregation at which the original survey was not sampled to be representative of.
This is a modified version of the barp
function from the BARP to allow for seed fixation.(https://github.com/jbisbee1/BARP)
barps(
y,
x,
dat,
census,
geo.unit,
algorithm = "BARP",
setSeed = NULL,
proportion = "None",
cred_int = c(0.025, 0.975),
BSSD = FALSE,
nsims = 200,
...
)
Returns an object of class BARP
, containing a list of the following components:
A data.frame
where each row corresponds to the geographic unit of interest and the columns summarize the predicted outcome and the upper and lower bounds for the given credible interval (cred_int
).
A bartMachine
object.
A data.frame
containing the cross-validation risk for each algorithm and the associated weight used in the ensemble predictions. Only useful when multiple algorithms are used.
Data containing the estimates and credible intervals for each observation in the input census dataset.
The random seed value employed during model estimation using bartMachine.
The number of observations in each combination of features.
The names of the explanatory variables included in the model.
Outcome of interest. Should be a character of the column name containing the variable of interest.
Prognostic covariates. Should be a vector of column names corresponding to the covariates used to predict the outcome variable of interest.
Survey data containing the x and y column names. The explanatory variables X included in the model must be converted to factors prior to input.
Census data containing the x column names. It must also have the same structure as X. If the user provides raw census data, BARP will calculate proportions for each unique bin of x covariates. Otherwise, the researcher must calculate bin proportions and indicate the column name that contains the proportions, either as percentages or as raw counts.
The column name corresponding to the unit at which outcomes should be aggregated.
Algorithm for predicting opinions. Can be any algorithm(s) included in the SuperLearner package. If multiple algorithms are listed, predicted opinions are provided for each separately, as well as for the weighted ensemble. Defaults to BARP
which implements Bayesian Additive Regression Trees via bartMachine
.
Seed to control random number generation.
The column name corresponding to the proportions for covariate bins in the Census data. If left to the default None
value, BARP assumes raw census data and estimates bin proportions automatically.
A vector giving the lower and upper bounds on the credible interval for the predictions.
Calculate bootstrapped standard deviation. Defaults to FALSE
in which case the standard deviation is generated by BART's default.
The number of bootstrap simulations.
Additional arguments to be passed to bartMachine or SuperLearner.
barps
is used to implement Bayesian Additive Regression Trees based on the bartMachine package.
For detailed options, see https://CRAN.R-project.org/package=bartMachine.
barps
also uses the SuperLearner package to implement alternative regularizers.
For more details, see https://CRAN.R-project.org/package=SuperLearner.