Regresi Linier Sederhana

Model regresi linier sederhana adalah: \[y = \beta_0 + \beta_1 x + \varepsilon\]

Misalkan tersedia data:

x <- c(3.5, 5, 8.5, 6, 10, 9)
y <- c(50, 70, 100, 60, 150, 150)

Model regresi dapat diestimasi dengan sebuah garis regresi: \[\hat{y} = b_0 + b_1 x\] dimana

\(b_1 = \displaystyle \frac{\displaystyle n\sum_{i=1}^n x_iy_i-\left(\sum_{i=1}^n x_i\right)\left(\sum_{i=1}^n y_i\right)}{\displaystyle n\sum_{i=1}^n x_i^2-\left(\sum_{i=1}^n x_i\right)^2}\)

b1 <- ((length(x)*sum(x*y))-(sum(x)*sum(y)))/
      ((length(x)*sum(x^2))-sum(x)^2)

dan

\(b_0 = \bar{y}-b_1\bar{x}\)

b0 <- mean(y) - (b1*mean(x))

Fungsi lm untuk regresi linier

rls <- lm (y~x)
summary (rls)

Sumber: Regresi Linier Sederhana