EJERCICIO 1. Prediccion de los precios de las acciones. Analizar el comportamiento de los precios de las Acciones de Ecopetrol segun la variacion del precio del barril de petroleo WTI producido en Colombia. Se tienen los siguientes precios

library(readxl)
library(ggplot2)
library(CGPfunctions)
## Warning: package 'CGPfunctions' was built under R version 4.1.2
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 4.1.2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
data1 = read_excel("G:/ACADEMIA/JAVERIANA CALI/2. SEMESTRE 2022 - II/2. Met. Estad. para la Toma Decisiones/Datos1.xlsx")
data1
## # A tibble: 18 x 3
##    fecha     Precio_accion Precio_WTIxBarril
##    <chr>             <dbl>             <dbl>
##  1 dic 14-15          1090              35.6
##  2 dic 15-15          1170              36.3
##  3 dic 16-15          1160              37.4
##  4 dic 18-15          1230              35.0
##  5 dic 21-15          1155              34.5
##  6 dic 22-15          1165              35.8
##  7 dic 23-15          1205              36.1
##  8 dic 24-15          1170              37.5
##  9 dic 28-15          1150              37.8
## 10 dic 29-15          1130              36.8
## 11 dic 30-15          1110              37.9
## 12 ene 04-16          1105              37.0
## 13 ene 05-16          1085              36.8
## 14 ene 06-16          1060              36.0
## 15 ene 07-16          1035              34.0
## 16 ene 08-16          1015              33.3
## 17 ene 12-16           955              31.4
## 18 ene 13-16           961              30.4

Desarrollo modelo

mod1=lm(Precio_accion~Precio_WTIxBarril, data = data1)
summary(mod1)
## 
## Call:
## lm(formula = Precio_accion ~ Precio_WTIxBarril, data = data1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -59.90 -40.74 -15.94  33.40 136.82 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)   
## (Intercept)        177.768    232.828   0.764  0.45627   
## Precio_WTIxBarril   26.192      6.542   4.004  0.00102 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 57.13 on 16 degrees of freedom
## Multiple R-squared:  0.5005, Adjusted R-squared:  0.4692 
## F-statistic: 16.03 on 1 and 16 DF,  p-value: 0.001024

a) La ecuacion esta dada por: Precio_accion=177.768+26.192*Precio_WTIxBarril

R^2=0.4692

b) Existe una relacion significativa entre Precio_accion y Precio_WTIxBarril, ya que el pvalue=0.001024, tomando como base ?? = 0.05

c) El precio minimo de la accion esperado es 177.768 si Precio_WTIxBarril=0 (intercepto) Por cada unidad en el precio Precio_WTIxBarril, el Precio_accion aumenta en 26.192

d) Validacion de supuestos

#exploracion bivariada
g1=ggplot(data=data1,mapping=
            aes(x=Precio_WTIxBarril,y=Precio_accion))+geom_point()+theme_bw()+
            geom_smooth()       
ggplotly(g1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
par(mfrow=c(2,2))
plot(mod1)

#normalidad en los residuales
shapiro.test(mod1$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  mod1$residuals
## W = 0.89259, p-value = 0.04276
ggplot(data = data1, aes(mod1$fitted.values, mod1$residuals)) +
geom_point() +
geom_smooth(color = "firebrick", se = FALSE) +
geom_hline(yintercept = 0) +
theme_bw()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

bptest(mod1)
## 
##  studentized Breusch-Pagan test
## 
## data:  mod1
## BP = 0.029563, df = 1, p-value = 0.8635

Conclusiones mod1: +Cumple normalidad +Cumple idenpendencia en los residuos +No cumple con el supuesto de homocedasticidad

e) Por lo anterior se requiere algun tipo de transformacion para garantizar la validez del modelo

EJERCICIO 2. Los siguientes datos corresponden a la INFLACION y al SALARIO MINIMO LEGAL MENSUAL (SMLM) desde el ano 1999 para Colombia.

data2 = read_excel("G:/ACADEMIA/JAVERIANA CALI/2. SEMESTRE 2022 - II/2. Met. Estad. para la Toma Decisiones/Datos2.xlsx")
data2
## # A tibble: 17 x 3
##      ANO INFLACION   SMLM
##    <dbl>     <dbl>  <dbl>
##  1  1999      9.23 236460
##  2  2000      8.75 260100
##  3  2001      7.65 286000
##  4  2002      6.99 309000
##  5  2003      6.49 332000
##  6  2004      5.5  358000
##  7  2005      4.85 381500
##  8  2006      4.48 408000
##  9  2007      5.69 433700
## 10  2008      7.67 461500
## 11  2009      2    496900
## 12  2010      3.17 515000
## 13  2011      3.73 535600
## 14  2012      2.44 566700
## 15  2013      1.94 589500
## 16  2014      3.66 616027
## 17  2015      6.77 644350

Desarrollo modelo

mod2=lm(SMLM~INFLACION, data = data2)
summary(mod2)
## 
## Call:
## lm(formula = SMLM ~ INFLACION, data = data2)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -75463 -63456 -42854  17623 263207 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   648486      58947   11.00  1.4e-08 ***
## INFLACION     -39489      10151   -3.89  0.00145 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 94130 on 15 degrees of freedom
## Multiple R-squared:  0.5022, Adjusted R-squared:  0.469 
## F-statistic: 15.13 on 1 and 15 DF,  p-value: 0.00145

a) La ecuacion esta dada por: SMLM=648486-39.489*INFLACION

R^2=0.469

b) Existe una relacion significativa entre INFLACION Y SMLM, ya que el pvalue=0.00145, tomando como base ?? = 0.05, sin embargo no es una relacion practica, quiza seria una mejor aprox relacionar la inflacion con las variaciones, ano a ano.

c)

cor(data2$SMLM,data2$INFLACION)
## [1] -0.7086581
summary(mod2)$r.squared
## [1] 0.5021963

Existe una correlacion alta negativa en las variables, el coeficiente de determinacion indica que solo el 50 porciento de la varianza de SMLM se explica con la inflacion.

d) Coeficientes mod2: 648486 (intercepto) indica el valor minimo de SMLM frente a una inflacion de cero. -39489 (pendiente) por cada unidad de inflacion se reduce en dicha proporcion el smlm.

e) analisis grafico

#exploracion bivariada
g2=ggplot(data=data2,mapping=
            aes(x=INFLACION,y=SMLM))+geom_point()+theme_bw()+
            geom_smooth()       
ggplotly(g2)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
par(mfrow=c(2,2))
plot(mod2)

Graficamente parece ser un modelo consistente, cumpliendo los supuestos correspondientes.

f) Es un modelo de regresion linea de baja capacidad de prediccion, ademas la interpretabilidad de los resultados no es lo suficientemente practica y robusta.

EJERCICIO 3. Con base en los datos de precios de vivienda de la actividad, realice los siguientes puntos:

a) Realice un filtro a la base de datos e incluya solo las ofertas de apartamentos,de la zona norte de la ciudad con precios inferiores a los 500 millones de pesos y areas menores a 300 mt2.

data3 = read_excel("G:/ACADEMIA/JAVERIANA CALI/2. SEMESTRE 2022 - II/2. Met. Estad. para la Toma Decisiones/Datos_Vivienda.xlsx")
data3
## # A tibble: 8,322 x 12
##    Zona       piso  Estrato precio_millon Area_contruida parqueaderos Banos
##    <chr>      <chr>   <dbl>         <dbl>          <dbl> <chr>        <dbl>
##  1 Zona Sur   2           6           880          237   2                5
##  2 Zona Oeste 2           4          1200          800   3                6
##  3 Zona Sur   3           5           250           86   NA               2
##  4 Zona Sur   NA          6          1280          346   4                6
##  5 Zona Sur   2           6          1300          600   4                7
##  6 Zona Sur   3           6           513          160   2                4
##  7 Zona Sur   2           6           870          490   3                6
##  8 Zona Sur   5           5           310           82.5 1                2
##  9 Zona Sur   9           4           240           80   1                2
## 10 Zona Sur   6           6           690          150   2                5
## # ... with 8,312 more rows, and 5 more variables: Habitaciones <dbl>,
## #   Tipo <chr>, Barrio <chr>, cordenada_longitud <dbl>, Cordenada_latitud <dbl>
library(sqldf)
## Loading required package: gsubfn
## Loading required package: proto
## Loading required package: RSQLite
data3_1=sqldf("select *
                from data3
                where Zona = 'Zona Norte'
                and precio_millon <=500
                and Area_contruida <=300
              ")
head(data3_1,3)
##         Zona piso Estrato precio_millon Area_contruida parqueaderos Banos
## 1 Zona Norte    2       3           135             56            1     1
## 2 Zona Norte   NA       5           400            212           NA     2
## 3 Zona Norte   NA       3            78             54            2     1
##   Habitaciones        Tipo                    Barrio cordenada_longitud
## 1            3 Apartamento        torres de comfandi          -76.46745
## 2            4        Casa santa mv=nica residencial          -76.47300
## 3            3 Apartamento               chiminangos          -76.47820
##   Cordenada_latitud
## 1           3.40763
## 2           3.41800
## 3           3.44898
summary(data3_1$precio_millon)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      65     145     240     250     340     500
summary(data3_1$Area_contruida)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    30.0    64.0    89.0   109.3   130.0   300.0
sqldf("select Zona, count()
       from data3_1
       group by Zona")
##         Zona count()
## 1 Zona Norte    1507
#Grafico para puntos Zona Norte
require(leaflet)
## Loading required package: leaflet
## Warning: package 'leaflet' was built under R version 4.1.2
leaflet()%>%addCircleMarkers(lng=data3_1$cordenada_longitud, lat=data3_1$Cordenada_latitud,radius = 0.1,color = 'red')%>%
addTiles()

La gran mayoria de puntos se encuentran en la Zona Norte, sin embargo existe una dispersion importante en otros areas de la ciudad lo que indica un problema en calidad de datos.

b) Realice un anaisis exploratorio de datos enfocado en la correlacion entre la variable respuesta (precio del apartamento) en funcion del areea construida, estrato y si tiene parqueadero.

sub3_1=sqldf("select precio_millon,Area_contruida,Estrato,parqueaderos
              from data3_1")
sub3_1$parqueaderos=as.numeric(sub3_1$parqueaderos)
## Warning: NAs introducidos por coerción
sub3_1[is.na(sub3_1)] <- 0
sub3_1
##      precio_millon Area_contruida Estrato parqueaderos
## 1              135          56.00       3            1
## 2              400         212.00       5            0
## 3               78          54.00       3            2
## 4              175         130.00       3            0
## 5              340         106.00       5            2
## 6              265         162.00       4            1
## 7              120         130.00       3            1
## 8              380         177.00       3            0
## 9              135         103.00       3            1
## 10              75          54.00       3            1
## 11             125         140.00       3            1
## 12             175          77.00       4            1
## 13              99          58.00       3            0
## 14              95          55.00       3            0
## 15             140         130.00       3            1
## 16             110          57.00       3            1
## 17             150          93.00       3            0
## 18             140         102.00       3            0
## 19             180         140.00       3            2
## 20             230          82.00       3            0
## 21             275          85.00       3            1
## 22             170         150.00       3            0
## 23             335         166.00       3            2
## 24             180         140.00       3            1
## 25             230         160.00       3            0
## 26             155          62.00       3            1
## 27             158          65.00       3            1
## 28             158          65.00       3            1
## 29             155          66.00       3            1
## 30             159          63.00       3            1
## 31             158          65.00       3            1
## 32             140         100.00       3            0
## 33             180         114.00       3            1
## 34              80          44.00       3            0
## 35              80          54.00       3            1
## 36             155          62.00       3            1
## 37             159          62.00       3            1
## 38             155          62.00       3            1
## 39             155          62.00       3            1
## 40             160         100.00       3            1
## 41             155          60.00       3            1
## 42             159          62.00       3            1
## 43             159          62.00       3            1
## 44             175         250.00       3            0
## 45             135          64.00       3            2
## 46             150          60.00       3            0
## 47             150          60.00       3            0
## 48             150          60.00       3            0
## 49             150          60.00       3            0
## 50             185         160.00       3            0
## 51             220         144.00       3            0
## 52             310          95.00       3            0
## 53             390         102.00       5            2
## 54             105          63.00       4            0
## 55              88          60.00       3            1
## 56             125          62.00       3            0
## 57             200         146.00       3            0
## 58             145          95.00       3            1
## 59             320          85.00       5            1
## 60             370          83.00       5            1
## 61             144         110.00       3            0
## 62             270         250.00       3            0
## 63             204         120.00       3            0
## 64             220         180.00       3            1
## 65             220          90.00       3            0
## 66             235         160.00       3            1
## 67             219         183.00       3            0
## 68             110          65.00       3            0
## 69             138          61.00       4            0
## 70             120          70.00       3            1
## 71             145          75.00       3            1
## 72             132          55.00       4            1
## 73             155         110.00       3            1
## 74              80          48.00       3            1
## 75             280         100.00       3            0
## 76             350         137.00       5            2
## 77             162          75.00       3            0
## 78             180         138.00       3            1
## 79             245         250.00       3            1
## 80             128          65.00       3            0
## 81             430         105.00       5            0
## 82             320          87.00       5            2
## 83             140          70.00       3            0
## 84             130          77.00       3            0
## 85              85          60.00       3            1
## 86             190          90.00       3            0
## 87             110          62.00       3            0
## 88             122          65.00       4            1
## 89              75          50.64       3            0
## 90             110         100.00       3            0
## 91              92          53.00       3            0
## 92             110          64.00       3            1
## 93             162         120.00       3            0
## 94             143          61.00       3            0
## 95             205          67.00       3            0
## 96             160          65.00       3            1
## 97             135          60.00       3            1
## 98              77          55.00       3            0
## 99              65          60.00       3            0
## 100            310         242.00       3            0
## 101             80          60.00       3            0
## 102            100          70.00       3            1
## 103            180          73.00       4            1
## 104             70          60.00       3            0
## 105             95          46.00       3            1
## 106             76          49.00       3            1
## 107            132          90.00       3            0
## 108            155          90.00       3            0
## 109            118         115.00       3            0
## 110            145          70.00       3            0
## 111             96          45.00       3            0
## 112            135          72.00       3            0
## 113             75          60.00       3            0
## 114            170         130.00       3            0
## 115            117         120.00       3            0
## 116            115          57.00       3            1
## 117            165         142.00       3            0
## 118            165         120.00       3            0
## 119            168          91.00       3            0
## 120            350         200.00       3            0
## 121             85          54.00       3            0
## 122            320          85.00       5            1
## 123             78          49.00       3            0
## 124             70          46.00       3            0
## 125             78          44.00       3            1
## 126            120         120.00       3            0
## 127             92          58.00       3            0
## 128            127          60.00       3            0
## 129            280         137.00       3            2
## 130             98          90.00       3            0
## 131            250         240.00       3            1
## 132            105          59.00       3            1
## 133            122          58.00       3            1
## 134            250          72.00       3            0
## 135            210          60.00       3            0
## 136             89          64.00       3            0
## 137            120          75.00       3            0
## 138            105          59.00       3            0
## 139            110          60.00       3            0
## 140             79          64.00       3            0
## 141             87          54.00       3            0
## 142             86          64.00       3            0
## 143             93          64.00       3            0
## 144            155          75.00       3            0
## 145            170          62.00       3            0
## 146             87          62.00       3            0
## 147             87          62.00       3            0
## 148             72          61.00       3            0
## 149            119          58.00       3            1
## 150            240         150.00       3            0
## 151            215         120.00       3            0
## 152            117          60.00       3            0
## 153            120          75.00       3            0
## 154            200         160.00       3            0
## 155             85          62.00       3            0
## 156            170          77.00       4            0
## 157            215         120.00       3            0
## 158            210         100.00       3            0
## 159            165         140.00       3            1
## 160            330         150.00       3            3
## 161            120          62.00       3            0
## 162            113          56.00       3            0
## 163            205          70.00       4            0
## 164            115          58.00       3            0
## 165            130          62.00       3            1
## 166            160         120.00       4            0
## 167            110          58.00       3            0
## 168            176          75.00       3            0
## 169            105          60.00       3            0
## 170            109          58.00       3            1
## 171             75          62.00       3            0
## 172            120          65.00       3            1
## 173            113          58.00       3            0
## 174            250         120.00       3            1
## 175            280         240.00       3            2
## 176            145          63.00       4            1
## 177            155          60.00       3            1
## 178            130          68.00       3            1
## 179            170          65.00       3            1
## 180            350         104.00       5            2
## 181            285          84.00       5            1
## 182            300          88.00       5            1
## 183            170         120.00       3            0
## 184            378          96.81       6            2
## 185            240          82.00       4            1
## 186             99          58.00       3            0
## 187            113          57.00       3            1
## 188            235         200.00       3            0
## 189            175         180.00       3            0
## 190            223          73.00       4            1
## 191            250         115.00       4            1
## 192            145          90.00       3            0
## 193            140          70.00       3            0
## 194            350          99.00       5            1
## 195            125          58.00       3            0
## 196            120          65.00       4            0
## 197            290          78.00       5            1
## 198            115          55.00       3            0
## 199            140          62.00       3            1
## 200            115          58.00       3            1
## 201            170         120.00       4            0
## 202            170          74.00       3            1
## 203            130          66.00       3            1
## 204            160         120.00       4            0
## 205            170         120.00       4            0
## 206            140          65.00       3            1
## 207            130          62.00       3            1
## 208            390          84.00       5            1
## 209            185          58.00       4            1
## 210             99          58.00       3            0
## 211            160         115.00       3            0
## 212            160         120.00       4            0
## 213             98          59.00       3            1
## 214            155          70.00       3            1
## 215            145          65.00       3            1
## 216            160         100.00       3            0
## 217            115          58.00       3            0
## 218            180         150.00       3            1
## 219            243         150.00       3            0
## 220             98          59.00       3            0
## 221            125          53.00       3            1
## 222            140          65.00       3            1
## 223            145          60.00       3            1
## 224            105          58.00       3            2
## 225             95          60.00       3            1
## 226            140          75.00       3            0
## 227            135          90.00       3            0
## 228            412         140.00       3            1
## 229            198          90.00       3            0
## 230            135          57.00       3            0
## 231            120          60.00       4            1
## 232            116          60.00       3            0
## 233            420         115.00       5            2
## 234            290         170.00       3            1
## 235            110          65.00       3            0
## 236            250          94.00       4            1
## 237            300         195.00       3            2
## 238             99          58.00       3            0
## 239            350         160.00       5            2
## 240            160          72.00       4            1
## 241            108          57.00       3            1
## 242             91          63.00       3            0
## 243            330         165.00       4            1
## 244             90          53.00       3            0
## 245            200         132.00       3            1
## 246             95          60.00       3            0
## 247             95          55.00       3            1
## 248             93          60.00       3            0
## 249             85          60.00       3            0
## 250            117          60.00       3            0
## 251            300         108.00       5            2
## 252             89          57.00       3            0
## 253             95          60.00       3            0
## 254            240         240.00       3            1
## 255            450         228.00       3            0
## 256            430         228.00       3            0
## 257             90          53.00       3            0
## 258             75          54.00       3            0
## 259            105          65.00       3            0
## 260            198          55.00       3            0
## 261            108          54.00       3            0
## 262            140          65.00       3            1
## 263            120          53.00       4            1
## 264             99          55.00       3            0
## 265            190          86.00       4            0
## 266            180         120.00       3            0
## 267            160         100.00       3            0
## 268            215          75.00       4            1
## 269            190          30.00       3            1
## 270            180         120.00       3            0
## 271            253          85.00       4            1
## 272            135          59.00       3            1
## 273            125          58.00       3            0
## 274            168          90.00       3            0
## 275             89          55.00       3            1
## 276            290         190.00       5            2
## 277            280         180.00       4            0
## 278            110          53.00       3            1
## 279            119          57.00       3            0
## 280            175         120.00       3            0
## 281            125          45.00       5            0
## 282            223          73.00       4            1
## 283            130          65.00       3            1
## 284            118          62.00       3            0
## 285            120          48.00       3            1
## 286             75          57.00       3            1
## 287            130          60.00       3            0
## 288            105          55.00       3            0
## 289            120          58.00       3            1
## 290            130          54.00       3            1
## 291            235         165.00       3            1
## 292            120          61.00       3            0
## 293            118          62.00       3            0
## 294             85          60.00       3            0
## 295            160         135.00       4            0
## 296            235         122.00       3            1
## 297            115          64.00       3            0
## 298            370         113.00       6            1
## 299            140          58.00       3            0
## 300            220         100.00       4            1
## 301            215          72.00       4            1
## 302            120          54.00       3            1
## 303            120          55.00       3            0
## 304            135          52.00       3            0
## 305            130          90.00       3            0
## 306            175         135.00       3            1
## 307            130         100.00       3            0
## 308            130          68.00       3            0
## 309            195         128.00       3            1
## 310             97          55.00       3            0
## 311             95          54.00       3            0
## 312            500         210.00       3            0
## 313            120          64.00       3            0
## 314            199         176.00       3            0
## 315            295          60.00       3            0
## 316            360          85.00       5            1
## 317            120          55.00       3            0
## 318            118          55.00       3            0
## 319            110          65.00       3            0
## 320            152          66.00       4            1
## 321            150          77.00       4            1
## 322            160          55.00       4            0
## 323             90          53.00       3            0
## 324            125          60.00       3            0
## 325            115          58.00       3            0
## 326            145          55.00       4            1
## 327            320         235.00       5            0
## 328            135          54.00       3            0
## 329            350         265.00       3            0
## 330             90          58.00       3            0
## 331            128          60.00       3            1
## 332            115         160.00       3            0
## 333            280         180.00       3            1
## 334            350         264.00       3            0
## 335            130          54.00       3            0
## 336            140          58.00       3            0
## 337             98          59.00       3            1
## 338            110          58.00       3            1
## 339            120          58.00       3            0
## 340             96          56.00       3            0
## 341            380         300.00       3            2
## 342            270         196.00       3            1
## 343            104          60.00       3            1
## 344            137          60.00       3            0
## 345            350          83.00       5            1
## 346            340         100.00       5            1
## 347            130          85.00       3            0
## 348            215          95.00       3            1
## 349            190         146.00       3            1
## 350            170         238.00       3            0
## 351            370         240.00       4            2
## 352            270          84.00       5            1
## 353            158          72.00       4            1
## 354            160          72.00       4            1
## 355            110          65.00       3            0
## 356            120          63.00       3            0
## 357            250         136.00       5            2
## 358            320          86.00       5            1
## 359            300          83.00       5            2
## 360            125          60.00       3            1
## 361            125          65.00       3            0
## 362            165          70.00       3            1
## 363            280         148.00       3            2
## 364            167          77.00       3            1
## 365            250          75.00       3            0
## 366            100          60.00       3            1
## 367            148          58.00       4            0
## 368            136          52.00       3            0
## 369            112          61.00       4            0
## 370            120          60.00       3            0
## 371            100          62.00       3            1
## 372            100          55.00       3            0
## 373            295          73.00       4            1
## 374            110          50.96       3            0
## 375            105          60.00       3            0
## 376            123          67.00       3            0
## 377            110          50.00       3            0
## 378            140          58.00       4            0
## 379            245          72.00       4            1
## 380            143          60.00       4            0
## 381            120          58.00       3            1
## 382            142          58.00       3            0
## 383            105          58.00       3            0
## 384            110          56.00       3            1
## 385            115          55.00       3            0
## 386            215          90.00       3            1
## 387            145          54.00       3            1
## 388            305          90.00       5            1
## 389            350          85.00       5            1
## 390            110          54.00       3            0
## 391            125          72.00       3            0
## 392            108          58.00       3            1
## 393            120          63.00       3            1
## 394            310          70.00       3            1
## 395            120          60.00       3            1
## 396            210         135.00       3            2
## 397            380         229.00       5            2
## 398            125          55.00       3            0
## 399            350         200.00       3            1
## 400            165         100.00       3            0
## 401            130          70.00       3            0
## 402            110          58.00       3            0
## 403            130          60.00       3            0
## 404            430         115.00       5            2
## 405            245          84.00       3            1
## 406            158          77.00       4            1
## 407            120          58.00       3            1
## 408            330         240.00       3            1
## 409            153          80.00       3            0
## 410            155          80.00       3            0
## 411            305         268.00       3            0
## 412            210         110.00       3            1
## 413            138          54.00       3            1
## 414            370          99.00       5            1
## 415            115          60.00       3            1
## 416            135          90.00       3            0
## 417            380         100.00       5            1
## 418            415         100.00       5            1
## 419            115          57.00       3            0
## 420            115          55.00       3            1
## 421            321         249.00       5            1
## 422            270         180.00       3            4
## 423            125          60.00       3            0
## 424            160         100.00       3            0
## 425            320          87.00       5            1
## 426            400         115.00       5            2
## 427            300         100.00       5            1
## 428            140          57.00       3            1
## 429             97          57.00       3            1
## 430            120          57.00       3            1
## 431            115          55.00       3            0
## 432            122          72.00       3            1
## 433            470         128.00       4            4
## 434            125          58.00       3            0
## 435            180         120.00       4            0
## 436            220         110.00       3            2
## 437            128          55.00       3            0
## 438            132          58.00       3            0
## 439            120          59.00       3            1
## 440            135         100.00       3            0
## 441            123          65.00       3            0
## 442             98          60.00       3            1
## 443            125          72.00       3            0
## 444            128          60.00       3            1
## 445            133          55.00       3            1
## 446            130          55.00       4            1
## 447            345          85.00       5            0
## 448            118          58.00       3            0
## 449            350         264.00       5            2
## 450            155          82.00       4            1
## 451            105          66.00       3            0
## 452            300         147.00       3            1
## 453            105          58.00       3            0
## 454            130          61.00       3            0
## 455            116          60.00       3            1
## 456            300         133.00       3            3
## 457            315          86.00       5            1
## 458            115          65.00       3            1
## 459            152          58.00       3            0
## 460            165         120.00       3            0
## 461            120          60.00       3            0
## 462            135          42.00       3            1
## 463            480         121.00       5            2
## 464            185          74.00       5            0
## 465            125          70.00       3            0
## 466            168         100.00       3            0
## 467            300         255.00       3            0
## 468            400         300.00       3            0
## 469            340         208.00       5            0
## 470            360         172.00       5            0
## 471            128          54.00       3            1
## 472            270         150.00       3            0
## 473            300         224.00       3            0
## 474            149          58.00       3            0
## 475            135          60.00       3            1
## 476            110          58.00       3            0
## 477            110          58.00       3            0
## 478            120          60.00       3            1
## 479            145          59.00       3            0
## 480            120          58.00       3            0
## 481            122          56.00       3            1
## 482            230         120.00       3            1
## 483            350         150.00       3            0
## 484            130          52.00       3            0
## 485            268         106.00       5            2
## 486             96          56.00       3            0
## 487            125          55.00       3            1
## 488            430         128.00       5            1
## 489            115          65.00       3            1
## 490            115          56.00       3            1
## 491            130          60.00       4            1
## 492            299         162.00       3            0
## 493            125          60.00       3            1
## 494            140          62.00       4            0
## 495            160          61.00       3            1
## 496            135          60.00       4            1
## 497            115          55.00       3            0
## 498            135          64.00       3            0
## 499            240          62.00       3            0
## 500             96          58.00       3            1
## 501            145          57.00       3            0
## 502            115          58.00       3            0
## 503            135          62.00       4            1
## 504            145          59.00       3            1
## 505            140          57.00       3            1
## 506            178          75.00       3            0
## 507            205         120.00       3            1
## 508            400         150.00       3            1
## 509            140          60.00       3            0
## 510            116          54.00       3            0
## 511            115          55.00       4            0
## 512            350         280.00       4            2
## 513            130          54.00       3            1
## 514            260          90.00       5            1
## 515            115          56.00       3            1
## 516            325         100.00       5            1
## 517            165          55.00       3            1
## 518            138          54.00       3            1
## 519            130          54.00       3            1
## 520            135          53.00       3            0
## 521            130          54.00       3            1
## 522            330         275.00       4            2
## 523            140          60.00       3            0
## 524            120          62.00       3            0
## 525            135          62.00       3            0
## 526            215          79.88       3            2
## 527            125          58.00       3            0
## 528             98          72.00       3            0
## 529            130          96.00       3            0
## 530             92          60.00       3            0
## 531             98          68.00       3            0
## 532            160          80.00       4            1
## 533             95          58.00       3            0
## 534            135          53.00       3            1
## 535            220          97.00       3            1
## 536            155          73.00       3            0
## 537            420          60.00       3            0
## 538            310         100.00       4            2
## 539            120          80.00       3            1
## 540            145          60.00       4            0
## 541            115          65.00       3            1
## 542            280         130.00       4            2
## 543            155          70.00       3            0
## 544            150          77.00       4            1
## 545            230         145.00       3            0
## 546            145          59.00       3            0
## 547            145          78.00       4            1
## 548            155          80.00       4            1
## 549            380         300.00       3            0
## 550            110          60.00       4            1
## 551            170         105.00       3            0
## 552            260         150.00       4            0
## 553            215         143.85       4            0
## 554            250         243.00       5            1
## 555            200         104.00       3            0
## 556             95          46.00       3            1
## 557            125          43.00       3            2
## 558            230         250.00       4            2
## 559            350         150.00       3            1
## 560            310         265.00       3            2
## 561            280          65.00       4            1
## 562            200         103.00       3            1
## 563            180          75.00       4            1
## 564            372         124.00       5            1
## 565            235          95.00       5            1
## 566            202          67.40       3            0
## 567            155          77.00       3            1
## 568            270         100.00       5            0
## 569            230          84.00       5            1
## 570            148          65.00       3            1
## 571            135          70.00       3            1
## 572            210          58.00       4            0
## 573            280         147.00       4            1
## 574            210         120.00       3            1
## 575            200         105.00       3            1
## 576            257         120.00       3            0
## 577            125          60.00       3            1
## 578            145          75.00       3            1
## 579            280         103.50       4            1
## 580            260         150.00       3            0
## 581            178          79.00       4            1
## 582            220          70.00       5            1
## 583            175          78.00       4            1
## 584            128          65.00       3            1
## 585            130          78.00       5            1
## 586            240         100.00       5            1
## 587            250          96.00       5            1
## 588            125          58.00       3            1
## 589            180          65.00       3            1
## 590            132          54.00       3            0
## 591            185          55.00       3            1
## 592            395         120.00       5            2
## 593            178          74.00       4            1
## 594            158          78.00       4            1
## 595            155          77.00       4            1
## 596            155          75.00       4            1
## 597            330         140.00       4            1
## 598            330         260.00       4            1
## 599            110          48.00       3            0
## 600            150          80.00       4            1
## 601            320         100.00       4            1
## 602            310         120.00       4            1
## 603            400         300.00       3            0
## 604            250         135.00       3            0
## 605            145          75.00       4            1
## 606            155          78.00       4            1
## 607            156          78.00       4            1
## 608            130          74.00       4            1
## 609            200          57.00       5            1
## 610            240          85.00       5            1
## 611            405          90.41       5            1
## 612            320         200.00       4            2
## 613            300         150.00       3            0
## 614            150          59.00       4            1
## 615            320         210.00       5            2
## 616            290          76.00       5            1
## 617            160          76.00       4            1
## 618            300          76.00       5            1
## 619            330         258.00       4            2
## 620            295          76.00       5            1
## 621            350         216.00       5            2
## 622            365         198.00       4            2
## 623            285          76.00       4            1
## 624            290          75.86       5            1
## 625            215          68.00       4            1
## 626            275         155.00       3            1
## 627            420         100.00       4            2
## 628            370         216.00       4            2
## 629            350         158.00       5            0
## 630            220          82.00       4            0
## 631            450         240.00       5            0
## 632            395         145.00       5            2
## 633            405         280.00       5            0
## 634            260         120.00       5            2
## 635            132          50.00       3            0
## 636            270          88.00       5            1
## 637            250          85.00       4            1
## 638            440         222.00       5            2
## 639            120          60.00       3            0
## 640            355         207.00       5            2
## 641            130          90.00       3            0
## 642            290          76.00       4            1
## 643            320         150.00       5            2
## 644            340         158.00       4            2
## 645            260          90.00       5            1
## 646            285          88.00       6            1
## 647            485         228.00       5            1
## 648            320          89.00       5            1
## 649            253         140.00       4            2
## 650            360         216.00       4            2
## 651            275          88.00       5            1
## 652            480         300.00       3            0
## 653            420         102.00       5            2
## 654            270         100.00       4            1
## 655             95          55.00       3            1
## 656            130          54.00       3            0
## 657            280         100.00       5            1
## 658            260          90.00       5            1
## 659            120         110.00       3            0
## 660            320         100.00       5            1
## 661            390         155.00       5            3
## 662            380         123.00       4            1
## 663            240          95.00       4            1
## 664            350         203.00       5            2
## 665            330         104.00       5            2
## 666            310          83.00       5            1
## 667            305         117.00       4            0
## 668            180          73.00       4            1
## 669            377          85.00       3            1
## 670            285          89.00       5            1
## 671            190          84.00       4            2
## 672            485         280.00       5            2
## 673            430         180.00       5            2
## 674            360         160.00       5            2
## 675            320          90.00       5            2
## 676            240          72.00       5            1
## 677            328         120.00       5            1
## 678            100          53.00       3            0
## 679            290         108.00       5            1
## 680            115          58.00       3            0
## 681            320         140.00       4            2
## 682            380         156.00       5            2
## 683            210          73.00       4            1
## 684            208          72.00       5            1
## 685            270         100.00       5            1
## 686            320         200.00       5            2
## 687            240          75.00       4            1
## 688            210          72.00       4            1
## 689            350         190.00       5            1
## 690            220          75.00       4            0
## 691            220         100.00       5            1
## 692            285          82.00       5            1
## 693             93         120.00       3            1
## 694            190          75.00       5            1
## 695            400         113.00       5            2
## 696            320         160.00       5            1
## 697            200          60.00       5            2
## 698            250          74.00       4            1
## 699            220         105.00       5            1
## 700            162          60.00       4            0
## 701            350         145.00       6            2
## 702            250         100.00       5            1
## 703            290          83.00       5            1
## 704            178          96.00       5            1
## 705            449         220.00       4            4
## 706            330         130.00       5            4
## 707            350         132.00       5            2
## 708            425         104.00       5            2
## 709            213          63.00       5            1
## 710             73          60.00       3            0
## 711            295          76.00       5            1
## 712            295          87.00       5            1
## 713            320         138.00       5            2
## 714            260          76.00       5            1
## 715            290          87.00       5            1
## 716            300          90.00       5            2
## 717            320         170.00       5            1
## 718            225          65.00       5            0
## 719            250          75.00       5            0
## 720            350         140.00       5            2
## 721            325         107.00       5            0
## 722            240          70.00       5            1
## 723            215         102.00       5            1
## 724            485         228.00       5            2
## 725            340         180.00       5            2
## 726            275          87.00       5            1
## 727             72          48.00       3            0
## 728            305          90.00       5            1
## 729            250          74.00       4            1
## 730            229          74.00       4            1
## 731            193          83.00       4            2
## 732            160          90.00       4            1
## 733            195          35.00       5            0
## 734            330          91.00       5            0
## 735            230          84.00       5            1
## 736            420         290.00       3            0
## 737            380         110.00       5            2
## 738            262          76.00       5            1
## 739            400         231.00       5            2
## 740            480         267.00       4            2
## 741            225          84.00       4            0
## 742            370         117.00       4            0
## 743            295          84.00       5            1
## 744            240          70.00       5            1
## 745            240          68.00       5            1
## 746            280          82.00       5            1
## 747            343         170.00       5            3
## 748            270         171.00       4            3
## 749            380         287.00       4            1
## 750            380         140.00       4            1
## 751            450         200.00       5            0
## 752            170         132.00       3            0
## 753            275         120.00       4            1
## 754            350         118.00       4            0
## 755            310         102.00       4            0
## 756            495         125.00       5            1
## 757            148          77.00       4            1
## 758            315          90.00       5            0
## 759            155          60.00       4            0
## 760            240          87.00       5            1
## 761            155          51.00       4            0
## 762            370         114.00       5            2
## 763            240          75.00       4            0
## 764            155          62.00       4            0
## 765            350         264.00       4            0
## 766            340          99.00       5            1
## 767            170          56.00       5            1
## 768            130          68.00       3            1
## 769            160          55.00       4            0
## 770            220         100.00       5            1
## 771            383         100.00       5            2
## 772            430         257.00       5            3
## 773            235          70.00       5            1
## 774            405          89.00       5            2
## 775            385          99.58       5            1
## 776            380         264.00       5            3
## 777            352          85.00       5            1
## 778            490         107.00       5            2
## 779            420         100.00       5            2
## 780            315         118.00       5            2
## 781            340         295.00       4            2
## 782            370         264.00       4            1
## 783            150          65.00       5            0
## 784            395         165.00       5            0
## 785            350         240.00       5            2
## 786            480         278.00       5            0
## 787            350         160.00       5            2
## 788            330         246.00       5            2
## 789            280          75.00       5            1
## 790            225          67.00       4            1
## 791            328          86.00       5            1
## 792            121          58.00       3            1
## 793            340         203.00       5            2
## 794            380         192.00       4            2
## 795            260         145.00       5            0
## 796            220          68.00       4            0
## 797            380         300.00       5            0
## 798            382         225.00       4            0
## 799            300         205.00       5            2
## 800            255          86.60       5            2
## 801            320         264.00       4            1
## 802            295         162.00       3            0
## 803            395         106.00       4            0
## 804            220          85.00       5            2
## 805            380         180.00       5            1
## 806            189          64.00       5            0
## 807            135          67.00       3            1
## 808            140          85.00       5            1
## 809            160          54.00       4            0
## 810            260          76.00       4            0
## 811            130          55.00       4            0
## 812            240          93.00       5            0
## 813            400          99.00       5            1
## 814            360         107.00       5            2
## 815            340          87.00       5            1
## 816            285          89.00       5            1
## 817            380         282.00       4            0
## 818            165          58.00       5            0
## 819            430         112.00       5            2
## 820            240          64.00       4            1
## 821            255          74.00       4            1
## 822            175          75.00       5            1
## 823            250         160.00       4            0
## 824            230          73.00       4            1
## 825            228          73.00       4            1
## 826            400         120.00       5            0
## 827            408          99.00       5            1
## 828            350          84.00       5            1
## 829            410          99.00       5            1
## 830            346          84.00       5            1
## 831            406          99.00       5            1
## 832            410          99.00       5            1
## 833            408          99.00       5            1
## 834            430         107.00       5            2
## 835            400         113.00       5            2
## 836            210          72.00       4            1
## 837            260          73.00       5            1
## 838            340         123.00       5            2
## 839            235          70.00       5            1
## 840            420         107.00       5            2
## 841            164          77.00       4            1
## 842            230         120.00       5            2
## 843            380         180.00       5            1
## 844            415         107.00       5            2
## 845            400         112.00       5            0
## 846            380         230.00       5            1
## 847            314          68.00       4            0
## 848            355          85.00       5            1
## 849            223          67.00       4            1
## 850            270          85.00       4            0
## 851            270         121.00       5            2
## 852            160          54.00       4            1
## 853            430         225.00       4            2
## 854            250          74.00       5            1
## 855            300          90.00       5            1
## 856            390          76.00       5            1
## 857            250          73.00       5            1
## 858            480         180.00       5            5
## 859            480         180.00       5            5
## 860            270          75.00       4            0
## 861            225          67.00       4            1
## 862            320         130.00       5            2
## 863            149          62.00       4            0
## 864            334         243.00       5            4
## 865            230          70.00       4            1
## 866            210          72.00       4            1
## 867            450         103.00       6            2
## 868            220          52.00       4            2
## 869            360          84.00       5            1
## 870            147          60.00       4            0
## 871            275          90.00       5            0
## 872            320         143.00       5            2
## 873            360         100.00       5            2
## 874            390         113.00       5            2
## 875            375          88.00       5            1
## 876            340         100.00       5            1
## 877            290         108.00       5            1
## 878            439         104.00       5            2
## 879            260          88.00       5            1
## 880            390         110.00       5            2
## 881            250          89.00       5            1
## 882            300         147.00       5            1
## 883            150          61.00       4            0
## 884            390         300.00       4            0
## 885            385          84.00       5            1
## 886            164          77.00       4            1
## 887            160          59.00       4            1
## 888            320         115.00       4            0
## 889            390         113.00       5            2
## 890            415         113.00       5            2
## 891            410         113.00       5            1
## 892            423         113.00       5            2
## 893            398         116.00       5            2
## 894            400         113.00       5            2
## 895            410         220.00       5            1
## 896            170          61.00       4            0
## 897            175          75.00       4            1
## 898            220          70.00       4            0
## 899            300         100.00       5            1
## 900            260          72.00       5            1
## 901            420         113.00       5            2
## 902            211          77.00       4            1
## 903            405         113.00       5            2
## 904            410         112.00       5            2
## 905            175          60.00       4            1
## 906            157          77.00       4            1
## 907            420         113.00       5            2
## 908            160          64.00       4            0
## 909            215          71.00       4            1
## 910            290          63.00       5            1
## 911            340         100.00       5            1
## 912            480         121.00       5            2
## 913            315          84.00       5            2
## 914            385          99.00       5            1
## 915            305          86.00       5            2
## 916            300         100.00       5            1
## 917            225          71.00       4            1
## 918            260         100.00       5            2
## 919            300         102.00       5            1
## 920            385         124.00       5            0
## 921            175          57.00       4            1
## 922            365         180.00       5            2
## 923            285         144.00       5            1
## 924            275          90.00       5            1
## 925            397         125.00       5            2
## 926            340         264.50       4            2
## 927            300         106.00       5            2
## 928            420         241.00       5            0
## 929            250          87.00       5            1
## 930            340         100.00       5            1
## 931            325          89.00       5            1
## 932            260          71.00       5            1
## 933            410         104.00       5            1
## 934            379          88.00       5            1
## 935            360          85.00       5            1
## 936            350          85.00       5            1
## 937            420         113.00       5            2
## 938            158          57.00       4            0
## 939            225          62.00       4            1
## 940            180          57.00       4            0
## 941            176          57.00       4            0
## 942            212          71.00       4            1
## 943            230          71.00       4            1
## 944            215          71.00       4            1
## 945            220          70.00       4            0
## 946            225          62.00       4            1
## 947            210          70.00       5            1
## 948            208          64.00       4            1
## 949            215          62.00       4            1
## 950            230          70.00       4            1
## 951            350         130.00       4            1
## 952            370          85.00       5            1
## 953            360          83.00       4            1
## 954            420         104.00       5            2
## 955            320         138.00       5            2
## 956            375          85.00       5            1
## 957            390          84.00       5            1
## 958            345          87.00       5            1
## 959            320          95.00       5            1
## 960            300          99.00       5            1
## 961            290         108.00       4            1
## 962            400         105.00       5            1
## 963            420         105.00       5            0
## 964            320          90.00       4            1
## 965            420         104.00       5            2
## 966            350          84.00       5            0
## 967            270          75.00       5            1
## 968            420         104.00       5            2
## 969            438         104.00       5            2
## 970            168          77.00       4            1
## 971            210          70.00       4            1
## 972            160          59.00       4            0
## 973            335         120.00       5            1
## 974            335         120.00       5            1
## 975            215          67.00       4            1
## 976            208          70.00       4            1
## 977            430         217.00       5            5
## 978            450         121.00       6            0
## 979            320          85.00       5            2
## 980            330          85.00       5            0
## 981            280          76.00       5            0
## 982            310          87.00       5            2
## 983            285          72.00       5            1
## 984            320          86.00       5            2
## 985            305          87.00       5            2
## 986            415         113.00       5            2
## 987            260          90.00       5            1
## 988            290          85.00       5            1
## 989            210          70.00       4            1
## 990            250          73.00       4            0
## 991            157          60.00       4            0
## 992            450         220.00       4            2
## 993            320         143.00       5            2
## 994            310          86.00       5            1
## 995            240          69.00       5            1
## 996            339          88.00       5            1
## 997            290         108.00       5            1
## 998            290         100.00       5            1
## 999            340          84.00       5            2
## 1000           360         107.00       5            2
## 1001           200         107.00       5            2
## 1002           480         121.00       5            2
## 1003           220          60.00       4            1
## 1004           400         105.00       5            2
## 1005           320          85.00       5            2
## 1006           295          52.00       5            1
## 1007           290         100.00       5            1
## 1008           390         280.00       5            2
## 1009           310          90.00       5            0
## 1010           290         107.00       5            1
## 1011           255          90.00       5            2
## 1012           320         149.00       5            2
## 1013           155          77.00       4            1
## 1014           340         207.00       4            0
## 1015           470         131.00       5            2
## 1016           170          63.00       4            0
## 1017           488         200.00       5            6
## 1018           170         107.00       5            2
## 1019           230         120.00       3            0
## 1020           450         280.00       5            1
## 1021           295         147.00       5            2
## 1022           210          73.00       4            1
## 1023           160          65.00       4            0
## 1024           300         102.00       5            2
## 1025           260         100.00       5            1
## 1026           445         113.00       5            2
## 1027           425         104.17       5            2
## 1028           230          68.00       5            1
## 1029           285          84.00       5            1
## 1030           215          76.00       5            1
## 1031           385         125.00       5            1
## 1032           250          90.00       5            1
## 1033           270          86.00       4            0
## 1034           240          90.00       5            1
## 1035           270          96.00       5            2
## 1036           440         276.00       5            1
## 1037           335         100.00       5            1
## 1038           410         104.00       5            2
## 1039           420         113.00       5            2
## 1040           335          88.00       5            1
## 1041           360          88.00       5            1
## 1042           290          62.00       5            1
## 1043           375          83.00       5            1
## 1044           420         109.00       5            2
## 1045           185         104.00       4            1
## 1046           135          75.00       3            1
## 1047           390          90.00       5            1
## 1048           392          90.00       5            1
## 1049           270          70.00       5            1
## 1050           250          82.00       5            2
## 1051           140          56.00       4            1
## 1052           145          60.00       3            0
## 1053           330         114.00       5            1
## 1054           250         103.00       5            2
## 1055           420         200.00       5            2
## 1056           290         110.00       5            1
## 1057           300         146.00       5            1
## 1058           480         139.00       5            3
## 1059           415         105.00       6            2
## 1060           340          85.00       5            1
## 1061           320         108.00       5            1
## 1062           200          78.00       5            1
## 1063           340          84.00       5            1
## 1064           220          65.00       5            0
## 1065           470         131.00       5            2
## 1066           330         275.00       5            2
## 1067           190          61.00       4            0
## 1068           370         160.00       5            3
## 1069           320         230.00       5            2
## 1070           380         240.00       4            4
## 1071           430         300.00       6            3
## 1072           360         170.00       5            3
## 1073           370         180.00       5            2
## 1074           350         110.00       5            1
## 1075           285          90.00       4            0
## 1076           440         132.00       5            1
## 1077           380         125.00       5            2
## 1078           265         125.00       4            2
## 1079           320          85.00       5            2
## 1080           275          78.00       5            2
## 1081           325         128.00       5            1
## 1082           390         110.00       5            2
## 1083           279          83.00       5            1
## 1084           260          90.00       5            1
## 1085           340          84.00       5            1
## 1086           270          83.00       5            1
## 1087           370          99.55       6            1
## 1088           365          90.00       5            1
## 1089           260         100.00       5            1
## 1090           220          74.00       4            0
## 1091           310          87.00       5            2
## 1092           340         100.00       5            1
## 1093           215          75.00       5            1
## 1094           272          90.00       4            0
## 1095           470         155.00       5            2
## 1096           250          75.00       4            1
## 1097           400         210.00       5            1
## 1098           260          86.00       5            1
## 1099           265          94.00       5            0
## 1100           170          63.00       4            1
## 1101           395         145.00       5            1
## 1102           320          86.00       5            2
## 1103           290          85.00       5            1
## 1104           310          85.00       5            1
## 1105           320         130.00       5            1
## 1106           290          75.00       5            2
## 1107           410         108.00       5            0
## 1108           315         116.00       5            1
## 1109           230          70.00       5            1
## 1110           300          77.00       5            1
## 1111           420         265.00       4            0
## 1112           415         120.00       6            1
## 1113           185          58.00       4            0
## 1114           380         126.00       4            2
## 1115           135          58.00       4            0
## 1116           370         160.00       5            2
## 1117           300         128.00       5            2
## 1118           390         240.00       5            1
## 1119           265         147.00       5            1
## 1120           195          89.00       5            1
## 1121           205          53.00       5            1
## 1122           220         105.00       5            1
## 1123           385         125.00       5            1
## 1124           235          94.00       4            1
## 1125           210          77.00       4            1
## 1126           202         117.00       5            1
## 1127           270         152.00       4            1
## 1128           150          80.00       4            1
## 1129           480         158.00       5            0
## 1130           240         120.00       5            0
## 1131           480         115.00       6            2
## 1132           139          64.00       4            0
## 1133           149          60.00       4            0
## 1134           165          60.00       4            0
## 1135           120          60.00       4            1
## 1136           340         121.00       4            2
## 1137           410         240.00       5            2
## 1138           107         102.00       4            0
## 1139           300         110.00       5            0
## 1140           175          65.00       4            0
## 1141           175          65.00       4            0
## 1142           250         105.00       5            1
## 1143           210          70.00       5            0
## 1144           430         270.00       4            2
## 1145           230         120.00       3            0
## 1146           330         285.00       3            0
## 1147           335         300.00       4            3
## 1148           250         113.00       5            1
## 1149           330         220.00       5            2
## 1150           350          85.00       5            1
## 1151           320          86.00       5            1
## 1152           390          90.00       5            1
## 1153           365         188.00       5            0
## 1154           204          74.00       5            1
## 1155           200          60.00       4            1
## 1156            70          46.00       3            1
## 1157           250          70.00       5            1
## 1158           235         101.00       5            1
## 1159           350         118.00       5            2
## 1160           115          54.00       3            1
## 1161           125          60.00       4            1
## 1162           112          58.00       3            1
## 1163           145          58.00       3            1
## 1164           240          98.00       4            1
## 1165           210         117.00       5            1
## 1166           450         210.00       5            0
## 1167           260         138.00       5            0
## 1168           150          63.00       4            0
## 1169           150          59.00       4            0
## 1170           340         240.00       5            2
## 1171           415         118.00       5            2
## 1172           300         152.00       5            1
## 1173           190          68.00       5            0
## 1174           300         287.00       4            1
## 1175           280         105.00       5            1
## 1176           490         118.00       5            2
## 1177           150          67.00       3            1
## 1178           460          95.00       5            2
## 1179           380         240.00       4            0
## 1180           320         165.00       5            2
## 1181           240         103.00       4            1
## 1182           435          90.00       6            2
## 1183           310          93.00       6            0
## 1184           190         104.12       4            1
## 1185           300          77.00       5            1
## 1186           440         116.00       5            2
## 1187           176         140.00       5            0
## 1188           225          73.00       4            1
## 1189           470         152.00       5            2
## 1190           330         240.00       4            1
## 1191           225          78.00       5            1
## 1192           190         145.00       5            0
## 1193           397         160.48       4            1
## 1194           420         125.00       5            2
## 1195           385         120.00       6            2
## 1196           225          95.00       4            1
## 1197           450         300.00       4            1
## 1198           300         163.00       4            1
## 1199           250         118.00       4            1
## 1200           220         136.00       5            2
## 1201           430         250.00       4            7
## 1202           390         268.00       5            0
## 1203           450         220.00       5            3
## 1204           320         100.00       5            2
## 1205           250         106.00       5            1
## 1206           180         147.00       5            0
## 1207           251         140.00       5            1
## 1208           300         170.00       5            1
## 1209           390         187.00       6            1
## 1210           118          60.00       4            0
## 1211           142          60.00       4            0
## 1212           435         170.00       3            2
## 1213           385         116.00       5            2
## 1214           460         152.00       5            2
## 1215           300          76.00       5            1
## 1216           175          90.00       4            0
## 1217           140          60.00       3            0
## 1218           380         171.10       5            2
## 1219           250         106.00       4            1
## 1220           327         143.00       5            2
## 1221           250         270.00       5            1
## 1222           330          80.00       5            1
## 1223           330         142.00       5            2
## 1224           190          81.00       4            1
## 1225           350         124.00       5            2
## 1226           350          98.00       4            2
## 1227           400         110.00       6            0
## 1228           250          98.00       4            1
## 1229           300         136.00       4            2
## 1230           450         230.00       5            2
## 1231           175          80.00       3            1
## 1232           260         110.00       5            1
## 1233           350         120.00       5            2
## 1234           155          61.00       3            0
## 1235           370         240.00       5            3
## 1236           420         300.00       3            2
## 1237           370         264.00       3            0
## 1238           390         280.00       5            2
## 1239           400         300.00       3            1
## 1240           230         198.00       3            0
## 1241           265         140.00       3            0
## 1242           320         140.00       5            1
## 1243           355         190.00       4            2
## 1244           440         300.00       5            2
## 1245           210         144.00       3            1
## 1246           175         226.00       3            1
## 1247           280         145.00       3            0
## 1248           110          57.00       3            1
## 1249           270         111.00       4            1
## 1250           340         211.00       5            1
## 1251           260         115.00       5            1
## 1252           120          70.00       3            0
## 1253           130          60.00       3            1
## 1254           300         193.00       5            2
## 1255            92          47.00       3            0
## 1256            96          60.00       3            1
## 1257           400         126.00       5            4
## 1258           225          99.00       4            1
## 1259           110          60.00       3            1
## 1260           110          59.00       3            1
## 1261            95          54.00       3            1
## 1262            70          45.00       3            1
## 1263           270         100.00       5            1
## 1264           160          60.00       3            0
## 1265           120          58.00       3            1
## 1266            78          56.00       3            0
## 1267           130          60.00       4            0
## 1268           360         120.00       5            2
## 1269           290          48.00       6            0
## 1270           390         120.00       5            2
## 1271           300         136.00       4            2
## 1272           230          95.00       5            1
## 1273           450         118.00       6            0
## 1274           355         188.00       5            1
## 1275           246         159.38       5            2
## 1276           320         143.00       5            2
## 1277           300         126.00       4            2
## 1278           450         250.00       5            5
## 1279           480         219.00       6            2
## 1280           260          85.00       5            1
## 1281           445          47.00       5            0
## 1282           260         115.00       5            1
## 1283           300         115.00       5            1
## 1284           360         230.00       5            2
## 1285           350         133.00       6            2
## 1286           140          58.00       4            0
## 1287           295         140.00       5            1
## 1288           360         264.50       4            3
## 1289           350         300.00       5            3
## 1290           350         200.00       5            3
## 1291           143          58.00       4            0
## 1292           249         135.00       5            1
## 1293           245         165.00       5            2
## 1294           335         202.00       5            1
## 1295           400         290.00       5            2
## 1296           400         171.00       5            1
## 1297           250         114.00       5            2
## 1298           335         220.00       5            1
## 1299           485         250.00       4            1
## 1300           310         147.00       4            1
## 1301           120          80.00       3            0
## 1302           400         186.00       5            1
## 1303           380         180.00       5            1
## 1304           320         142.00       5            2
## 1305           100          52.00       3            0
## 1306           310         137.00       5            2
## 1307           200          65.00       5            1
## 1308           275          85.00       5            1
## 1309           250         114.00       5            2
## 1310           350         240.00       5            2
## 1311           335         165.00       5            2
## 1312           370         107.00       5            3
## 1313           350         179.00       6            2
## 1314           315         270.00       4            2
## 1315           340         162.00       4            1
## 1316           245          67.00       5            1
## 1317           230          64.00       5            1
## 1318           342         250.00       5            1
## 1319           350         265.00       4            0
## 1320           435         297.00       4            1
## 1321           220          75.00       3            0
## 1322           129          84.00       3            0
## 1323           275         190.00       4            0
## 1324           125          60.00       3            1
## 1325           270         173.00       5            2
## 1326           250          74.00       4            1
## 1327           155          61.00       4            1
## 1328           115          54.00       3            0
## 1329           138          59.00       4            0
## 1330           250          85.00       4            1
## 1331           310         300.00       3            0
## 1332           490         200.00       5            4
## 1333           310         300.00       3            0
## 1334           415         143.00       5            1
## 1335           369         208.00       5            1
## 1336           154         104.00       3            0
## 1337           220         150.00       3            1
## 1338           240         100.00       4            1
## 1339           185          85.00       4            1
## 1340           260         152.00       5            1
## 1341           360         129.00       6            2
## 1342           470         111.00       6            2
## 1343           215          60.00       4            1
## 1344           115          80.00       3            0
## 1345           390          90.00       5            1
## 1346           165          80.00       4            2
## 1347           170          73.00       4            1
## 1348           320         129.00       5            1
## 1349           420         145.00       4            1
## 1350           240          72.00       5            1
## 1351           470         300.00       6            1
## 1352           370         152.00       5            1
## 1353           280         173.00       6            2
## 1354           271         226.00       4            0
## 1355           435         250.00       4            0
## 1356           300         115.00       5            2
## 1357           225          90.00       4            1
## 1358           415         297.00       4            1
## 1359           405         174.00       5            2
## 1360           296         232.00       4            0
## 1361           470         131.00       6            2
## 1362           295          75.00       5            1
## 1363           295          75.00       5            1
## 1364           340          86.00       5            1
## 1365           350         191.00       6            2
## 1366           280         140.00       5            1
## 1367           340         250.00       5            2
## 1368           110          66.00       3            1
## 1369           225          73.00       4            1
## 1370           190          78.00       4            1
## 1371           330          70.00       5            1
## 1372           411          90.00       5            2
## 1373           320          90.00       5            0
## 1374           310          88.00       5            1
## 1375           250          96.00       4            0
## 1376           280         173.00       4            2
## 1377           480         293.00       5            1
## 1378           470         111.00       6            2
## 1379           195          57.00       4            1
## 1380           500         145.00       5            2
## 1381           203          44.00       5            1
## 1382           252          63.00       5            1
## 1383           215         145.00       3            0
## 1384           340         160.00       5            2
## 1385           404         270.00       5            1
## 1386           420         250.00       5            1
## 1387            89         130.00       3            1
## 1388           135          53.00       3            0
## 1389           430         116.00       6            2
## 1390           225         117.00       5            1
## 1391           390         180.00       5            0
## 1392           145          75.00       3            1
## 1393            69          50.00       3            0
## 1394           255          74.00       5            1
## 1395           100          60.00       3            0
## 1396           395         150.00       5            2
## 1397           480         300.00       5            1
## 1398           320         120.00       5            1
## 1399           260          87.00       5            1
## 1400           370         192.00       4            2
## 1401           180          78.00       3            1
## 1402           160          80.00       4            1
## 1403           420         198.00       4            0
## 1404           500         239.00       6            1
## 1405           315         125.00       4            1
## 1406           480         236.00       6            0
## 1407           120          53.00       3            0
## 1408           440          92.00       5            0
## 1409           150          63.00       5            1
## 1410           280         180.00       4            0
## 1411           100          55.00       3            0
## 1412           150          75.00       4            1
## 1413           285          95.00       5            0
## 1414           320         108.00       4            2
## 1415           400         225.00       4            0
## 1416           500         200.00       5            4
## 1417           152          82.00       4            1
## 1418           450         150.00       5            2
## 1419           430         117.00       6            2
## 1420           430         214.00       6            2
## 1421           450          85.00       6            2
## 1422           390         100.00       6            1
## 1423           480         178.00       6            2
## 1424           450         106.00       6            0
## 1425           420         149.00       5            2
## 1426           480         240.00       6            0
## 1427           250         104.00       6            0
## 1428           380         130.00       6            2
## 1429           420          84.00       6            2
## 1430           310          95.00       5            1
## 1431           445         131.00       5            2
## 1432           470         223.10       6            1
## 1433           400         117.00       6            2
## 1434            98          58.00       3            0
## 1435           470         131.00       5            2
## 1436           340         127.00       4            0
## 1437           440         150.00       6            0
## 1438           180          54.53       6            1
## 1439           180          54.53       6            1
## 1440           490         130.00       6            2
## 1441           200         190.00       3            1
## 1442           440         230.00       4            0
## 1443           260          72.00       5            1
## 1444           270         137.00       4            0
## 1445           230          73.00       5            1
## 1446           159          61.00       4            0
## 1447           337          80.00       4            0
## 1448           160         160.00       3            0
## 1449           420         124.00       5            3
## 1450           160          56.00       4            0
## 1451           390         265.00       5            1
## 1452           380         120.00       5            2
## 1453           470         170.00       6            2
## 1454           230         170.00       3            1
## 1455           385         103.00       5            2
## 1456           250          96.00       4            1
## 1457           220          67.00       4            1
## 1458           400         156.00       6            2
## 1459           490         118.00       5            0
## 1460           450         225.00       5            0
## 1461           124          64.00       3            1
## 1462           450         300.00       4            0
## 1463           155          80.00       3            0
## 1464           318         108.00       5            0
## 1465           500         160.00       4            0
## 1466           440         140.00       5            0
## 1467            98          57.00       3            0
## 1468           240          78.00       4            0
## 1469           360         240.00       4            0
## 1470           100          49.00       3            0
## 1471           370         120.00       5            0
## 1472           435         113.00       5            2
## 1473           310          90.00       5            0
## 1474           285          82.00       5            1
## 1475           480         126.00       6            0
## 1476           145          55.00       4            1
## 1477           220          86.00       5            2
## 1478           260         280.00       4            2
## 1479           245         103.00       4            1
## 1480           320         173.00       5            3
## 1481           135          57.00       3            1
## 1482            95          56.00       3            0
## 1483           155          92.00       4            0
## 1484           150          60.00       5            1
## 1485           340         264.00       4            2
## 1486           330         240.00       4            0
## 1487           160          80.00       4            1
## 1488           130          65.00       3            0
## 1489           167         100.00       3            0
## 1490           415         116.00       6            0
## 1491           210          83.00       4            0
## 1492           490         227.00       6            0
## 1493           340         200.00       4            0
## 1494           430         100.00       6            0
## 1495           152          62.00       3            0
## 1496           330         280.00       3            2
## 1497           300          67.00       6            0
## 1498           283          61.00       6            0
## 1499           420         200.00       5            4
## 1500           310         120.00       4            1
## 1501           135          60.00       3            0
## 1502           149         130.00       3            0
## 1503           280         145.00       5            0
## 1504           320          86.00       5            1
## 1505           390         240.00       4            0
## 1506           170          62.00       5            0
## 1507           400         220.00       5            1
library(PerformanceAnalytics)
## Loading required package: xts
## 
## Attaching package: 'xts'
## The following object is masked from 'package:leaflet':
## 
##     addLegend
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
chart.Correlation(as.matrix(sub3_1),histogram = TRUE,pch=12)

#exploracion bivariada: precio_millon vs Area_construida
g3_1=ggplot(data=sub3_1,mapping=
            aes(x=Area_contruida,y=precio_millon))+geom_point()+theme_bw()+
            geom_smooth(method = "lm")       
ggplotly(g3_1)
## `geom_smooth()` using formula 'y ~ x'
#exploracion bivariada: precio_millon vs Estrato
g3_2=ggplot(data=sub3_1,mapping=
            aes(x=Estrato,y=precio_millon))+geom_point()+theme_bw()+
            geom_smooth(method = "lm")       
ggplotly(g3_2)
## `geom_smooth()` using formula 'y ~ x'
#exploracion bivariada: precio_millon vs Estrato
g3_3=ggplot(data=sub3_1,mapping=aes(x=parqueaderos,y=precio_millon))+geom_point()+theme_bw()+
            geom_smooth(method = "lm")       
ggplotly(g3_3)
## `geom_smooth()` using formula 'y ~ x'

En conclusion: Podemos observar una realcion lineal directamente proporcional entre los atributos y el precio del inmueble.

c) Estime un modelo de regresion lineal multiple con las variables del punto anterior e interprete los coeficientes si son estadisticamente significativos.

mod3 <- lm(precio_millon ~Area_contruida+Estrato+parqueaderos, data = sub3_1 )
summary(mod3)
## 
## Call:
## lm(formula = precio_millon ~ Area_contruida + Estrato + parqueaderos, 
##     data = sub3_1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -199.743  -36.332   -4.719   29.130  295.975 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -122.56056    7.03538 -17.421  < 2e-16 ***
## Area_contruida    0.86344    0.02657  32.501  < 2e-16 ***
## Estrato          64.92647    1.80809  35.909  < 2e-16 ***
## parqueaderos     14.54242    2.03775   7.137 1.48e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 58.44 on 1503 degrees of freedom
## Multiple R-squared:  0.7295, Adjusted R-squared:  0.729 
## F-statistic:  1351 on 3 and 1503 DF,  p-value: < 2.2e-16

Tiene un R^2 de 0.729 lo que indica una interpretacion de la varianza bastante alta por parte de las variables explicativas.

Todas las variables son significativas y positivas lo que indica como se observo previamente que el aumento en los valores en cada una de estas aumenta el precio del inmueble.

d) Validacion de supuestos

par(mfrow=c(2,2))
plot(mod3)

shapiro.test(mod3$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  mod3$residuals
## W = 0.97798, p-value = 1.975e-14

Cumple con normalidad

bptest(mod3)
## 
##  studentized Breusch-Pagan test
## 
## data:  mod3
## BP = 76.206, df = 3, p-value < 2.2e-16

Cumple con heterocedasticidad

dwtest( mod3, 
        alternative = "two.sided", 
        data = sub3_1)
## 
##  Durbin-Watson test
## 
## data:  mod3
## DW = 1.8136, p-value = 0.0002719
## alternative hypothesis: true autocorrelation is not 0

Cumple con indepencia en los residuos

Conclusion Cumple con los supuestos requeridos, lo que evidencia un modelo robusto para tomar decisiones.

e) Con el modelo identificado predecir el precio de un apartamento con 100 mt2, de estrato 4 y con parqueadero. si este apartamento lo estan ofreciendo en 450 millones cual seria su opinion con base en el resultado del modelo considera que es una buena oferta?

predict(mod3,list(Area_contruida=100, Estrato=4, parqueaderos=1),interval="confidence",level=0.95)
##        fit      lwr      upr
## 1 238.0318 234.9782 241.0854

El modelo pronostica un precio de $238M para esas condiciones, por lo que una oferta de 450 es sobreestimada frente a lo que plantea el modelo.

f) Con las predicciones del modelo sugiera potenciales ofertas para una persona interesada en un apartamento en la zona norte con mas de 100 mt2 de area, de estrato 4, que tenga parqueadero y tenga encuentra que la persona tiene un credito preaprobado de minimo 400 millones de pesos.

#Oferta 1
predict(mod3,list(Area_contruida=100, Estrato=4, parqueaderos=1),interval="confidence",level=0.95)
##        fit      lwr      upr
## 1 238.0318 234.9782 241.0854
#Oferta 2
predict(mod3,list(Area_contruida=125, Estrato=4, parqueaderos=1),interval="confidence",level=0.95)
##        fit      lwr      upr
## 1 259.6178 256.5114 262.7242
#Oferta 3
predict(mod3,list(Area_contruida=150, Estrato=4, parqueaderos=1),interval="confidence",level=0.95)
##        fit      lwr      upr
## 1 281.2038 277.5474 284.8603
#Oferta 4
predict(mod3,list(Area_contruida=275, Estrato=4, parqueaderos=2),interval="confidence",level=0.95)
##        fit      lwr      upr
## 1 403.6763 394.3135 413.0391
#Oferta 5
predict(mod3,list(Area_contruida=285, Estrato=4, parqueaderos=1),interval="confidence",level=0.95)
##        fit      lwr      upr
## 1 397.7683 388.1706 407.3659

Bajo las condiciones dadas, se puede presentar ofertas de apto hasta de 285 mts con 1 parqueadero en Estrato 4 y hasta de 275 mts con 2 parqueaderos.

EJERCICIO 4 Con base en los datos de arboles proponga un modelo de regresion lineal multiple que permita predecir el peso del arbol en funcion de las covariables que considere importantes y seleccionandolas de acuerdo con un proceso adecuado.

data4 = read_excel("G:/ACADEMIA/JAVERIANA CALI/2. SEMESTRE 2022 - II/2. Met. Estad. para la Toma Decisiones/data_arboles.xlsx")
head(data4)
## # A tibble: 6 x 5
##   finca   mg         peso  diametro altura
##   <chr>   <chr>      <chr> <chr>    <chr> 
## 1 FINCA_1 GENOTIPO_1 13.73 4.7      5     
## 2 FINCA_1 GENOTIPO_1 14.58 5.3      5.6   
## 3 FINCA_1 GENOTIPO_1 15.88 4.8      5.8   
## 4 FINCA_1 GENOTIPO_1 8.99  3.2      4.3   
## 5 FINCA_1 GENOTIPO_1 6.99  2.2      3.3   
## 6 FINCA_1 GENOTIPO_2 19.34 6.3      7.9
data4$diametro=as.numeric(data4$diametro)
data4$altura=as.numeric(data4$altura)
#se prueba un primer modelo con la totalidad de variables
mod4 <- lm(peso ~diametro+altura+mg+finca, data = data4 )
summary(mod4)
## 
## Call:
## lm(formula = peso ~ diametro + altura + mg + finca, data = data4)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1009 -1.8569 -0.5094  1.5578 12.8691 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -13.95177    1.68295  -8.290 1.59e-12 ***
## diametro       2.57058    0.76282   3.370 0.001138 ** 
## altura         2.98566    0.76616   3.897 0.000195 ***
## mgGENOTIPO_2  -4.50270    1.23667  -3.641 0.000468 ***
## fincaFINCA_2  -0.03095    0.99140  -0.031 0.975166    
## fincaFINCA_3   3.51938    0.83466   4.217 6.23e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.983 on 84 degrees of freedom
## Multiple R-squared:  0.8738, Adjusted R-squared:  0.8662 
## F-statistic: 116.3 on 5 and 84 DF,  p-value: < 2.2e-16
library(fastDummies)
data4 = dummy_cols(data4,  select_columns = c("mg","finca"))
colnames(data4)
##  [1] "finca"         "mg"            "peso"          "diametro"     
##  [5] "altura"        "mg_GENOTIPO_1" "mg_GENOTIPO_2" "finca_FINCA_1"
##  [9] "finca_FINCA_2" "finca_FINCA_3"
#se prueba modelo con variables dummy para categoricas
mod4_1 <- lm(peso ~ diametro+altura+mg_GENOTIPO_1+
                    finca_FINCA_1+finca_FINCA_2,
                    data = data4 )
summary(mod4_1)
## 
## Call:
## lm(formula = peso ~ diametro + altura + mg_GENOTIPO_1 + finca_FINCA_1 + 
##     finca_FINCA_2, data = data4)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1009 -1.8569 -0.5094  1.5578 12.8691 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -14.9351     2.7436  -5.444 5.08e-07 ***
## diametro        2.5706     0.7628   3.370 0.001138 ** 
## altura          2.9857     0.7662   3.897 0.000195 ***
## mg_GENOTIPO_1   4.5027     1.2367   3.641 0.000468 ***
## finca_FINCA_1  -3.5194     0.8347  -4.217 6.23e-05 ***
## finca_FINCA_2  -3.5503     0.8991  -3.949 0.000163 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.983 on 84 degrees of freedom
## Multiple R-squared:  0.8738, Adjusted R-squared:  0.8662 
## F-statistic: 116.3 on 5 and 84 DF,  p-value: < 2.2e-16

Se obtiene un modelo robusto, de buena capacidad de explicacion de varianza con un 86.6% y con variables explicativas significantes.

par(mfrow=c(2,2))
plot(mod4_1)

head(data4)
## # A tibble: 6 x 10
##   finca   mg     peso  diametro altura mg_GENOTIPO_1 mg_GENOTIPO_2 finca_FINCA_1
##   <chr>   <chr>  <chr>    <dbl>  <dbl>         <int>         <int>         <int>
## 1 FINCA_1 GENOT~ 13.73      4.7    5               1             0             1
## 2 FINCA_1 GENOT~ 14.58      5.3    5.6             1             0             1
## 3 FINCA_1 GENOT~ 15.88      4.8    5.8             1             0             1
## 4 FINCA_1 GENOT~ 8.99       3.2    4.3             1             0             1
## 5 FINCA_1 GENOT~ 6.99       2.2    3.3             1             0             1
## 6 FINCA_1 GENOT~ 19.34      6.3    7.9             0             1             1
## # ... with 2 more variables: finca_FINCA_2 <int>, finca_FINCA_3 <int>

Validacion Cruzada

##Paso 1 - Segmentar los datos
id_modelar=sample(1:200, size=160)
peso_modelar=data4[id_modelar,]
peso_validar=data4[-id_modelar,]

##Paso 2 - Estimar el modelo en el set de entrenamiento
mod4_modelar=lm(peso ~ diametro+altura+mg_GENOTIPO_1+
                    finca_FINCA_1+finca_FINCA_2,
                    data = peso_modelar )

##Paso 3 - Predecir set de validacion
peso_pred=predict(mod4_modelar,list(diametro=peso_validar$diametro,
                                    altura=peso_validar$altura,
                                    mg_GENOTIPO_1=peso_validar$mg_GENOTIPO_1,
                                    finca_FINCA_1=peso_validar$finca_FINCA_1,
                                    finca_FINCA_2=peso_validar$finca_FINCA_2))

##Paso 4 - Comparar ventas del modelo y reales
peso_real=peso_validar$peso
error=as.numeric(peso_real)- as.numeric(peso_pred)
res=data.frame(peso_real,peso_pred,error)

##Paso 5 - Calcular indicador de evaluacion de prediccion
MAE=mean(abs(error))
MAE
## [1] 2.019837
RMSE=sqrt(mean(error^2))
RMSE
## [1] 2.188783
res
##    peso_real peso_pred      error
## 1      13.73 12.813118  0.9168821
## 2      16.62 18.173938 -1.5539380
## 3      15.83 14.562068  1.2679316
## 4       7.87  5.584666  2.2853339
## 5      11.04  8.857498  2.1825018
## 6      10.69 12.831752 -2.1417523
## 7       9.93  7.516704  2.4132959
## 8      16.08 19.594321 -3.5143206
## 9      23.82 27.639085 -3.8190851
## 10     17.01 18.301655 -1.2916546
## 11     25.24 24.412025  0.8279751
## 12     32.44 30.253911  2.1860893
## 13     30.51 28.184557  2.3254429
## 14     33.42 31.411617  2.0083827
## 15     17.71 18.984442 -1.2744423
## 16     13.98 15.100518 -1.1205177
## 17     24.47 22.441504  2.0284961
## 18     22.82 26.009958 -3.1899579
## 19      21.8 25.056329 -3.2563295
## 20      13.3 12.125664  1.1743362
## 21      15.4 13.762080  1.6379202