data(acs_dat)
acs_small <- as.data.frame(acs_dat[1:500, ])
example_control <- list(n_iter = 50, burn_in = 25, progress = FALSE)
fit_linear <- fit_fh(
MedInc ~ SNAPRate + PovRate + White + Black + Hispanic + Asian,
sampling_variance = MedIncSE^2,
data = acs_small,
method = "linear",
control = example_control
)
X <- model.matrix(
MedInc ~ SNAPRate + PovRate + White + Black + Hispanic + Asian,
data = acs_small
)
fit_matrix <- fit_fh(
y = acs_small$MedInc,
X = X,
sampling_variance = acs_small$MedIncSE^2,
method = "linear",
control = example_control
)
fit_rnn <- fit_fh(
MedInc ~ .,
sampling_variance = MedIncSE^2,
data = acs_small,
method = "rnn",
control = example_control
)
fit_bart <- fit_fh(
MedInc ~ SNAPRate + PovRate + White,
sampling_variance = MedIncSE^2,
data = acs_small,
method = "bart",
control = example_control
)
# The default formula intercept is the first model-matrix column and is not
# included in BART variable importance.
fit_bart$variable_importance
Run the code above in your browser using DataLab