Skip to content

tienmt/tobitbayes

Repository files navigation

tobitbayes

Bayesian sparse Tobit regression for censored response via Gibbs sampler. This is based on the paper:
"High-dimensional Bayesian Tobit regression for censored response with Horseshoe prior."

Installation

Install the package using:

devtools::install_github('tienmt/tobitbayes')

or install with vignettes "tutorial"

devtools::install_github(
    "tienmt/tobitbayes", 
    build_vignettes = TRUE,
    build_opts = c("--no-resave-data", "--no-manual")
)

Examples

library(tobitbayes)

# simulate data
set.seed(1)
n = 100
p = 5
X <- matrix(rnorm(n * p), n, p)
beta0 <- c(2, -1, rep(0,p-2) )
y <- X %*% beta0 + rnorm(n)

# censor the response to value c = 0
y[y < 0] <- 0

# fit the Gibbs sampler
res <- tobit_bayes(y, X)

get the posterior mean and compare it to the true beta0

(posterior_means <- colMeans(res$beta_samples))
# plot output
plot(posterior_means, type = 'h',
     main = "Posterior Means of Beta",
     ylab = "Mean")

get the selected variables from the Gibbs sampler

res$selected

About

tobitbayes: Bayesian sparse Tobit regression for censored response via Gibbs sampler

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published