# this script creates the dataset for the regression exercise library(dplyr) library(faux) set.seed(123) n <- 100 dat <- rnorm_multi(n = n, r = .6, varnames = paste0("x", 1:2)) |> mutate(y = x1 + x2 + rnorm(n)) lm(y ~ x1 + x2, dat) |> summary() dat <- dat |> mutate( y = ifelse(runif(n) > .5, NA, y) ) lm(y ~ x1 + x2, dat) |> summary() # write.csv(dat, "exercise_01.csv", row.names = F)