## # A tibble: 6 × 13
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1147 Zona O… <NA> 3 250 70 1 3 6
## 2 1169 Zona O… <NA> 3 320 120 1 2 3
## 3 1350 Zona O… <NA> 3 350 220 2 2 4
## 4 5992 Zona S… 02 4 400 280 3 5 3
## 5 1212 Zona N… 01 5 260 90 1 2 3
## 6 1724 Zona N… 01 5 240 87 1 3 3
## # ℹ 4 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>
## id zona piso estrato
## Min. : 1 Length:8322 Length:8322 Min. :3.000
## 1st Qu.:2080 Class :character Class :character 1st Qu.:4.000
## Median :4160 Mode :character Mode :character Median :5.000
## Mean :4160 Mean :4.634
## 3rd Qu.:6240 3rd Qu.:5.000
## Max. :8319 Max. :6.000
## NA's :3 NA's :3
## preciom areaconst parqueaderos banios
## Min. : 58.0 Min. : 30.0 Min. : 1.000 Min. : 0.000
## 1st Qu.: 220.0 1st Qu.: 80.0 1st Qu.: 1.000 1st Qu.: 2.000
## Median : 330.0 Median : 123.0 Median : 2.000 Median : 3.000
## Mean : 433.9 Mean : 174.9 Mean : 1.835 Mean : 3.111
## 3rd Qu.: 540.0 3rd Qu.: 229.0 3rd Qu.: 2.000 3rd Qu.: 4.000
## Max. :1999.0 Max. :1745.0 Max. :10.000 Max. :10.000
## NA's :2 NA's :3 NA's :1605 NA's :3
## habitaciones tipo barrio longitud
## Min. : 0.000 Length:8322 Length:8322 Min. :-76.59
## 1st Qu.: 3.000 Class :character Class :character 1st Qu.:-76.54
## Median : 3.000 Mode :character Mode :character Median :-76.53
## Mean : 3.605 Mean :-76.53
## 3rd Qu.: 4.000 3rd Qu.:-76.52
## Max. :10.000 Max. :-76.46
## NA's :3 NA's :3
## latitud
## Min. :3.333
## 1st Qu.:3.381
## Median :3.416
## Mean :3.418
## 3rd Qu.:3.452
## Max. :3.498
## NA's :3
## id zona piso estrato preciom areaconst
## "numeric" "character" "character" "numeric" "numeric" "numeric"
## parqueaderos banios habitaciones tipo barrio longitud
## "numeric" "numeric" "numeric" "character" "character" "numeric"
## latitud
## "numeric"
## [1] 4275
## NUMERO DE VALORES FALTANTES
## id 3
## zona 3
## piso 2638
## estrato 3
## preciom 2
## areaconst 3
## parqueaderos 1605
## banios 3
## habitaciones 3
## tipo 3
## barrio 3
## longitud 3
## latitud 3
## # A tibble: 5 × 2
## zona n
## <chr> <int>
## 1 Zona Centro 100
## 2 Zona Norte 722
## 3 Zona Oeste 169
## 4 Zona Oriente 289
## 5 Zona Sur 1939
## # A tibble: 3 × 13
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1147 Zona O… <NA> 3 250 70 1 3 6
## 2 1169 Zona O… <NA> 3 320 120 1 2 3
## 3 1350 Zona O… <NA> 3 350 220 2 2 4
## # ℹ 4 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>
## # A tibble: 5 × 2
## zona n
## <chr> <int>
## 1 Zona Sur 1939
## 2 Zona Norte 722
## 3 Zona Oriente 289
## 4 Zona Oeste 169
## 5 Zona Centro 100
| zona | n |
|---|---|
| Zona Centro | 100 |
| Zona Norte | 722 |
| Zona Oeste | 169 |
| Zona Oriente | 289 |
| Zona Sur | 1939 |
## Rows: 4,808
## Columns: 13
## $ id <dbl> 5992, 1212, 1724, 2326, 4386, 1209, 1592, 4460, 6081, 749…
## $ zona <chr> "Zona Sur", "Zona Norte", "Zona Norte", "Zona Norte", "Zo…
## $ piso <dbl> 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5, 5, 5, …
## $ estrato <dbl> 4, 5, 5, 4, 5, 5, 5, 4, 5, 6, 4, 5, 5, 4, 5, 3, 6, 6, 4, …
## $ preciom <dbl> 400, 260, 240, 220, 310, 320, 780, 625, 750, 520, 600, 42…
## $ areaconst <dbl> 280, 90, 87, 52, 137, 150, 380, 355, 237, 98, 160, 200, 1…
## $ parqueaderos <dbl> 3, 1, 1, 2, 2, 2, 2, 3, 2, 2, 1, 4, 2, 2, 2, 1, 1, 2, 1, …
## $ banios <dbl> 5, 2, 3, 2, 3, 4, 3, 5, 6, 2, 4, 4, 4, 3, 2, 2, 4, 3, 2, …
## $ habitaciones <dbl> 3, 3, 3, 3, 4, 6, 3, 5, 6, 2, 5, 5, 4, 3, 3, 3, 4, 4, 3, …
## $ tipo <chr> "Casa", "Apartamento", "Apartamento", "Apartamento", "Apa…
## $ barrio <chr> "3 de julio", "acopi", "acopi", "acopi", "acopi", "acopi"…
## $ longitud <dbl> -76.54000, -76.51350, -76.51700, -76.51974, -76.53105, -7…
## $ latitud <dbl> 3.43500, 3.45891, 3.36971, 3.42627, 3.38296, 3.47968, 3.4…
## # A tibble: 15 × 13
## # Groups: zona [5]
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 5298 Zona … 1 3 650 240 2 4 4
## 2 5608 Zona … 3 3 295 200 1 5 9
## 3 2879 Zona … 1 3 148 86 1 2 3
## 4 1209 Zona … 2 5 320 150 2 4 6
## 5 1592 Zona … 2 5 780 380 2 3 3
## 6 4460 Zona … 2 4 625 355 3 5 5
## 7 6928 Zona … 3 6 1850 302 4 4 3
## 8 7510 Zona … 3 6 1950 400 4 5 3
## 9 7586 Zona … 3 6 870 275 3 5 4
## 10 77 Zona … 1 3 190 410 1 2 2
## 11 85 Zona … 1 3 200 146 1 2 4
## 12 99 Zona … 1 3 403 384 1 3 5
## 13 5992 Zona … 2 4 400 280 3 5 3
## 14 5157 Zona … 2 3 500 354 1 2 4
## 15 8187 Zona … 2 5 650 200 2 4 3
## # ℹ 4 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>
“Precio2vs. Área”
## preciom areaconst estrato banios habitaciones
## preciom 1.00 0.65 0.67 0.56 0.10
## areaconst 0.65 1.00 0.37 0.49 0.29
## estrato 0.67 0.37 1.00 0.45 -0.11
## banios 0.56 0.49 0.45 1.00 0.48
## habitaciones 0.10 0.29 -0.11 0.48 1.00
##El número de habitaciones está correlacionado positivamente con el precio, con una correlación de 0.434. Esto significa que, en general, las viviendas con más habitaciones tienen un precio más alto. ## La correlación más fuerte es entre el precio y el área construida. ## Las casas ubicadas en zonas de mayor estrato tienen un precio más alto. ## Las casas con más baños y habitaciones también tienen un precio más alto.
##
## Call:
## lm(formula = preciom ~ areaconst + estrato + banios + habitaciones,
## data = vivienda)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1713.69 -92.48 -20.01 58.45 1154.29
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -379.5673 11.7870 -32.20 <2e-16 ***
## areaconst 1.0697 0.0188 56.89 <2e-16 ***
## estrato 111.6148 2.3759 46.98 <2e-16 ***
## banios 67.7328 2.2695 29.84 <2e-16 ***
## habitaciones -28.1710 1.9294 -14.60 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 181 on 8314 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.6969, Adjusted R-squared: 0.6967
## F-statistic: 4778 on 4 and 8314 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = preciom ~ areaconst + estrato + banios + habitaciones,
## data = vivienda)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1713.69 -92.48 -20.01 58.45 1154.29
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -379.5673 11.7870 -32.20 <2e-16 ***
## areaconst 1.0697 0.0188 56.89 <2e-16 ***
## estrato 111.6148 2.3759 46.98 <2e-16 ***
## banios 67.7328 2.2695 29.84 <2e-16 ***
## habitaciones -28.1710 1.9294 -14.60 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 181 on 8314 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.6969, Adjusted R-squared: 0.6967
## F-statistic: 4778 on 4 and 8314 DF, p-value: < 2.2e-16
## El R-squared del modelo es de 0.6968704
## El error estándar del modelo es de 180.9973
## El valor p del modelo es de 0
#Implicaciones para mejorar el modelo
##
## Call:
## lm(formula = preciom ~ areaconst + estrato + banios + habitaciones,
## data = vivienda)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1116.17 -92.85 -18.66 58.61 1168.24
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -406.84377 17.31983 -23.49 <2e-16 ***
## areaconst 1.10769 0.02653 41.75 <2e-16 ***
## estrato 112.51368 3.36061 33.48 <2e-16 ***
## banios 78.18940 3.13934 24.91 <2e-16 ***
## habitaciones -35.23561 2.75381 -12.79 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 179.2 on 4803 degrees of freedom
## Multiple R-squared: 0.6972, Adjusted R-squared: 0.697
## F-statistic: 2765 on 4 and 4803 DF, p-value: < 2.2e-16
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Durbin-Watson test
##
## data: df_casas
## DW = 1.6116, p-value < 2.2e-16
## alternative hypothesis: true autocorrelation is greater than 0
## areaconst estrato banios habitaciones
## 2.014155 1.449921 2.692335 2.009601
## 1
## 280.1854
## 1
## 392.6991
## # A tibble: 2 × 14
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 226 Zona O… <NA> 3 310 250 1 2 3
## 2 6963 Zona S… 02 3 335 200 1 2 3
## # ℹ 5 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>,
## # precio <dbl>
## # A tibble: 6 × 13
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1147 Zona O… <NA> 3 250 70 1 3 6
## 2 1169 Zona O… <NA> 3 320 120 1 2 3
## 3 1350 Zona O… <NA> 3 350 220 2 2 4
## 4 5992 Zona S… 02 4 400 280 3 5 3
## 5 1212 Zona N… 01 5 260 90 1 2 3
## 6 1724 Zona N… 01 5 240 87 1 3 3
## # ℹ 4 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>
## id zona piso estrato
## Min. : 1 Length:8322 Length:8322 Min. :3.000
## 1st Qu.:2080 Class :character Class :character 1st Qu.:4.000
## Median :4160 Mode :character Mode :character Median :5.000
## Mean :4160 Mean :4.634
## 3rd Qu.:6240 3rd Qu.:5.000
## Max. :8319 Max. :6.000
## NA's :3 NA's :3
## preciom areaconst parqueaderos banios
## Min. : 58.0 Min. : 30.0 Min. : 1.000 Min. : 0.000
## 1st Qu.: 220.0 1st Qu.: 80.0 1st Qu.: 1.000 1st Qu.: 2.000
## Median : 330.0 Median : 123.0 Median : 2.000 Median : 3.000
## Mean : 433.9 Mean : 174.9 Mean : 1.835 Mean : 3.111
## 3rd Qu.: 540.0 3rd Qu.: 229.0 3rd Qu.: 2.000 3rd Qu.: 4.000
## Max. :1999.0 Max. :1745.0 Max. :10.000 Max. :10.000
## NA's :2 NA's :3 NA's :1605 NA's :3
## habitaciones tipo barrio longitud
## Min. : 0.000 Length:8322 Length:8322 Min. :-76.59
## 1st Qu.: 3.000 Class :character Class :character 1st Qu.:-76.54
## Median : 3.000 Mode :character Mode :character Median :-76.53
## Mean : 3.605 Mean :-76.53
## 3rd Qu.: 4.000 3rd Qu.:-76.52
## Max. :10.000 Max. :-76.46
## NA's :3 NA's :3
## latitud
## Min. :3.333
## 1st Qu.:3.381
## Median :3.416
## Mean :3.418
## 3rd Qu.:3.452
## Max. :3.498
## NA's :3
## id zona piso estrato preciom areaconst
## "numeric" "character" "character" "numeric" "numeric" "numeric"
## parqueaderos banios habitaciones tipo barrio longitud
## "numeric" "numeric" "numeric" "character" "character" "numeric"
## latitud
## "numeric"
## [1] 4275
## NUMERO DE VALORES FALTANTES
## id 3
## zona 3
## piso 2638
## estrato 3
## preciom 2
## areaconst 3
## parqueaderos 1605
## banios 3
## habitaciones 3
## tipo 3
## barrio 3
## longitud 3
## latitud 3
## # A tibble: 5 × 2
## zona n
## <chr> <int>
## 1 Zona Centro 24
## 2 Zona Norte 1198
## 3 Zona Oeste 1029
## 4 Zona Oriente 62
## 5 Zona Sur 2787
## # A tibble: 3 × 13
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1147 Zona O… <NA> 3 250 70 1 3 6
## 2 1169 Zona O… <NA> 3 320 120 1 2 3
## 3 1350 Zona O… <NA> 3 350 220 2 2 4
## # ℹ 4 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>
## # A tibble: 5 × 2
## zona n
## <chr> <int>
## 1 Zona Sur 2787
## 2 Zona Norte 1198
## 3 Zona Oeste 1029
## 4 Zona Oriente 62
## 5 Zona Centro 24
| zona | n |
|---|---|
| Zona Centro | 24 |
| Zona Norte | 1198 |
| Zona Oeste | 1029 |
| Zona Oriente | 62 |
| Zona Sur | 2787 |
## Rows: 4,808
## Columns: 13
## $ id <dbl> 5992, 1212, 1724, 2326, 4386, 1209, 1592, 4460, 6081, 749…
## $ zona <chr> "Zona Sur", "Zona Norte", "Zona Norte", "Zona Norte", "Zo…
## $ piso <dbl> 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5, 5, 5, …
## $ estrato <dbl> 4, 5, 5, 4, 5, 5, 5, 4, 5, 6, 4, 5, 5, 4, 5, 3, 6, 6, 4, …
## $ preciom <dbl> 400, 260, 240, 220, 310, 320, 780, 625, 750, 520, 600, 42…
## $ areaconst <dbl> 280, 90, 87, 52, 137, 150, 380, 355, 237, 98, 160, 200, 1…
## $ parqueaderos <dbl> 3, 1, 1, 2, 2, 2, 2, 3, 2, 2, 1, 4, 2, 2, 2, 1, 1, 2, 1, …
## $ banios <dbl> 5, 2, 3, 2, 3, 4, 3, 5, 6, 2, 4, 4, 4, 3, 2, 2, 4, 3, 2, …
## $ habitaciones <dbl> 3, 3, 3, 3, 4, 6, 3, 5, 6, 2, 5, 5, 4, 3, 3, 3, 4, 4, 3, …
## $ tipo <chr> "Casa", "Apartamento", "Apartamento", "Apartamento", "Apa…
## $ barrio <chr> "3 de julio", "acopi", "acopi", "acopi", "acopi", "acopi"…
## $ longitud <dbl> -76.54000, -76.51350, -76.51700, -76.51974, -76.53105, -7…
## $ latitud <dbl> 3.43500, 3.45891, 3.36971, 3.42627, 3.38296, 3.47968, 3.4…
## # A tibble: 15 × 13
## # Groups: zona [5]
## id zona piso estrato preciom areaconst parqueaderos banios habitaciones
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4408 Zona … 5 3 120 84 1 2 3
## 2 4305 Zona … 5 3 120 84 1 2 3
## 3 1130 Zona … 4 4 170 96 1 3 2
## 4 1212 Zona … 1 5 260 90 1 2 3
## 5 1724 Zona … 1 5 240 87 1 3 3
## 6 2326 Zona … 1 4 220 52 2 2 3
## 7 6999 Zona … 1 6 870 200 2 5 3
## 8 8055 Zona … 1 4 165 61 1 2 3
## 9 8058 Zona … 1 4 165 61 1 2 2
## 10 82 Zona … 1 3 115 111 1 2 4
## 11 78 Zona … 2 3 58 50 1 1 2
## 12 2342 Zona … 5 3 113 72 1 1 3
## 13 5098 Zona … 5 4 290 96 1 2 3
## 14 698 Zona … 2 3 78 40 1 1 2
## 15 6975 Zona … 6 4 220 75 1 2 3
## # ℹ 4 more variables: tipo <chr>, barrio <chr>, longitud <dbl>, latitud <dbl>
## preciom areaconst estrato banios habitaciones
## preciom 1.00 0.83 0.67 0.74 0.30
## areaconst 0.83 1.00 0.55 0.73 0.41
## estrato 0.67 0.55 1.00 0.62 0.18
## banios 0.74 0.73 0.62 1.00 0.50
## habitaciones 0.30 0.41 0.18 0.50 1.00
##
## Call:
## lm(formula = preciom ~ areaconst + estrato + banios + habitaciones,
## data = vivienda)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1713.69 -92.48 -20.01 58.45 1154.29
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -379.5673 11.7870 -32.20 <2e-16 ***
## areaconst 1.0697 0.0188 56.89 <2e-16 ***
## estrato 111.6148 2.3759 46.98 <2e-16 ***
## banios 67.7328 2.2695 29.84 <2e-16 ***
## habitaciones -28.1710 1.9294 -14.60 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 181 on 8314 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.6969, Adjusted R-squared: 0.6967
## F-statistic: 4778 on 4 and 8314 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = preciom ~ areaconst + estrato + banios + habitaciones,
## data = vivienda)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1713.69 -92.48 -20.01 58.45 1154.29
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -379.5673 11.7870 -32.20 <2e-16 ***
## areaconst 1.0697 0.0188 56.89 <2e-16 ***
## estrato 111.6148 2.3759 46.98 <2e-16 ***
## banios 67.7328 2.2695 29.84 <2e-16 ***
## habitaciones -28.1710 1.9294 -14.60 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 181 on 8314 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.6969, Adjusted R-squared: 0.6967
## F-statistic: 4778 on 4 and 8314 DF, p-value: < 2.2e-16
##
## Durbin-Watson test
##
## data: df_apartamentos_por_zona
## DW = 1.5964, p-value < 2.2e-16
## alternative hypothesis: true autocorrelation is greater than 0
## areaconst estrato banios habitaciones
## 1.834878 1.518246 2.667654 2.013418
## 1
## 561.7486
## 1
## 673.3634
## # A tibble: 0 × 14
## # ℹ 14 variables: id <dbl>, zona <chr>, piso <chr>, estrato <dbl>,
## # preciom <dbl>, areaconst <dbl>, parqueaderos <dbl>, banios <dbl>,
## # habitaciones <dbl>, tipo <chr>, barrio <chr>, longitud <dbl>,
## # latitud <dbl>, precio <dbl>