1 Data Understanding

Berikut ini adalah analisis harga rumah berdasarkan data HousePricing yang disediakan oleh Kaggle.

1.1 Business problem

Dalam analisis ini, pendekatan yang digunakan adalah regresi linear untuk menghasilkan sebuah model yang dapat memperkirakan harga rumah berdasarkan atribut-atribut properti yang ada. Selanjutnya, saya akan memberikan saran tentang tindakan yang dapat diambil untuk meningkatkan keakuratan prediksi harga rumah tersebut.

1.2 Metadata

Deskripsi dari dataset House Pricing :

  • “Area”: Luas area properti (numerik)
  • “Garage”: Jumlah garasi pada properti (faktor)
  • “FirePlace”: Apakah properti memiliki perapian (faktor)
  • “Baths”: Jumlah kamar mandi pada properti (faktor)
  • “White.Marble”: Apakah properti menggunakan lantai marmer putih (faktor)
  • “Black.Marble”: Apakah properti menggunakan lantai marmer hitam (faktor)
  • “Indian.Marble”: Apakah properti menggunakan lantai marmer India (tidak ada dalam daftar atribut)
  • “Floors”: Jumlah lantai properti (faktor)
  • “City”: Kota lokasi properti (faktor)
  • “Solar”: Apakah properti menggunakan energi surya (faktor)
  • “Electric”: Apakah properti menggunakan listrik (faktor)
  • “Fiber”: Apakah properti memiliki akses serat optik (faktor)
  • “Glass.Doors”: Apakah properti menggunakan pintu kaca (faktor)
  • “Swiming.Pool”: Apakah properti memiliki kolam renang (faktor) “Garden”: Apakah properti memiliki taman (faktor) “Prices”: Harga rumah (numerik)

2 Pembersihan Data

2.1 Import Library

library(dplyr) # untuk transformasi data
library(plotly) # untuk membuat plot menjadi interaktif
library(glue) # untuk custom informasi saat plot interaktif
library(scales) # untuk custom keterangan axis atau lainnya
library(tidyr) # untuk custom keterangan axis atau lainnya
library(ggpubr) # untuk export plot
library(ggthemes)

2.2 Baca Data

house <- read.csv("HousePrices_HalfMil.csv")

2.2.1 Melihat dan Memperbaiki Tipe Data

glimpse(house)
#> Rows: 500,000
#> Columns: 16
#> $ Area          <int> 164, 84, 190, 75, 148, 124, 58, 249, 243, 242, 61, 189, …
#> $ Garage        <int> 2, 2, 2, 2, 1, 3, 1, 2, 1, 1, 2, 2, 2, 3, 3, 3, 1, 3, 2,…
#> $ FirePlace     <int> 0, 0, 4, 4, 4, 3, 0, 1, 0, 2, 4, 0, 0, 3, 3, 4, 0, 3, 3,…
#> $ Baths         <int> 2, 4, 4, 4, 2, 3, 2, 1, 2, 4, 5, 4, 2, 3, 1, 1, 5, 3, 5,…
#> $ White.Marble  <int> 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
#> $ Black.Marble  <int> 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1,…
#> $ Indian.Marble <int> 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0,…
#> $ Floors        <int> 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1,…
#> $ City          <int> 3, 2, 2, 1, 2, 1, 3, 1, 1, 2, 1, 2, 1, 3, 3, 1, 3, 1, 3,…
#> $ Solar         <int> 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0,…
#> $ Electric      <int> 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,…
#> $ Fiber         <int> 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0,…
#> $ Glass.Doors   <int> 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1,…
#> $ Swiming.Pool  <int> 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0,…
#> $ Garden        <int> 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0,…
#> $ Prices        <int> 43800, 37550, 49500, 50075, 52400, 54300, 34400, 50425, …

Dari hasil diatas diketahui bahwa ada beberapa variabel memiliki tipe data yang tidak sesuai, sehingga kita perbaiki sebagai berikut :

house$Garage <- as.factor(house$Garage)
house$FirePlace <- as.factor(house$FirePlace)
house$Baths <- as.factor(house$Baths)
house$White.Marble <- as.factor(house$White.Marble)
house$Black.Marble <- as.factor(house$Black.Marble)
house$Indian.Marble <- as.factor(house$Indian.Marble)
house$Floors <- as.factor(house$Floors)
house$City <- as.factor(house$City)
house$Solar <- as.factor(house$Solar)
house$Electric <- as.factor(house$Electric)
house$Fiber <- as.factor(house$Fiber)
house$Glass.Doors <- as.factor(house$Glass.Doors)
house$Swiming.Pool <- as.factor(house$Swiming.Pool)
house$Garden <- as.factor(house$Garden)
house <-  house %>% 
  select(-Indian.Marble)

glimpse(house)
#> Rows: 500,000
#> Columns: 15
#> $ Area         <int> 164, 84, 190, 75, 148, 124, 58, 249, 243, 242, 61, 189, 1…
#> $ Garage       <fct> 2, 2, 2, 2, 1, 3, 1, 2, 1, 1, 2, 2, 2, 3, 3, 3, 1, 3, 2, …
#> $ FirePlace    <fct> 0, 0, 4, 4, 4, 3, 0, 1, 0, 2, 4, 0, 0, 3, 3, 4, 0, 3, 3, …
#> $ Baths        <fct> 2, 4, 4, 4, 2, 3, 2, 1, 2, 4, 5, 4, 2, 3, 1, 1, 5, 3, 5, …
#> $ White.Marble <fct> 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, …
#> $ Black.Marble <fct> 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, …
#> $ Floors       <fct> 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, …
#> $ City         <fct> 3, 2, 2, 1, 2, 1, 3, 1, 1, 2, 1, 2, 1, 3, 3, 1, 3, 1, 3, …
#> $ Solar        <fct> 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, …
#> $ Electric     <fct> 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, …
#> $ Fiber        <fct> 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, …
#> $ Glass.Doors  <fct> 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, …
#> $ Swiming.Pool <fct> 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, …
#> $ Garden       <fct> 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, …
#> $ Prices       <int> 43800, 37550, 49500, 50075, 52400, 54300, 34400, 50425, 2…

Tipe data telah sesuai


3 Explanatory Data Analysis

3.1 Cek Persebaran Data setiap Variabel

Untuk melihat persebaran data bisa kita lakukan dengan visualisasi menggunakan boxplot

boxplot(house$Area)

💡 Insight :

  • Data berdistribusi normal
  • Tidak terdapat outlier
hist(house$Prices)

boxplot(house$Prices)

💡 Insight :

  • Data berdistribusi normal
  • Tidak terdapat outlier

4 Model Fitting

4.1 Pembuatan Model Regresi Linear

model_all <- lm(formula = Prices ~ .,
                data = house)

4.2 Feature Selection dengan Stepwise Regression

model_both <- step(object = model_all,
                   direction = "both")
#> Start:  AIC=-15952426
#> Prices ~ Area + Garage + FirePlace + Baths + White.Marble + Black.Marble + 
#>     Floors + City + Solar + Electric + Fiber + Glass.Doors + 
#>     Swiming.Pool + Garden
#> 
#>                Df      Sum of Sq            RSS       AIC
#> - Garden        1              0              0 -15952427
#> - Swiming.Pool  1              0              0 -15952427
#> <none>                                        0 -15952426
#> - Solar         1     7812091498     7812091498   4828332
#> - Electric      1   195307211138   195307211138   6437782
#> - FirePlace     4   562330991840   562330991840   6966535
#> - Garage        2   750900463652   750900463652   7111130
#> - Baths         4  1562461718726  1562461718726   7477498
#> - Area          1  1610742706484  1610742706484   7492721
#> - Black.Marble  1  2084309361443  2084309361443   7621592
#> - Glass.Doors   1  2475202284839  2475202284839   7707534
#> - City          2  4080202933376  4080202933376   7957444
#> - White.Marble  1 16348430238630 16348430238630   8651439
#> - Fiber         1 17256996658724 17256996658724   8678482
#> - Floors        1 28124091525139 28124091525139   8922686
#> 
#> Step:  AIC=-15952427
#> Prices ~ Area + Garage + FirePlace + Baths + White.Marble + Black.Marble + 
#>     Floors + City + Solar + Electric + Fiber + Glass.Doors + 
#>     Swiming.Pool
#> 
#>                Df      Sum of Sq            RSS       AIC
#> - Swiming.Pool  1              0              0 -15952428
#> <none>                                        0 -15952427
#> + Garden        1              0              0 -15952426
#> - Solar         1     7812233367     7812233367   4828339
#> - Electric      1   195307322730   195307322730   6437780
#> - FirePlace     4   562331022984   562331022984   6966533
#> - Garage        2   750900774021   750900774021   7111128
#> - Baths         4  1562466350859  1562466350859   7477498
#> - Area          1  1610745975777  1610745975777   7492720
#> - Black.Marble  1  2084310446123  2084310446123   7621590
#> - Glass.Doors   1  2475229827725  2475229827725   7707537
#> - City          2  4080208939499  4080208939499   7957443
#> - White.Marble  1 16348452900853 16348452900853   8651438
#> - Fiber         1 17256996659639 17256996659639   8678480
#> - Floors        1 28124098536696 28124098536696   8922684
#> 
#> Step:  AIC=-15952428
#> Prices ~ Area + Garage + FirePlace + Baths + White.Marble + Black.Marble + 
#>     Floors + City + Solar + Electric + Fiber + Glass.Doors
#> 
#>                Df      Sum of Sq            RSS       AIC
#> <none>                                        0 -15952428
#> + Swiming.Pool  1              0              0 -15952427
#> + Garden        1              0              0 -15952427
#> - Solar         1     7812235041     7812235041   4828337
#> - Electric      1   195307386164   195307386164   6437779
#> - FirePlace     4   562331958685   562331958685   6966531
#> - Garage        2   750901679540   750901679540   7111127
#> - Baths         4  1562474050274  1562474050274   7477498
#> - Area          1  1610746592545  1610746592545   7492718
#> - Black.Marble  1  2084310592520  2084310592520   7621588
#> - Glass.Doors   1  2475230252103  2475230252103   7707536
#> - City          2  4080209428704  4080209428704   7957441
#> - White.Marble  1 16348504752391 16348504752391   8651437
#> - Fiber         1 17257290426898 17257290426898   8678486
#> - Floors        1 28124099845304 28124099845304   8922682
summary(model_both)
#> 
#> Call:
#> lm(formula = Prices ~ Area + Garage + FirePlace + Baths + White.Marble + 
#>     Black.Marble + Floors + City + Solar + Electric + Fiber + 
#>     Glass.Doors, data = house)
#> 
#> Residuals:
#>          Min           1Q       Median           3Q          Max 
#> -0.000083445  0.000000000  0.000000000  0.000000001  0.000000092 
#> 
#> Coefficients:
#>                            Estimate            Std. Error        t value
#> (Intercept)    7249.999999882059456     0.000000000801755  9042657945567
#> Area             25.000000000000817     0.000000000002325 10754102801015
#> Garage2        1499.999999998853809     0.000000000409151  3666125295609
#> Garage3        2999.999999999741249     0.000000000408573  7342633460738
#> FirePlace1      750.000000001087869     0.000000000528380  1419432406822
#> FirePlace2     1500.000000001110266     0.000000000528423  2838634947855
#> FirePlace3     2250.000000000819455     0.000000000528138  4260252325081
#> FirePlace4     3000.000000001255103     0.000000000527931  5682563123348
#> Baths2         1249.999999998888370     0.000000000527645  2369017780308
#> Baths3         2499.999999999881311     0.000000000527167  4742326164350
#> Baths4         3749.999999999895408     0.000000000527385  7110548267275
#> Baths5         4999.999999999692591     0.000000000527713  9474849432782
#> White.Marble1 14000.000000000969521     0.000000000408628 34260965060715
#> Black.Marble1  4999.999999999665306     0.000000000408722 12233248302610
#> Floors1       15000.000000000456566     0.000000000333804 44936566776931
#> City2          3499.999999999886313     0.000000000408899  8559577106577
#> City3          6999.999999999483407     0.000000000408975 17115975593609
#> Solar1          249.999999999670933     0.000000000333804   748942064621
#> Electric1      1249.999999999619604     0.000000000333803  3744724800511
#> Fiber1        11749.999999999832653     0.000000000333804 35200341515226
#> Glass.Doors1   4449.999999999620741     0.000000000333804 13331173333021
#>                          Pr(>|t|)    
#> (Intercept)   <0.0000000000000002 ***
#> Area          <0.0000000000000002 ***
#> Garage2       <0.0000000000000002 ***
#> Garage3       <0.0000000000000002 ***
#> FirePlace1    <0.0000000000000002 ***
#> FirePlace2    <0.0000000000000002 ***
#> FirePlace3    <0.0000000000000002 ***
#> FirePlace4    <0.0000000000000002 ***
#> Baths2        <0.0000000000000002 ***
#> Baths3        <0.0000000000000002 ***
#> Baths4        <0.0000000000000002 ***
#> Baths5        <0.0000000000000002 ***
#> White.Marble1 <0.0000000000000002 ***
#> Black.Marble1 <0.0000000000000002 ***
#> Floors1       <0.0000000000000002 ***
#> City2         <0.0000000000000002 ***
#> City3         <0.0000000000000002 ***
#> Solar1        <0.0000000000000002 ***
#> Electric1     <0.0000000000000002 ***
#> Fiber1        <0.0000000000000002 ***
#> Glass.Doors1  <0.0000000000000002 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 0.000000118 on 499979 degrees of freedom
#> Multiple R-squared:      1,  Adjusted R-squared:      1 
#> F-statistic: 2.632e+26 on 20 and 499979 DF,  p-value: < 0.00000000000000022

5 Prediction

5.1 prediksi biasa

house$pred_all <- predict(object = model_all, newdata = house)
house$pred_both<- predict(object = model_both, newdata = house)

6 Model Comparison

Tujuan: mendapatkan model terbaik untuk prediksi variabel target.

6.1 Goodness of Fit

Bandingkan nilai R-Squared dari model-model yang telah dibuat

summary(model_all)$adj.r.squared
#> [1] 1
summary(model_both)$adj.r.squared
#> [1] 1

💡 Kesimpulan : model yang dapat menjelaskan variabel target dengan baik adalah model backward, yakni sebesar 0.8893899 atau 88,94% (ubah)

6.2 Model Evaluation

6.2.1 Root Mean Squared Error (RMSE)

library(MLmetrics)
# RMSE model_all
RMSE(y_pred = house$pred_all ,
    y_true = house$Prices)
#> [1] 0.000000118177
# RMSE model_both
RMSE(y_pred = house$pred_both ,
    y_true = house$Prices)
#> [1] 0.0000001181808

💡 Kesimpulan : model yang memberikan error paling kecil dalam memprediksi nilai prices adalah model_all, dengan nilai RMSE sebesar 1.18177e-07


7 Model Interpretation

summary(model_all) 
#> 
#> Call:
#> lm(formula = Prices ~ ., data = house)
#> 
#> Residuals:
#>          Min           1Q       Median           3Q          Max 
#> -0.000083445  0.000000000  0.000000000  0.000000001  0.000000092 
#> 
#> Coefficients:
#>                            Estimate            Std. Error            t value
#> (Intercept)    7249.999999881726580     0.000000000835385  8678633299331.416
#> Area             25.000000000000814     0.000000000002325 10754090212740.080
#> Garage2        1499.999999998852672     0.000000000409153  3666113453753.977
#> Garage3        2999.999999999741249     0.000000000408573  7342627761164.181
#> FirePlace1      750.000000001088097     0.000000000528381  1419429641645.870
#> FirePlace2     1500.000000001110720     0.000000000528424  2838627974020.207
#> FirePlace3     2250.000000000820819     0.000000000528138  4260249664266.809
#> FirePlace4     3000.000000001254193     0.000000000527932  5682552052029.521
#> Baths2         1249.999999998889507     0.000000000527646  2369012349150.285
#> Baths3         2499.999999999881311     0.000000000527168  4742325705127.095
#> Baths4         3749.999999999894499     0.000000000527386  7110538763347.890
#> Baths5         4999.999999999691681     0.000000000527714  9474829554929.393
#> White.Marble1 14000.000000000969521     0.000000000408629 34260888207125.945
#> Black.Marble1  4999.999999999665306     0.000000000408722 12233245127069.418
#> Floors1       15000.000000000456566     0.000000000333804 44936561735872.031
#> City2          3499.999999999884949     0.000000000408899  8559562789832.808
#> City3          6999.999999999482498     0.000000000408975 17115962557464.693
#> Solar1          249.999999999672553     0.000000000333807   748935210803.985
#> Electric1      1249.999999999619149     0.000000000333803  3744723256402.335
#> Fiber1        11749.999999999830834     0.000000000333806 35200043166926.719
#> Glass.Doors1   4449.999999999619831     0.000000000333806 13331098495737.248
#> Swiming.Pool1     0.000000000338430     0.000000000333806              1.014
#> Garden1           0.000000000335183     0.000000000333811              1.004
#>                          Pr(>|t|)    
#> (Intercept)   <0.0000000000000002 ***
#> Area          <0.0000000000000002 ***
#> Garage2       <0.0000000000000002 ***
#> Garage3       <0.0000000000000002 ***
#> FirePlace1    <0.0000000000000002 ***
#> FirePlace2    <0.0000000000000002 ***
#> FirePlace3    <0.0000000000000002 ***
#> FirePlace4    <0.0000000000000002 ***
#> Baths2        <0.0000000000000002 ***
#> Baths3        <0.0000000000000002 ***
#> Baths4        <0.0000000000000002 ***
#> Baths5        <0.0000000000000002 ***
#> White.Marble1 <0.0000000000000002 ***
#> Black.Marble1 <0.0000000000000002 ***
#> Floors1       <0.0000000000000002 ***
#> City2         <0.0000000000000002 ***
#> City3         <0.0000000000000002 ***
#> Solar1        <0.0000000000000002 ***
#> Electric1     <0.0000000000000002 ***
#> Fiber1        <0.0000000000000002 ***
#> Glass.Doors1  <0.0000000000000002 ***
#> Swiming.Pool1               0.311    
#> Garden1                     0.315    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 0.000000118 on 499977 degrees of freedom
#> Multiple R-squared:      1,  Adjusted R-squared:      1 
#> F-statistic: 2.393e+26 on 22 and 499977 DF,  p-value: < 0.00000000000000022

Interpretasi

  1. Intercept = 7.250e+03, artinya nilai prices akan sebesar 7.250e+03 apabila Garage = 0, FirePlace = 0, Baths = 0, White.Marble = 0, Black.Marble = 0, Floors = 0, City = 0,Solar = 0,Electric = 0,Fiber= 0,Glass.Doors = 0, Swiming.Pool= 0, Garden= 0, dan variabel prediktor lainnya bernilai 0.

  2. Interpretasi coefficient untuk prediktor kategorik :

  1. Garage
  • Garage1 = 0 menjadi basis
  • Garage2 = 1.500e+03, artinya nilai prices akan meningkat sebesar 1.500e+03 apabila rumah memiliki jumlah garasi sebanyak 2 dan variabel prediktor lainnya bernilai tetap
  • Garage3 = 3.000e+03, artinya nilai prices akan meningkat sebesar 3.000e+03 apabila rumah memiliki jumlah garasi sebanyak 3 dan variabel prediktor lainnya bernilai tetap
  1. Garden
  • Garden = 0 basis
  • Garden1 = 3.336e-10, artinya nilai prices akan menurun sebesar 3.336e-10 apabila rumah memiliki jumlah taman dan variabel prediktor lainnya bernilai tetap
  1. Floors
  • Floors = 0 basis
  • Floors1 = 1.500e+04, artinya nilai Floors akan meningkat sebesar 1.500e+04 apabila rumah memiliki lnatai dan variabel prediktor lainnya bernilai tetap
  1. Interpretasi coefficient untuk prediktor numerik:
  1. Area = 2.500e+01, artinya nilai Prices akan meningkat sebesar 2.500e+01 dengan catatan nilai variabel prediktor lainnya bernilai tetap
  1. Signifikansi prediktor:
  • variabel prediktor yang signifikan berpengaruh terhadap prices adalah Area, Garage, FirePlace, Baths, White.Marble, Black.Marble, Indian.Marble, Floors, City,Solar, Electric,Fiber,Glass.Doors
  1. Adjusted R-squared:
  • 1 , artinya model kita bisa menjelaskan prices dengan baik sebesar 100%

8 Model Assumption

8.1 Linearity

plot(model_all, 
     which = 1) # residual vs fitted

💡 Kesimpulan: Model yang dimiliki memenuhi asumsi linieriats

8.2 Shapiro test untuk Uji Asumsi Normality of Residuals

# histogram residual
hist(model_all$residuals)

-> Uji statistik dengan shapiro.test()

Shapiro-Wilk hypothesis test:

H0: error berdistribusi normal H1: error TIDAK berdistribusi normal H0 ditolak jika p-values < 0.05 (alpha)

# shapiro test dari residual
shapiro.test(model_all$residuals[0:5000])
#> 
#>  Shapiro-Wilk normality test
#> 
#> data:  model_all$residuals[0:5000]
#> W = 0.0031622, p-value < 0.00000000000000022
# QQ Plot
plot(model_all, which = 2)

💡 Kesimpulan: p-value = 0.6662, artinya residual data berdistribusi normal

8.3 Breusch-Pagan untuk Uji Asumsi Homoscedasticity

# scatter plot
plot(x = model_all$fitted.values, y = model_all$residuals)
abline(h = 0, col = "red") # garis horizontal di angka 0

-> Uji statistik dengan bptest() dari package lmtest Breusch-Pagan hypothesis test:

H0: error menyebar konstan atau homoscedasticity H1: error menyebar TIDAK konstan atau heteroscedasticity

# bptest dari model
library(lmtest)
bptest(model_all)
#> 
#>  studentized Breusch-Pagan test
#> 
#> data:  model_all
#> BP = 21.358, df = 22, p-value = 0.4987

💡 Kesimpulan: p-value = 0.3744 > 0.05, artinya error tersebar secara acak atau homoskedastisitas

8.4 No Multicollinearity

Uji VIF (Variance Inflation Factor) dengan fungsi vif() dari package car:

nilai VIF > 10: terjadi multicollinearity pada model nilai VIF < 10: tidak terjadi multicollinearity pada model

# vif dari model_backward
library(car)
vif(model_all)
#>                  GVIF Df GVIF^(1/(2*Df))
#> Area         1.000036  1        1.000018
#> Garage       1.000103  2        1.000026
#> FirePlace    1.000123  4        1.000015
#> Baths        1.000159  4        1.000020
#> White.Marble 1.331419  1        1.153871
#> Black.Marble 1.331420  1        1.153872
#> Floors       1.000031  1        1.000015
#> City         1.000102  2        1.000026
#> Solar        1.000045  1        1.000023
#> Electric     1.000025  1        1.000013
#> Fiber        1.000046  1        1.000023
#> Glass.Doors  1.000044  1        1.000022
#> Swiming.Pool 1.000047  1        1.000023
#> Garden       1.000065  1        1.000032

💡 Kesimpulan: seluruh variabel prediktor memenuhi asumsi no multicolinierity

Model_all memenuhi keseluruhan asumsi regresi


9 Rekomendasi

Terdapat beberapa tindakan yang dapat diambil untuk meningkatkan keakuratan prediksi harga rumah berdasarkan model regresi linear. Berikut adalah beberapa contoh saran:

  1. Memilih fitur yang relevan: Melakukan analisis lebih lanjut untuk mengidentifikasi fitur-fitur yang paling berpengaruh terhadap harga rumah. Gunakan teknik seperti analisis korelasi atau seleksi fitur untuk menentukan atribut-atribut yang memiliki hubungan kuat dengan harga rumah. Dengan memilih fitur yang relevan, model dapat fokus pada variabel yang benar-benar mempengaruhi harga rumah.

  2. Mengumpulkan atribut yang lebih lengkap: Pastikan dataset yang digunakan untuk melatih model mengandung atribut-atribut yang relevan dan komprehensif. Pertimbangkan untuk menyertakan informasi seperti ukuran tanah, lokasi, fasilitas terdekat, kondisi bangunan, dan sebagainya. Semakin lengkap atribut yang dimiliki, semakin akurat prediksi harga rumah.