Aplikasi ini menggunakan pemodelan regresi linier sederhana dari dataset mtcars:
# Model regresi linier MPG terhadap Berat (wt)
fit <- lm(mpg ~ wt, data = mtcars)
summary(fit)$coefficients
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 37.285126 1.877627 19.857575 8.241799e-19
## wt -5.344472 0.559101 -9.559044 1.293959e-10
library(ggplot2)
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(color = "blue", size = 3) +
geom_smooth(method = "lm", col = "red") +
labs(title = "Regresi MPG vs Berat Kendaraan", x = "Berat (1000 lbs)", y = "MPG")
## `geom_smooth()` using formula 'y ~ x'
