Input Data

# Data dari tabel
BB   <- c(60, 60, 50, 50, 47, 46, 38, 44, 40, 48, 55, 50, 42)
TB   <- c(155, 159, 158, 153, 151, 153, 145, 158, 155, 154, 156, 150, 150)
LILA <- c(27, 27, 23, 23, 23, 23, 20, 23, 24, 20, 25, 25, 23)

data <- data.frame(BB, TB, LILA)
data
##    BB  TB LILA
## 1  60 155   27
## 2  60 159   27
## 3  50 158   23
## 4  50 153   23
## 5  47 151   23
## 6  46 153   23
## 7  38 145   20
## 8  44 158   23
## 9  40 155   24
## 10 48 154   20
## 11 55 156   25
## 12 50 150   25
## 13 42 150   23

Model Regresi Linier Berganda

# Membentuk model regresi
model <- lm(LILA ~ BB + TB, data = data)
summary(model)
## 
## Call:
## lm(formula = LILA ~ BB + TB, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4650 -0.7475  0.0266  0.9104  2.1766 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  3.22656   19.08969   0.169   0.8691  
## BB           0.21331    0.07786   2.740   0.0208 *
## TB           0.06493    0.13630   0.476   0.6440  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.537 on 10 degrees of freedom
## Multiple R-squared:  0.5724, Adjusted R-squared:  0.4868 
## F-statistic: 6.692 on 2 and 10 DF,  p-value: 0.0143

Persamaan Regresi

# Ambil koefisien
b0 <- coef(model)[1]
b1 <- coef(model)[2]
b2 <- coef(model)[3]

# Tampilkan persamaan
cat("Persamaan regresi: LILA =",
    round(b0, 4), "+", round(b1, 4), "* BB +", round(b2, 4), "* TB\n")
## Persamaan regresi: LILA = 3.2266 + 0.2133 * BB + 0.0649 * TB

Koefisien Determinasi (R-squared)

r2 <- summary(model)$r.squared
cat("Koefisien Determinasi (R^2) =", round(r2, 4), "\n")
## Koefisien Determinasi (R^2) = 0.5724

Uji Serentak (F-test)

fstat <- summary(model)$fstatistic
f_value <- fstat[1]
df1 <- fstat[2]
df2 <- fstat[3]
p_value <- pf(f_value, df1, df2, lower.tail = FALSE)

cat("F-statistic =", round(f_value, 3),
    "dengan df =", df1, "dan", df2,
    "serta p-value =", round(p_value, 5), "\n")
## F-statistic = 6.692 dengan df = 2 dan 10 serta p-value = 0.0143

Interpretasi

Misalkan α = 0,05
if (p_value < 0.05) {
  cat("Kesimpulan: Secara serentak, variabel BB dan TB berpengaruh signifikan terhadap LILA (p-value < 0.05).\n")
} else {
  cat("Kesimpulan: Secara serentak, variabel BB dan TB tidak berpengaruh signifikan terhadap LILA (p-value >= 0.05).\n")
}
## Kesimpulan: Secara serentak, variabel BB dan TB berpengaruh signifikan terhadap LILA (p-value < 0.05).
cat("Interpretasi R^2:", round(r2*100, 2), "% variasi LILA dapat dijelaskan oleh variasi BB dan TB. Sisanya 42,76% variasi LILA dijelaskan oleh faktor lain di luar model.\n")
## Interpretasi R^2: 57.24 % variasi LILA dapat dijelaskan oleh variasi BB dan TB. Sisanya 42,76% variasi LILA dijelaskan oleh faktor lain di luar model.