<- 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
7 OLS Regression
Show the code
regression_vis(df, plot_regression = TRUE, plot_residuals = df$residual == max(df$residual))
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
ℹ The deprecated feature was likely used in the VisualStats package.
Please report the issue at <https://github.com/jbryer/VisualStats/issues>.
Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the VisualStats package.
Please report the issue at <https://github.com/jbryer/VisualStats/issues>.
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)