a <- 2; b <- 1; c <- 3
x <- seq(-3, 3, length.out = 1000)
plot(x, dlasso(x, a, b, c, logarithm = FALSE), type = 'l')
r <- rlasso(1000, a, b, c)
hist(r, breaks = 50, probability = TRUE, col = "grey", border = "white")
lines(x, dlasso(x, a, b, c, logarithm = FALSE), col = "blue")
plasso(0, a, b, c)
qlasso(0.25, a, b, c)
elasso(a, b, c)
vlasso(a, b, c)
mlasso(a, b, c)
MillsRatio(2)
# The Modified_Hans_Gibbs() function uses the Lasso distribution to draw
# samples from the full conditional distribution of the regression coefficients.
y <- 1:20
X <- matrix(c(1:20,12:31,7:26),20,3,byrow = TRUE)
a1 <- b1 <- u1 <- v1 <- 0.01
sigma2_init <- 1
lambda_init <- 0.1
beta_init <- rep(1, ncol(X))
nsamples <- 1000
verbose <- 100
Output_Hans <- Modified_Hans_Gibbs(
X, y, a1, b1, u1, v1,
nsamples, beta_init, lambda_init, sigma2_init, verbose
)
colMeans(Output_Hans$mBeta)
mean(Output_Hans$vlambda2)
Output_PC <- Modified_PC_Gibbs(
X, y, a1, b1, u1, v1,
nsamples, lambda_init, sigma2_init, verbose)
colMeans(Output_PC$mBeta)
mean(Output_PC$vlambda2)
Run the code above in your browser using DataLab