A simple, one-variable Bayesian linear regression model using a horseshoe prior. The horseshoe, just as the LASSO, can be used when the slopes are assumed to be sparse. According to the original publication:
its flat, Cauchy-like tails allow strong signals to remain large [...] a posteriori. Yet its infinitely tall spike at the origin provides severe shrinkage for the zero elements
horseshoe <- function (tau = 1, dim = NULL) { lambda <- cauchy(0, 1, truncation = c(0, Inf), dim = dim) sd <- tau ^ 2 * lambda ^ 2 normal(0, sd, dim = dim) } # variables & priors int <- variable() sd <- inverse_gamma(1, 1) coef <- horseshoe() # linear predictor mu <- int + coef * attitude$complaints # observation model distribution(attitude$rating) <- normal(mu, sd)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.