Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_sigsqs

Get Posterior Error Variance Estimates


Description

Returns the posterior estimates of the error variance from the Gibbs samples with an option to create a histogram of the posterior estimates of the error variance with a credible interval overlaid.

Usage

get_sigsqs(bart_machine, after_burn_in = T, 
plot_hist = F, plot_CI = .95, plot_sigma = F)

Arguments

bart_machine

An object of class “bartMachine”.

after_burn_in

If TRUE, only the σ^2 draws after the burn-in period are returned.

plot_hist

If TRUE, a histogram of the posterior σ^2 draws is generated.

plot_CI

Confidence level for credible interval on histogram.

plot_sigma

If TRUE, plots σ instead of σ^2.

Value

Returns a vector of posterior σ^2 draws (with or without the burn-in samples).

Author(s)

Adam Kapelner and Justin Bleich

See Also

Examples

## Not run: 
#generate Friedman data
set.seed(11)
n  = 300 
p = 5
X = data.frame(matrix(runif(n * p), ncol = p))
y = 10 * sin(pi* X[ ,1] * X[,2]) +20 * (X[,3] -.5)^2 + 10 * X[ ,4] + 5 * X[,5] + rnorm(n)

##build BART regression model
bart_machine = bartMachine(X, y)

#get posterior sigma^2's after burn-in and plot
sigsqs = get_sigsqs(bart_machine, plot_hist = TRUE)

## End(Not run)

bartMachine

Bayesian Additive Regression Trees

v1.2.6
GPL-3
Authors
Adam Kapelner and Justin Bleich (R package)
Initial release
2020-12-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.