<- 20
mean_x <- 40
mean_y <- 2
sd_x <- 3
sd_y <- 30
n <- 0.8
rho set.seed(2112)
<- mvtnorm::rmvnorm(n = n,
df mean = c(mean_x, mean_y),
sigma = matrix(c(sd_x^2, rho * (sd_x * sd_y),
* (sd_x * sd_y), sd_y^2), 2, 2)) |>
rho as.data.frame() |>
::mutate(cross_products = abs(V1 * V2))
dplyr<- lm(V1 ~ V2, data = df)
lm_out $prediction <- predict(lm_out)
df$residual <- resid(lm_out) df
6 OLS Regression
Show the code
regression_vis(df, plot_regression = TRUE, plot_residuals = df$residual == max(df$residual))
Show the code
regression_vis(df, plot_regression = TRUE,
plot_residuals = df$residual == max(df$residual),
plot_residuals_squared = df$residual == max(df$residual))
Show the code
regression_vis(df, plot_regression = TRUE,
plot_residuals = TRUE,
plot_residuals_squared = TRUE)