n <- 5e2
x1 <- rnorm(n, sd = 2)
x2 <- rnorm(n)
y <- x1 + cos(x1) + rnorm(n, sd = 0.5**.5)
d0 <- data.frame(y, x1, x2)
lr <- learner_gam(y ~ s(x1) + x2)
lr$estimate(d0)
if (interactive()) {
plot(lr$fit)
}
Run the code above in your browser using DataLab