15.2 Linear regression with a continuous predictor

Simulate \(y\) data for the simple linear regression model with one continuous predict \(x_1\), \[y \sim N(\mu, \sigma^2), \\ \quad \mu = \beta_0 + \beta_1x + \epsilon, \quad \epsilon \sim N(0, .1^2),\]

and then plot.

Code
dg$y = 0 + 2*x1 + rnorm(n, 0, .1)

g = ggplot(dg, 
           aes(x1, y))+
  geom_point(alpha = 0.1)

g %>% 
  pub(xlim = c(0,1))

[1] 49.99122
[1] 80
[1] 20
[1] 149.9912