A Minimal Example

We examine the relationship between speed and stopping distance using a linear regression model: $Y = \beta_0 + \beta_1 x + \epsilon$.

par(mar = c(4, 4, 1, 1), mgp = c(2, 1, 0), cex = 0.8)
plot(cars, pch = 20, col = 'darkgray')
fit <- lm(dist ~ speed, data = cars)
abline(fit, lwd = 2)

The slope of a simple linear regression is r coef(fit)[2].



Try the parsermd package in your browser

Any scripts or data that you put into this service are public.

parsermd documentation built on May 29, 2024, 6:39 a.m.