Asumsi Regresi Linier Sederhana
Data
Data yang digunakan dalam praktikum ini adalah data Perusahaan toluca.
Perusahaan toluca ingin memprediksi berapa lama waktu yang dibutuhkan dalam bekerja berdasarkan banyaknya jumlah produksi yang dikerjakan.
## # A tibble: 6 × 2
## LotSize WorkHours
## <dbl> <dbl>
## 1 80 399
## 2 30 121
## 3 50 221
## 4 90 376
## 5 70 361
## 6 60 224
Eksplorasi Data
## LotSize WorkHours
## Min. : 20 Min. :113.0
## 1st Qu.: 50 1st Qu.:224.0
## Median : 70 Median :342.0
## Mean : 70 Mean :312.3
## 3rd Qu.: 90 3rd Qu.:389.0
## Max. :120 Max. :546.0
Persamaan Regresi
##
## Call:
## lm(formula = WorkHours ~ LotSize, data = toluca)
##
## Residuals:
## Min 1Q Median 3Q Max
## -83.876 -34.088 -5.982 38.826 103.528
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 62.366 26.177 2.382 0.0259 *
## LotSize 3.570 0.347 10.290 4.45e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 48.82 on 23 degrees of freedom
## Multiple R-squared: 0.8215, Adjusted R-squared: 0.8138
## F-statistic: 105.9 on 1 and 23 DF, p-value: 4.449e-10
Persaman Regresi dapat dituliskan sebagai berikut:
\(\hat{y}=b_{0}+b_{1}X\)
\(\hat{y}=62.366+3.570X\)
Asumsi 1: Rata-rata galat diasumsikan bernilai nol
plot(toluca$LotSize,model2$residuals,
xlab="Lotsize (X)",ylab="Residuals",
main="Plot Uji Asumsi Rata-rata Galat bernilai nol")
Asumsi 2: Galat saling bebas
## LotSize WorkHours c
## 1 80 399 1
## 2 30 121 2
## 3 50 221 3
## 4 90 376 4
## 5 70 361 5
## 6 60 224 6
plot(toluca$c,model2$residuals,
xlab="Amatan",ylab="Residuals",type="l",
main="Plot Uji Asumsi Galat Saling Bebas")
plot(toluca$c,model2$residuals,
xlab="Amatan",ylab="Residuals",
main="Plot Uji Asumsi Galat Saling Bebas")
Asumsi 3: Galat berdistribusi normal
c<-(1:25)
ytopi<-model2$fitted.values
ei<-model2$residuals
eiterurut<-sort(model2$residuals)
anova(model2) #baca nilai KTG
## Analysis of Variance Table
##
## Response: WorkHours
## Df Sum Sq Mean Sq F value Pr(>F)
## LotSize 1 252378 252378 105.88 4.449e-10 ***
## Residuals 23 54825 2384
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## LotSize WorkHours c ytopi ei eiterurut hi
## 1 80 399 1 347.9820 51.01798 -83.87596 -95.90529
## 2 30 121 2 169.4719 -48.47192 -66.38606 -74.17666
## 3 50 221 3 240.8760 -19.87596 -60.28000 -61.48702
## 4 90 376 4 383.6840 -7.68404 -52.57798 -51.97266
## 5 70 361 5 312.2800 48.72000 -48.47192 -44.10749
## 6 60 224 6 276.5780 -52.57798 -45.17394 -37.24776
Atau gunakan fungsi qqnorm dan qqline di R sebagai berikut,