Description Usage Arguments Examples
Plot the MC chain of regression coeffecients comparet to OLS using 95% HPD confidence intervals.
1 2 3 4 5 6 | horseshoe_regression_plot <- function(
beta,
Y,
X,
main = "Horseshoe Prior",
ylim = NULL)
|
beta |
n x p MCMC chain of beta coeffecients. |
Y |
Y values used to generate beta; used as input to OLS regression |
X |
X values used to generate beta; used as input to OLS regression |
main |
Title of the plot |
ylim |
y range of plot |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Load the data
prostate.data = "https://web.stanford.edu/~hastie/ElemStatLearn/datasets/prostate.data"
prostate = read.table(file = "prostate.data", sep="", header = TRUE)
# Training data:
prostate_train = prostate[which(prostate$train),-10]
# Testing data:
prostate_test = prostate[which(!prostate$train),-10]
# Response:
y = prostate_train$lpsa
# Center and scale the data:
y = scale(y)
# And the predictors
X = scale(prostate_train[,names(prostate_train) != "lpsa"])
gibbs_hs <- horseshoe_regression(y, X, niter=10000)
shrinkage_regression_plot(gibbs_hs$beta, y, X)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.