set.seed(123)
n.obs <- 1e4
n.vars <- 100
n.obs.test <- 1e3
true.beta <- c(runif(15, -0.5, 0.5), rep(0, n.vars - 15))
x <- matrix(rnorm(n.obs * n.vars), n.obs, n.vars)
y <- rnorm(n.obs, sd = 3) + x %*% true.beta
fit <- oem(x = x, y = y, penalty = c("lasso", "grp.lasso"), groups = rep(1:10, each = 10))
layout(matrix(1:2, ncol = 2))
plot(fit, which.model = 1)
plot(fit, which.model = 2)
set.seed(123)
n.obs <- 1e4
n.vars <- 100
n.obs.test <- 1e3
true.beta <- c(runif(15, -0.5, 0.5), rep(0, n.vars - 15))
x <- matrix(rnorm(n.obs * n.vars), n.obs, n.vars)
y <- rnorm(n.obs, sd = 3) + x %*% true.beta
fit <- cv.oem(x = x, y = y, penalty = c("lasso", "grp.lasso"), groups = rep(1:10, each = 10))
layout(matrix(1:2, ncol = 2))
plot(fit, which.model = 1)
plot(fit, which.model = "grp.lasso")
set.seed(123)
n.obs <- 1e4
n.vars <- 100
n.obs.test <- 1e3
true.beta <- c(runif(15, -0.5, 0.5), rep(0, n.vars - 15))
x <- matrix(rnorm(n.obs * n.vars), n.obs, n.vars)
y <- rnorm(n.obs, sd = 3) + x %*% true.beta
fit <- xval.oem(x = x, y = y, penalty = c("lasso", "grp.lasso"), groups = rep(1:10, each = 10))
layout(matrix(1:4, ncol = 2))
plot(fit, which.model = 1)
plot(fit, which.model = 2)
plot(fit, which.model = 1, type = "coef")
plot(fit, which.model = 2, type = "coef")
Run the code above in your browser using DataLab