sim_regression = function(n, beta0 = 2, beta1 = 3) {
sim_data = tibble(
x = rnorm(n, mean = 1, sd = 1),
y = beta0 + beta1 * x + rnorm(n, 0, 1)
)
ls_fit = lm(y ~ x, data = sim_data)
tibble(
beta0_hat = coef(ls_fit)[1],
beta1_hat = coef(ls_fit)[2]
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.