# =========================
# 1. Load Library
# =========================
library(readr)
## Warning: package 'readr' was built under R version 4.5.2
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.2
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(stats)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.2
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.5.2
## corrplot 0.95 loaded
library(car)
## Warning: package 'car' was built under R version 4.5.2
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.5.2
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
library(lmtest)
## Warning: package 'lmtest' was built under R version 4.5.2
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.5.2
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(Metrics)
## Warning: package 'Metrics' was built under R version 4.5.2
library(reshape2)
## Warning: package 'reshape2' was built under R version 4.5.2
# =========================
# 2. Import Data
# =========================
data <- read.csv("C:/Users/Msi user/Downloads/Tugas Anreg Smt 6/StudentsPerformance.csv")
cat("Data Awal:\n")
## Data Awal:
head(data)
## gender race.ethnicity parental.level.of.education lunch
## 1 female group B bachelor's degree standard
## 2 female group C some college standard
## 3 female group B master's degree standard
## 4 male group A associate's degree free/reduced
## 5 male group C some college standard
## 6 female group B associate's degree standard
## test.preparation.course math.score reading.score writing.score
## 1 none 72 72 74
## 2 completed 69 90 88
## 3 none 90 95 93
## 4 none 47 57 44
## 5 none 76 78 75
## 6 none 71 83 78
# =========================
# 3. Pilih Variabel
# =========================
kolom <- c("math_score","reading_score","writing_score","test_preparation_course")
# Cek missing value
colSums(is.na(data))
## gender race.ethnicity
## 0 0
## parental.level.of.education lunch
## 0 0
## test.preparation.course math.score
## 0 0
## reading.score writing.score
## 0 0
# Hapus missing value
data <- na.omit(data)
cat("\nData setelah hapus NA:\n")
##
## Data setelah hapus NA:
colSums(is.na(data))
## gender race.ethnicity
## 0 0
## parental.level.of.education lunch
## 0 0
## test.preparation.course math.score
## 0 0
## reading.score writing.score
## 0 0
# 4. Ubah Variabel Kategori
# =========================
colnames(data) <- c("gender","race","parent_edu","lunch",
"test_preparation_course","math_score",
"reading_score","writing_score")
data$test_preparation_course <- ifelse(data$test_preparation_course == "completed", 1, 0)
# 5. Cek Outlier
# =========================
boxplot(data[kolom],
main = "Boxplot Sebelum Hapus Outlier",
col = "lightblue")

# Menghitung Q1 dan Q3
Q1 <- apply(data[kolom], 2, quantile, probs = 0.25)
Q3 <- apply(data[kolom], 2, quantile, probs = 0.75)
# Menghitung IQR
IQR_val <- Q3 - Q1
# Menentukan batas bawah dan batas atas
lower_bound <- Q1 - 1.5 * IQR_val
upper_bound <- Q3 + 1.5 * IQR_val
# Deteksi outlier
outlier <- sweep(data[kolom], 2, lower_bound, "<") |
sweep(data[kolom], 2, upper_bound, ">")
# Menampilkan jumlah outlier tiap variabel
cat("Jumlah Outlier tiap variabel:\n")
## Jumlah Outlier tiap variabel:
print(colSums(outlier))
## math_score reading_score writing_score
## 8 6 5
## test_preparation_course
## 0
# Menghapus baris yang mengandung outlier
outlier_row <- apply(outlier, 1, any)
data_clean <- data[!outlier_row, ]
# Menampilkan jumlah data sebelum dan sesudah
cat("\nJumlah data sebelum hapus outlier:", nrow(data), "\n")
##
## Jumlah data sebelum hapus outlier: 1000
cat("Jumlah data setelah hapus outlier:", nrow(data_clean), "\n")
## Jumlah data setelah hapus outlier: 988
# Boxplot setelah hapus outlier
boxplot(data_clean[kolom],
main = "Boxplot Setelah Hapus Outlier",
col = "lightgreen")

# Korelasi Pearson
cat("\nKorelasi Pearson\n")
##
## Korelasi Pearson
corr_matrix <- cor(data_clean[kolom], method = "pearson")
print(corr_matrix)
## math_score reading_score writing_score
## math_score 1.0000000 0.8014054 0.7833488
## reading_score 0.8014054 1.0000000 0.9506286
## writing_score 0.7833488 0.9506286 1.0000000
## test_preparation_course 0.1671689 0.2328474 0.3087789
## test_preparation_course
## math_score 0.1671689
## reading_score 0.2328474
## writing_score 0.3087789
## test_preparation_course 1.0000000
# Heatmap korelasi
library(ggplot2)
library(reshape2)
corr_melt <- melt(corr_matrix)
ggplot(corr_melt, aes(Var1, Var2, fill = value)) +
geom_tile() +
geom_text(aes(label = round(value,2))) +
scale_fill_gradient2(low = "blue", high = "red", mid = "white", midpoint = 0) +
labs(title = "Heatmap Korelasi Pearson",
x = "",
y = "") +
theme_minimal()

# Korelasi dengan math_score
variabel <- c("reading_score","writing_score","test_preparation_course")
for (var in variabel) {
test <- cor.test(data_clean$math_score, data_clean[[var]])
cat(var, "r =", round(test$estimate,3),
"p =", round(test$p.value,4), "\n")
}
## reading_score r = 0.801 p = 0
## writing_score r = 0.783 p = 0
## test_preparation_course r = 0.167 p = 0
# =========================
# Mendefinisikan variabel dependen (Y)
# =========================
Y <- data_clean$math_score
# =========================
# Mendefinisikan variabel independen (X)
# =========================
X <- data_clean[, c("reading_score","writing_score","test_preparation_course")]
# Menambahkan konstanta (intercept)
X <- cbind(constant = 1, X)
# =========================
# Model Regresi Linear
# =========================
model <- lm(math_score ~ reading_score + writing_score + test_preparation_course,
data = data_clean)
# Ringkasan model
summary(model)
##
## Call:
## lm(formula = math_score ~ reading_score + writing_score + test_preparation_course,
## data = data_clean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.3142 -6.0720 0.2119 6.0936 24.3132
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.99903 1.38461 6.499 1.28e-10 ***
## reading_score 0.57645 0.06395 9.014 < 2e-16 ***
## writing_score 0.26207 0.06310 4.153 3.56e-05 ***
## test_preparation_course -1.34823 0.60848 -2.216 0.0269 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.552 on 984 degrees of freedom
## Multiple R-squared: 0.6488, Adjusted R-squared: 0.6477
## F-statistic: 606 on 3 and 984 DF, p-value: < 2.2e-16
# =========================
# Mengambil koefisien model
# =========================
coef_model <- coef(model)
b0 <- coef_model["(Intercept)"]
b1 <- coef_model["reading_score"]
b2 <- coef_model["writing_score"]
b3 <- coef_model["test_preparation_course"]
cat("\nPersamaan Model:\n")
##
## Persamaan Model:
cat(sprintf("Y = %.3f + (%.3f)X1 + (%.3f)X2 + (%.3f)X3\n",
b0, b1, b2, b3))
## Y = 8.999 + (0.576)X1 + (0.262)X2 + (-1.348)X3
# =========================
# R-square
# =========================
r2 <- summary(model)$r.squared
adj_r2 <- summary(model)$adj.r.squared
cat(sprintf("\nR-square = %.3f\n", r2))
##
## R-square = 0.649
cat(sprintf("Adjusted R-square = %.3f\n", adj_r2))
## Adjusted R-square = 0.648
# =========================
# Interpretasi R-square
# =========================
cat("\nInterpretasi R-square:\n")
##
## Interpretasi R-square:
cat(sprintf("Nilai R-square sebesar %.3f menunjukkan bahwa %.2f%% variasi nilai matematika siswa ",
r2, r2*100))
## Nilai R-square sebesar 0.649 menunjukkan bahwa 64.88% variasi nilai matematika siswa
cat("dapat dijelaskan oleh variabel reading_score, writing_score, dan test_preparation_course secara bersama-sama, ")
## dapat dijelaskan oleh variabel reading_score, writing_score, dan test_preparation_course secara bersama-sama,
cat(sprintf("sedangkan sisanya sebesar %.2f%% dijelaskan oleh faktor lain di luar model.\n",
(1-r2)*100))
## sedangkan sisanya sebesar 35.12% dijelaskan oleh faktor lain di luar model.
# =========================
# Uji Asumsi Klasik
# =========================
# 1. Normalitas (Shapiro-Wilk)
residual <- resid(model)
# Ambil maksimal 1000 sampel (biar tidak error kalau data kecil)
set.seed(123)
res_sample <- sample(residual, min(length(residual), 1000))
shapiro_test <- shapiro.test(res_sample)
print(shapiro_test)
##
## Shapiro-Wilk normality test
##
## data: res_sample
## W = 0.99626, p-value = 0.01796
if (shapiro_test$p.value > 0.05){
cat("Residual berdistribusi normal sehingga asumsi normalitas terpenuhi.\n")
} else {
cat("Residual tidak berdistribusi normal sehingga asumsi normalitas tidak terpenuhi.\n")
}
## Residual tidak berdistribusi normal sehingga asumsi normalitas tidak terpenuhi.
# =========================
# 2. Multikolinearitas (VIF)
# =========================
library(car)
vif_values <- vif(model)
cat("\nUji Multikolinearitas (VIF):\n")
##
## Uji Multikolinearitas (VIF):
print(vif_values)
## reading_score writing_score test_preparation_course
## 10.841969 11.334855 1.154183
if (all(vif_values < 10)) {
cat("Interpretasi: Tidak terdapat multikolinearitas antar variabel bebas (reading, writing, test preparation).\n")
} else {
cat("Interpretasi: Terdapat multikolinearitas pada beberapa variabel bebas.\n")
}
## Interpretasi: Terdapat multikolinearitas pada beberapa variabel bebas.
# =========================
# 3. Heteroskedastisitas (Breusch-Pagan)
# =========================
library(lmtest)
bp_test <- bptest(model)
cat("\nUji Heteroskedastisitas (Breusch-Pagan):\n")
##
## Uji Heteroskedastisitas (Breusch-Pagan):
print(bp_test)
##
## studentized Breusch-Pagan test
##
## data: model
## BP = 4.5466, df = 3, p-value = 0.2082
if (bp_test$p.value > 0.05) {
cat("Interpretasi: Tidak terjadi heteroskedastisitas (model bersifat homoskedastis).\n")
} else {
cat("Interpretasi: Terjadi heteroskedastisitas pada model regresi.\n")
}
## Interpretasi: Tidak terjadi heteroskedastisitas (model bersifat homoskedastis).
# =========================
# 4. Autokorelasi (Durbin-Watson)
# =========================
dw_test <- dwtest(model)
cat("\nUji Autokorelasi (Durbin-Watson):\n")
##
## Uji Autokorelasi (Durbin-Watson):
print(dw_test)
##
## Durbin-Watson test
##
## data: model
## DW = 2.0453, p-value = 0.7617
## alternative hypothesis: true autocorrelation is greater than 0
dw_value <- dw_test$statistic
cat("Nilai DW =", dw_value, "\n")
## Nilai DW = 2.045269
if (dw_value > 1.5 & dw_value < 2.5) {
cat("Interpretasi: Tidak terdapat autokorelasi pada residual.\n")
} else if (dw_value <= 1.5) {
cat("Interpretasi: Terdapat autokorelasi positif.\n")
} else {
cat("Interpretasi: Terdapat autokorelasi negatif.\n")
}
## Interpretasi: Tidak terdapat autokorelasi pada residual.
#Prediksi
data_clean$prediksi_math_score <- predict(model)
# =========================
# Evaluasi Model
# =========================
# Nilai aktual
Y <- data_clean$math_score
# Nilai prediksi
pred <- data_clean$prediksi_math_score
# RMSE
rmse <- sqrt(mean((Y - pred)^2))
# MAE
mae <- mean(abs(Y - pred))
# MAPE
mape <- mean(abs((Y - pred) / Y)) * 100
cat("RMSE =", rmse, "\n")
## RMSE = 8.534905
cat("MAE =", mae, "\n")
## MAE = 6.98042
cat("MAPE =", mape, "%\n")
## MAPE = 11.26838 %
cat("\nInterpretasi Evaluasi Model:\n")
##
## Interpretasi Evaluasi Model:
cat(sprintf("RMSE sebesar %.3f menunjukkan rata-rata besar kesalahan prediksi dalam satuan yang sama dengan nilai matematika siswa (math_score).\n", rmse))
## RMSE sebesar 8.535 menunjukkan rata-rata besar kesalahan prediksi dalam satuan yang sama dengan nilai matematika siswa (math_score).
cat(sprintf("MAE sebesar %.3f menunjukkan rata-rata kesalahan absolut antara nilai matematika aktual dengan nilai hasil prediksi model.\n", mae))
## MAE sebesar 6.980 menunjukkan rata-rata kesalahan absolut antara nilai matematika aktual dengan nilai hasil prediksi model.
if (mape < 10) {
cat(sprintf("MAPE sebesar %.2f%% menunjukkan model memiliki akurasi sangat baik.\n", mape))
} else if (mape < 20) {
cat(sprintf("MAPE sebesar %.2f%% menunjukkan model memiliki akurasi baik.\n", mape))
} else if (mape < 50) {
cat(sprintf("MAPE sebesar %.2f%% menunjukkan model memiliki akurasi cukup.\n", mape))
} else {
cat(sprintf("MAPE sebesar %.2f%% menunjukkan model memiliki akurasi rendah.\n", mape))
}
## MAPE sebesar 11.27% menunjukkan model memiliki akurasi baik.
# =========================
# Menampilkan hasil prediksi
# =========================
hasil <- data_clean[, c("math_score","prediksi_math_score")]
cat("\nTabel Hasil Prediksi:\n")
##
## Tabel Hasil Prediksi:
print(hasil)
## math_score prediksi_math_score
## 1 72 69.89657
## 2 69 82.59341
## 3 90 88.13424
## 4 47 53.38774
## 5 76 73.61734
## 6 71 77.28580
## 7 88 86.52394
## 8 40 44.00709
## 9 64 62.10225
## 10 38 56.68951
## 11 58 53.75494
## 12 40 50.24342
## 13 65 74.82256
## 14 78 67.50006
## 15 50 54.75091
## 16 69 72.67420
## 17 88 82.84106
## 19 46 43.91689
## 20 54 58.41937
## 21 66 65.28446
## 22 65 69.22942
## 23 44 54.01701
## 24 69 70.21095
## 25 74 69.54430
## 26 73 70.52533
## 27 69 54.54115
## 28 67 68.42929
## 29 70 66.38505
## 30 62 69.00574
## 31 69 71.04947
## 32 63 62.45452
## 33 56 67.53795
## 34 40 43.16857
## 35 97 80.63988
## 36 81 75.04674
## 37 74 77.44324
## 38 50 61.35393
## 39 75 82.59341
## 40 57 56.21819
## 41 55 58.31424
## 42 58 68.90061
## 43 53 59.46764
## 44 59 62.41663
## 45 50 55.43198
## 46 65 55.06529
## 47 55 61.36836
## 48 66 69.84426
## 49 57 70.22538
## 50 82 77.56230
## 51 53 53.28312
## 52 77 65.24657
## 53 53 45.36975
## 54 88 73.61734
## 55 71 78.87264
## 56 33 43.90247
## 57 82 79.18702
## 58 52 53.54519
## 59 58 56.86138
## 61 79 69.17710
## 62 39 40.39094
## 63 62 58.57630
## 64 69 73.72197
## 65 59 57.89523
## 66 67 61.87807
## 67 45 40.02425
## 68 60 69.89657
## 69 61 57.10902
## 70 39 60.82979
## 71 58 63.09821
## 72 63 55.86592
## 73 41 50.97732
## 74 61 56.53257
## 75 49 47.98993
## 76 44 42.59212
## 78 80 73.84152
## 79 61 69.17710
## 80 62 66.01835
## 81 47 50.34855
## 82 49 46.73241
## 83 50 48.89570
## 84 72 62.40221
## 85 42 40.39094
## 86 73 76.60472
## 87 76 79.90649
## 88 71 69.32012
## 89 58 66.90919
## 90 73 80.06343
## 91 65 69.89657
## 92 27 38.03283
## 93 71 73.14552
## 94 43 46.69452
## 95 79 82.68412
## 96 78 75.83295
## 97 65 61.94481
## 98 63 67.50006
## 99 58 63.86949
## 100 65 63.86949
## 101 79 65.17983
## 102 68 69.70124
## 103 85 84.78016
## 104 60 45.33186
## 105 98 80.81175
## 106 58 66.49018
## 107 87 92.85098
## 108 66 60.73959
## 109 52 71.15410
## 110 70 64.76083
## 111 77 84.63765
## 112 62 53.54519
## 113 54 51.86815
## 114 51 56.58488
## 115 99 91.50275
## 116 84 72.77882
## 117 75 79.48698
## 118 78 76.97142
## 119 51 61.30162
## 120 55 65.80860
## 121 79 84.00838
## 122 91 83.06524
## 123 88 85.63311
## 124 63 56.53257
## 125 83 74.24611
## 126 87 86.29976
## 127 72 65.75628
## 128 65 71.43059
## 129 82 75.66108
## 130 51 50.61062
## 131 89 78.91053
## 132 53 39.46223
## 133 87 68.65296
## 134 75 76.35708
## 135 74 72.84556
## 136 58 53.28312
## 137 51 49.52396
## 138 70 55.37967
## 139 59 64.60338
## 140 71 60.89704
## 141 76 69.11036
## 142 59 61.51137
## 143 42 53.50730
## 144 57 46.10364
## 145 88 71.52129
## 147 88 77.07605
## 148 73 65.49422
## 149 68 72.11217
## 150 100 89.66826
## 151 62 64.35574
## 152 77 65.44190
## 153 59 65.29889
## 154 54 49.56235
## 155 62 63.60742
## 156 70 82.01696
## 157 66 70.74952
## 158 60 59.31020
## 159 61 80.02554
## 160 66 61.51137
## 161 82 72.00704
## 162 75 80.65431
## 163 49 53.17849
## 164 52 52.39229
## 165 81 85.88075
## 166 96 91.50275
## 167 53 50.41529
## 168 58 71.90242
## 169 68 75.93757
## 170 67 69.22942
## 171 72 69.12479
## 172 94 80.16805
## 173 79 79.80136
## 174 63 65.96604
## 175 43 51.20150
## 176 81 82.90780
## 177 46 53.97913
## 178 71 72.21680
## 179 52 64.25061
## 180 97 91.50275
## 181 62 66.50460
## 182 46 63.18841
## 183 50 50.13880
## 184 65 67.11894
## 185 45 50.46761
## 186 65 63.30747
## 187 80 69.84375
## 188 62 63.51722
## 189 48 50.76756
## 190 77 82.52667
## 191 66 64.55107
## 192 76 76.19964
## 193 62 63.18841
## 194 77 59.63901
## 195 69 78.34850
## 196 61 54.33139
## 197 59 64.46037
## 198 55 54.64578
## 199 45 53.96470
## 200 78 74.45586
## 201 67 78.61057
## 202 65 75.87083
## 203 69 71.46848
## 204 57 66.59480
## 205 59 43.64040
## 206 74 69.02016
## 207 82 60.98724
## 208 81 73.68408
## 209 74 75.60876
## 210 58 61.45906
## 211 80 73.89384
## 213 42 60.46310
## 214 60 51.72564
## 215 87 81.33538
## 216 84 75.15136
## 217 83 80.28761
## 218 34 43.43064
## 219 66 71.73055
## 220 61 54.60789
## 221 56 66.24254
## 222 87 77.12836
## 223 55 62.71659
## 224 86 74.77024
## 225 52 64.82757
## 226 45 55.43198
## 227 72 69.11036
## 228 57 51.97328
## 229 68 67.27588
## 230 88 87.04808
## 231 76 63.18841
## 232 46 44.79330
## 233 67 80.32550
## 234 92 79.59160
## 235 83 76.93353
## 236 80 72.41213
## 237 63 64.60338
## 238 64 61.63093
## 239 54 52.33997
## 240 84 76.08059
## 241 73 64.14599
## 242 80 78.59615
## 243 56 53.38825
## 244 59 49.66697
## 245 75 69.73913
## 246 85 71.41617
## 247 89 72.20237
## 248 58 65.82302
## 249 65 62.14014
## 250 68 57.47572
## 251 47 48.73825
## 252 71 78.59615
## 253 60 66.34716
## 254 80 73.98404
## 255 54 52.60204
## 256 62 69.42474
## 257 64 68.90061
## 258 78 72.21680
## 259 70 72.67420
## 260 65 75.57088
## 261 64 73.36970
## 262 79 73.63177
## 263 44 51.18707
## 264 99 86.19513
## 265 76 68.90061
## 266 59 43.95478
## 267 63 73.46040
## 268 69 70.68278
## 269 88 85.58080
## 270 71 71.15410
## 271 69 61.30162
## 272 58 48.25200
## 273 47 54.75091
## 274 65 67.95746
## 275 88 76.56633
## 276 83 73.09320
## 277 85 85.05666
## 278 59 63.62235
## 279 65 79.53929
## 280 73 56.21819
## 281 53 49.98135
## 282 45 48.72383
## 283 73 76.55241
## 284 70 73.05532
## 285 37 47.57093
## 286 81 76.40940
## 287 97 77.98181
## 288 67 81.79278
## 289 88 72.15006
## 290 77 71.64035
## 291 76 67.17125
## 292 86 69.42474
## 293 63 57.17576
## 294 65 70.73509
## 295 78 73.00300
## 296 67 60.46310
## 297 46 42.55424
## 298 71 68.12883
## 299 40 47.27097
## 300 90 78.80540
## 301 81 73.84152
## 302 56 53.75494
## 303 67 77.30023
## 304 80 69.58168
## 305 74 72.63631
## 306 69 65.70397
## 307 99 79.02958
## 308 51 50.50549
## 309 53 67.48564
## 310 49 55.48430
## 311 73 73.77478
## 312 66 58.52399
## 313 67 60.63497
## 314 68 64.35574
## 315 59 64.19880
## 316 71 64.07925
## 317 77 78.76802
## 318 83 70.94484
## 319 63 68.00977
## 320 56 62.97866
## 321 67 75.20418
## 322 75 79.27722
## 323 71 76.65704
## 324 43 53.44056
## 325 41 46.78472
## 326 82 85.51406
## 327 61 60.41079
## 329 82 71.06390
## 330 41 54.06932
## 331 71 59.57227
## 332 47 39.50011
## 333 62 53.82168
## 334 90 75.18975
## 335 83 87.50548
## 336 61 65.49422
## 337 76 66.08509
## 338 49 49.66697
## 340 35 55.07971
## 341 58 57.79010
## 342 61 67.59026
## 343 69 70.85414
## 344 67 66.71386
## 345 79 68.63854
## 346 72 74.77024
## 347 62 59.10044
## 348 77 86.73370
## 349 75 68.95292
## 350 87 71.57361
## 351 52 64.55107
## 352 66 55.48430
## 353 63 73.57946
## 354 46 57.37109
## 355 59 68.27184
## 356 61 68.84829
## 357 63 60.14872
## 358 42 63.77929
## 359 59 60.72517
## 360 80 84.20371
## 361 58 60.20103
## 362 85 76.51402
## 363 52 57.63316
## 364 27 36.98455
## 365 59 58.78606
## 366 49 56.80907
## 367 69 54.97458
## 368 61 63.03097
## 369 44 61.09186
## 370 73 79.69673
## 371 84 71.99262
## 372 45 68.07651
## 373 74 70.52533
## 374 82 88.72512
## 375 59 68.48160
## 376 46 44.53123
## 377 80 82.36923
## 378 85 88.62049
## 379 71 77.02373
## 380 66 62.14014
## 381 80 80.32550
## 382 87 90.19240
## 383 79 74.29842
## 384 38 49.03821
## 385 38 45.05537
## 386 67 72.46444
## 387 64 69.42474
## 388 57 71.52079
## 389 62 62.66428
## 390 73 69.00574
## 391 73 61.73505
## 392 77 68.37697
## 393 76 65.17983
## 394 57 53.45499
## 395 65 70.48745
## 396 48 45.68413
## 397 50 64.13156
## 398 85 85.19968
## 399 74 60.25334
## 400 60 57.16133
## 401 59 56.33775
## 402 53 45.05537
## 403 49 60.88211
## 404 88 90.92630
## 405 54 59.25788
## 406 63 68.90061
## 407 65 61.63043
## 408 82 75.29438
## 409 52 55.18434
## 410 87 78.34850
## 411 70 67.97189
## 412 84 75.93757
## 413 71 62.76890
## 414 63 63.83160
## 415 51 69.85868
## 416 84 69.16268
## 417 71 68.12883
## 418 74 68.63854
## 419 68 59.25788
## 420 57 54.08375
## 421 82 85.63311
## 422 57 57.85734
## 423 47 58.64355
## 424 59 77.61461
## 425 41 40.39094
## 426 62 63.86949
## 427 86 79.38235
## 428 69 66.96150
## 429 65 56.89927
## 430 68 59.46714
## 431 64 62.50683
## 432 61 68.84829
## 433 61 55.69405
## 434 47 56.11306
## 435 73 64.34131
## 436 50 49.21008
## 437 75 64.97008
## 438 75 66.17580
## 439 70 54.64578
## 440 89 79.86810
## 441 67 75.04674
## 442 78 76.65704
## 443 59 69.16268
## 444 73 76.76166
## 445 79 75.39901
## 446 67 70.48745
## 447 69 62.76890
## 448 86 75.30881
## 449 47 46.52265
## 450 81 69.94888
## 451 64 78.92495
## 452 100 87.45316
## 453 65 72.77882
## 454 65 55.27454
## 455 53 60.41079
## 456 37 53.59750
## 457 79 83.62726
## 458 53 52.70667
## 459 100 92.85098
## 460 72 62.94077
## 461 53 56.84695
## 462 54 51.92046
## 463 71 69.26781
## 464 77 84.72785
## 465 75 57.33320
## 466 84 82.99850
## 468 72 63.30747
## 469 77 80.65431
## 470 91 71.57361
## 471 83 80.23530
## 472 63 68.16722
## 473 68 79.23934
## 474 59 63.60742
## 475 90 83.37962
## 476 71 73.21276
## 477 76 60.68728
## 478 80 67.06663
## 479 55 64.23669
## 480 76 67.48564
## 481 73 66.39948
## 482 52 57.68547
## 483 68 64.18387
## 484 59 51.02963
## 485 49 53.12618
## 486 70 70.26326
## 487 61 50.76806
## 488 60 71.62592
## 489 64 53.14061
## 490 79 76.40940
## 491 65 77.91456
## 492 64 64.23669
## 493 83 80.43063
## 494 81 83.31288
## 495 54 63.71255
## 496 68 61.84018
## 497 54 50.29624
## 498 59 72.53118
## 499 66 66.59480
## 500 76 68.79598
## 501 74 76.02827
## 502 94 81.91234
## 503 63 58.31424
## 504 95 83.06524
## 505 40 57.16133
## 506 82 77.23349
## 507 68 66.64712
## 508 55 57.16133
## 509 79 74.14148
## 510 86 84.83248
## 511 76 69.05805
## 512 64 49.09052
## 513 62 50.87269
## 514 54 59.06256
## 515 77 88.20098
## 516 76 80.07786
## 517 74 82.31692
## 518 66 69.43917
## 519 66 73.05532
## 520 67 73.31739
## 521 71 50.87269
## 522 91 80.58757
## 523 69 57.37109
## 524 54 56.11306
## 525 53 50.46761
## 526 68 59.04813
## 527 56 58.53842
## 528 36 50.81987
## 529 29 44.95074
## 530 62 70.00119
## 531 68 65.40402
## 532 47 54.01701
## 533 62 58.01428
## 534 79 83.01293
## 535 73 65.24657
## 536 66 77.24792
## 537 51 57.43783
## 538 51 63.29304
## 539 85 64.30343
## 540 97 83.22218
## 541 75 65.24657
## 542 79 75.88526
## 543 81 74.08917
## 544 82 87.08597
## 545 64 62.61196
## 546 78 76.46171
## 547 92 90.71654
## 548 72 63.04540
## 549 62 64.39363
## 550 79 68.58622
## 551 79 69.84375
## 552 87 82.59341
## 553 40 49.77210
## 554 77 61.51137
## 555 53 45.42206
## 556 32 40.12888
## 557 55 69.85868
## 558 61 64.91777
## 559 53 67.69539
## 560 73 63.29304
## 561 74 71.58803
## 562 63 71.04947
## 563 96 83.64169
## 564 63 74.73236
## 565 48 50.45318
## 566 48 45.57950
## 567 92 91.50275
## 568 61 69.02016
## 569 63 48.98590
## 570 68 65.75628
## 571 71 69.22942
## 572 91 88.44862
## 573 53 59.41482
## 574 50 62.46895
## 575 74 74.29842
## 576 40 53.24523
## 577 61 50.67736
## 578 81 84.78016
## 579 48 55.13203
## 580 53 61.98320
## 581 81 90.07335
## 582 77 75.50414
## 583 63 71.52129
## 584 73 71.85010
## 585 69 73.56503
## 586 65 72.72651
## 587 55 70.21095
## 588 44 61.56369
## 589 54 62.92634
## 590 48 64.07925
## 591 58 56.00843
## 592 71 57.84241
## 593 68 64.97008
## 594 74 71.94030
## 595 92 91.24068
## 596 56 72.05936
## 598 53 52.70667
## 599 69 72.51675
## 600 65 77.49556
## 601 54 60.09640
## 602 29 33.57816
## 603 76 74.92769
## 604 60 55.22223
## 605 84 82.54110
## 606 75 66.75174
## 607 85 78.91053
## 608 40 56.58488
## 609 61 62.14014
## 610 58 62.34989
## 611 69 58.74817
## 612 58 60.30616
## 613 94 83.37962
## 614 65 72.77882
## 615 82 86.98134
## 616 60 67.06663
## 617 37 44.89792
## 618 88 75.71389
## 619 95 77.70531
## 620 65 67.55238
## 621 35 58.31424
## 622 62 59.99127
## 623 58 50.67736
## 624 100 85.52798
## 625 61 58.68143
## 626 100 89.51133
## 627 69 64.51268
## 628 61 48.72383
## 629 49 53.91188
## 630 44 51.46357
## 631 67 64.23669
## 632 79 60.62054
## 633 66 71.53572
## 634 75 82.00254
## 635 84 78.38639
## 636 71 68.42878
## 637 67 74.99443
## 638 80 83.74632
## 639 86 72.20237
## 640 76 70.78740
## 641 41 52.33997
## 642 74 81.96465
## 643 72 76.39497
## 644 74 74.15591
## 645 70 62.19245
## 646 65 75.57088
## 647 59 66.38505
## 648 64 62.55965
## 649 50 53.96470
## 650 69 74.41797
## 651 51 53.82168
## 652 68 73.68408
## 653 85 82.90830
## 654 65 67.39544
## 655 73 75.24207
## 656 62 65.17983
## 657 77 64.39363
## 658 69 63.03097
## 659 43 58.78606
## 660 90 81.42609
## 661 74 72.51675
## 662 73 63.55511
## 663 55 68.00977
## 664 65 66.33274
## 665 80 61.82576
## 666 50 57.96197
## 667 63 68.33858
## 668 77 80.79732
## 669 73 67.64258
## 670 81 69.33455
## 671 66 70.62996
## 672 52 54.96016
## 673 69 73.87941
## 674 65 78.08643
## 675 69 72.47887
## 676 50 61.84018
## 677 73 72.53118
## 678 70 74.83698
## 679 81 72.67420
## 680 63 59.88665
## 681 67 69.89657
## 682 60 63.92180
## 683 62 54.85553
## 684 29 42.23985
## 685 62 63.51722
## 686 94 90.92630
## 687 85 68.70528
## 688 77 73.09320
## 689 53 53.96420
## 690 93 82.63130
## 691 49 53.44056
## 692 73 73.25065
## 693 66 71.53572
## 694 77 72.51675
## 695 49 59.99127
## 696 79 82.84106
## 697 75 78.50595
## 698 59 68.84829
## 699 57 73.31739
## 700 66 62.50683
## 701 79 75.83295
## 702 57 66.49018
## 703 87 78.87264
## 704 63 63.45048
## 705 59 60.73959
## 706 62 67.53795
## 707 46 38.03283
## 708 66 56.63720
## 709 89 79.85367
## 710 42 58.01428
## 711 93 79.65885
## 712 80 78.92495
## 713 98 92.58891
## 714 81 77.70531
## 715 60 67.39544
## 716 76 84.63715
## 717 73 71.48290
## 718 96 88.93487
## 719 76 72.20237
## 720 91 70.69720
## 721 62 68.84829
## 722 55 57.12345
## 723 74 82.59341
## 724 50 47.67555
## 725 47 44.53123
## 726 81 68.91503
## 727 65 71.06390
## 728 68 51.98771
## 729 73 84.04627
## 730 53 41.17715
## 731 68 73.00300
## 732 55 46.78472
## 733 87 83.58938
## 734 55 47.62324
## 735 53 57.37109
## 736 67 57.31878
## 737 92 76.55241
## 738 53 64.82757
## 739 81 69.05805
## 740 61 57.99985
## 741 80 69.94888
## 742 37 56.53257
## 743 81 78.91053
## 744 59 68.60065
## 745 55 53.02105
## 746 72 73.93172
## 747 69 70.83971
## 748 69 63.71255
## 749 50 59.04813
## 750 87 78.61057
## 751 71 65.24657
## 752 68 67.53795
## 753 79 71.69266
## 754 77 81.80721
## 755 58 54.59346
## 756 84 87.87217
## 757 55 56.06075
## 758 70 65.71840
## 759 52 58.69586
## 760 69 72.21680
## 761 53 67.27588
## 762 48 56.58488
## 763 78 76.88122
## 764 62 61.24931
## 765 60 60.77748
## 766 74 69.37243
## 767 58 71.06390
## 768 76 59.11487
## 769 68 69.58219
## 770 58 58.52399
## 771 52 49.51003
## 772 75 70.47302
## 773 52 65.14195
## 774 62 74.66562
## 775 66 62.19245
## 776 49 56.84695
## 777 66 68.84829
## 778 35 45.63182
## 779 72 74.68004
## 780 94 78.13875
## 781 46 56.21819
## 782 77 82.89337
## 783 76 78.13875
## 784 52 57.90965
## 785 91 75.04674
## 786 32 48.58081
## 787 72 74.71793
## 789 68 62.45452
## 790 52 62.45452
## 791 48 60.46310
## 792 60 65.38959
## 793 66 69.73913
## 794 89 76.25195
## 795 42 52.33997
## 796 57 65.98047
## 797 70 67.69539
## 798 70 78.64846
## 799 69 57.73778
## 800 52 55.64174
## 801 67 67.55238
## 802 76 72.89787
## 803 87 88.08193
## 804 82 80.79732
## 805 73 73.25065
## 806 75 75.08462
## 807 64 71.31154
## 808 41 45.42206
## 809 90 70.31558
## 810 59 53.49287
## 811 51 36.30348
## 812 45 48.93358
## 813 54 62.10225
## 814 87 75.98988
## 815 72 76.86679
## 816 94 80.02554
## 817 45 59.78202
## 818 61 67.91958
## 819 60 68.32416
## 820 77 84.51809
## 821 85 83.64169
## 822 78 85.25199
## 823 49 50.99174
## 824 71 80.63988
## 825 48 56.06075
## 826 62 62.82121
## 827 56 65.19426
## 828 65 68.69135
## 829 69 78.45313
## 830 68 54.01701
## 831 61 58.52399
## 832 74 80.54968
## 833 64 58.78606
## 834 77 78.24388
## 835 58 49.61466
## 836 60 63.93673
## 837 73 60.82979
## 838 75 75.62319
## 839 58 54.39813
## 840 66 72.51675
## 841 39 51.02963
## 842 64 55.79868
## 844 74 71.95473
## 845 40 61.89250
## 846 90 80.01112
## 847 91 78.92495
## 848 64 53.23081
## 849 59 68.32416
## 850 80 70.31558
## 851 71 65.17983
## 852 61 64.70801
## 853 87 82.36974
## 854 82 63.60742
## 855 62 60.30566
## 856 97 90.07335
## 857 75 65.23215
## 858 65 75.76621
## 859 52 47.95205
## 860 87 69.94888
## 861 53 58.62862
## 862 81 81.37377
## 863 39 41.82034
## 864 71 69.54430
## 865 97 86.45720
## 866 82 77.98181
## 867 59 53.17849
## 868 61 43.95478
## 869 78 69.17710
## 870 49 51.76352
## 871 59 54.75040
## 872 70 69.07248
## 873 82 76.51402
## 874 90 82.36923
## 875 43 60.72517
## 876 80 63.18841
## 877 81 78.28176
## 878 57 58.31424
## 879 59 71.46898
## 880 64 72.20237
## 881 63 61.84018
## 882 71 66.34716
## 883 64 69.68681
## 884 55 47.04679
## 885 51 52.54973
## 886 62 72.42655
## 887 93 90.19240
## 888 54 65.96554
## 889 69 65.86141
## 890 44 50.97732
## 891 86 80.49737
## 892 85 84.30834
## 893 50 66.75225
## 894 88 69.96331
## 895 59 62.82172
## 896 32 38.55697
## 897 36 32.79196
## 898 63 73.31739
## 899 67 55.28947
## 900 65 74.10359
## 901 85 80.74501
## 902 73 73.35527
## 903 34 46.06525
## 904 93 91.50275
## 905 67 79.43466
## 906 88 73.56503
## 907 57 50.03417
## 908 79 79.92092
## 909 67 71.10178
## 910 70 62.88846
## 911 50 45.78926
## 912 69 78.91053
## 913 52 60.11083
## 914 47 60.68728
## 915 46 58.57630
## 916 68 66.64712
## 917 100 91.50275
## 918 44 57.79010
## 919 57 73.00300
## 920 91 86.83832
## 921 69 66.90919
## 922 35 51.60608
## 923 72 64.34131
## 924 54 63.50280
## 925 74 67.43332
## 926 74 60.26777
## 927 64 54.90784
## 928 65 61.42118
## 929 46 43.96921
## 930 48 54.64578
## 931 67 68.65296
## 932 62 58.10498
## 933 61 67.70982
## 934 70 70.27769
## 935 98 81.38820
## 936 70 60.51541
## 937 67 55.74636
## 938 57 57.37109
## 939 85 76.61915
## 940 77 64.93219
## 941 72 64.56550
## 942 78 86.61465
## 943 81 63.81718
## 944 61 59.37694
## 945 58 64.18387
## 946 54 59.36251
## 947 82 77.23349
## 948 49 58.15730
## 949 49 50.10091
## 950 57 70.01562
## 951 94 69.68681
## 952 75 73.78921
## 953 74 70.52533
## 954 58 51.77795
## 955 62 66.85687
## 956 72 58.10498
## 957 84 80.37781
## 958 92 92.85098
## 959 45 60.77748
## 960 75 74.29842
## 961 56 59.20557
## 962 48 54.01701
## 963 100 92.85098
## 964 65 71.11621
## 965 72 57.05671
## 966 62 68.21953
## 967 66 63.62185
## 968 63 61.03955
## 969 68 70.36789
## 970 75 78.38639
## 971 89 92.85098
## 972 78 67.23799
## 973 53 52.19746
## 974 49 62.45452
## 975 54 62.87403
## 976 64 75.09905
## 977 60 59.11487
## 978 62 61.66831
## 979 55 43.86458
## 980 91 88.39631
## 982 81 74.40355
## 983 79 79.18702
## 984 78 81.65027
## 985 74 73.72247
## 986 57 52.54973
## 987 40 56.37513
## 988 81 70.80183
## 989 44 46.73241
## 990 67 78.97727
## 991 86 73.99846
## 992 65 75.36112
## 993 55 72.72651
## 994 62 69.89657
## 995 63 61.56369
## 996 88 89.61595
## 997 62 55.11760
## 998 59 65.61327
## 999 68 72.79325
## 1000 77 81.11170
# =========================
# Plot grafik Aktual vs Prediksi
# =========================
plot(Y, type="l", col="blue", lwd=2,
ylab="Math Score",
xlab="Observasi",
main="Aktual vs Prediksi")
lines(data_clean$prediksi_math_score, col="red", lwd=2)
legend("topleft",
legend=c("Aktual","Prediksi"),
col=c("blue","red"),
lwd=2)
