set.seed(1)
x <- matrix(rnorm(50000), nrow=50)
y <- rnorm(50, mean=x[,1])
weights <- adaptive.weights(x, y)
if (requireNamespace("glmnet", quietly = TRUE)) {
res <- glmnet::glmnet(x, y, penalty.factor=weights$weights)
head(res)
}
Run the code above in your browser using DataLab