# NOT RUN {
## don't test because this can take some time to run
library(SuperLearner)
library(gam)
n <- 100
p <- 2
## generate the data
x <- data.frame(replicate(p, stats::runif(n, -5, 5)))
## apply the function to the x's
smooth <- (x[,1]/5)^2*(x[,1]+7)/5 + (x[,2]/3)^2
## generate Y ~ Normal (smooth, 1)
y <- as.matrix(smooth + stats::rnorm(n, 0, 1))
## set up a library for SuperLearner
learners <- c("SL.mean", "SL.gam")
## -----------------------------------------
## using Super Learner
## -----------------------------------------
set.seed(4747)
est <- sp_vim(Y = y, X = x, V = 5, type = "r_squared", SL.library = learners, alpha = 0.05)
# }
Run the code above in your browser using DataLab