n = 10 x_mean = 0 x_sd = 1 slope = 4 intercept = 0 noise_mean = 0 noise_sd = 1 x = rnorm(n, x_mean, x_sd) y = slope * x + intercept + rnorm(n, noise_mean, noise_sd) plot(x,y) abline(intercept,slope,col="red") fit = lm(y ~ x) abline(fit, col="green")