Data yang digunakan dalam praktikum ini adalah data handheight.
{handheight<-read.table(file = “C:/Users/qurro/OneDrive/Documents/Semester_2/Analisis Regresi/handheight.txt”, header = TRUE)} head(handheight) modelhandheight <- lm(HandSpan ~ Height, data = handheight) modelhandheight
#Asumsi 1: Rata-rata galat diasumsikan bernilai nol plot(handheight\(Height,modelhandheight\)residuals, xlab=“variabel X”,ylab=“Residuals”, main=“Plot Uji Asumsi Rata2 Galat bernilai nol”) abline(h=0, col=“yellow”, lty=2)
Kesimpulan: Berdasarkan plot uji asumsi rata-rata galat bernilai nol diatas, titik-titik residu menyebar disekitar residual e=0 secara acak, maka E(Yi) adalah fungsi linier dari Xi atau asumsi rata-rata galat bernilai nol terpenuhi.
#Asumsi 2: Galat saling bebas c <- (1:167) handheightbaru <- cbind(handheight, c); head(handheightbaru) #Plot Uji Asumsi Galat Saling Bebas plot(handheightbaru\(c, modelhandheight\)residuals, xlab = “amatan”, ylab = “residuals”, type = “l”, main = “Plot Uji Asumsi Galat Saling Bebas”)
#Asumsi 3: Galat berdistribusi normal c <- (1:167) ytopi.handheight <- modelhandheight\(fitted.values ei.handheight <- modelhandheight\)residuals eiterurut.handheight <- sort(modelhandheight$residuals) anova(modelhandheight)
hi.handheight <- sqrt(1.69)*qnorm((c-0.375)/(167+0.25)) hi.shandheight <- cbind(handheightbaru, ytopi.handheight, ei.handheight, eiterurut.handheight, hi.handheight);head(hi.handheight)
#Plot Uji Galat Berdistribusi Normal plot(hi.handheight, eiterurut.handheight, xlab = “hi”, ylab = “ei terurut”, main = “Plot Uji Galat Berdistribusi Normal”) hist(modelhandheight$residuals, 5)
qqnorm(modelhandheight\(residuals, ylab = "raw residuals") qqline(modelhandheight\)residuals) hist(modelhandheight\(residuals,25) boxplot(modelhandheight\)residuals)
#Asumsi 4: Ragam galat diasumsikan konstan ytopi.handheight <- modelhandheight\(fitted.values ei.handheight <- modelhandheight\)residuals plot(ytopi.handheight, ei.handheight, xlab = “fitted values”, ylab = “residuals”, main = “Plot Uji Ragam Galat Konstan”) abline(h=0, col=“red”, lty=2)
#Asumsi 5: X dan Y berhubungan linear plot(handheight\(Height, handheight\)Handspan, main = “Plot Data Signdist”) abline(modelhandheight, col=“red”)
#Asumsi 6: tidak ada outliner plot(handheight\(Height, handheight\)HandSpan, main = “Plot Data handheightt”)