shrinkage_regression_plot: Plot the MC chain of regression coeffecients compared to OLS.

Description Usage Arguments Examples

Description

Plot the MC chain of regression coeffecients comparet to OLS using 95% HPD confidence intervals.

Usage

1
2
3
4
5
6
horseshoe_regression_plot <- function(
  beta,
  Y,
  X,
  main = "Horseshoe Prior",
  ylim = NULL)

Arguments

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

Examples

 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)

dcbdan/s525 documentation built on May 19, 2019, 10:48 p.m.