Objetivo: Modelar los ingresos de la sociedad mexicana del estado de Puebla para determinar qué conceptos impactan más en el gasto de los hogares de dicha región, así como una buena estimación del ingreso en años posteriores a los de la captura de información.


REGRESIÓN LINEAL SIMPLE


Llamamos a nuestra base de datos y hacemos un primer acercamiento con ella:

Esta base nos muestra los ingresos totales mensuales de 1,837 hogares y la cantidad de dinero que gastan en las diferentes variables: alimentos, vestimenta y calzado, vivienda, limpieza, salud, transporte, educación y esparcimiento y gastos personales. Además nos brinda la edad de la jefa o jefe de familia así como el número de integrantes de cada hogar.

Antes de continuar, eliminaremos la variable “entidad”, pues sabemos que se trata del estado 21: Puebla.

Observaremos el siguiente correlograma para decidir qué variables conformarán nuestros modelos.

La variable Edad del o de la Jefa de familia no se correlaciona con los Ingresos corruientes, por lo tanto no la tomaremos en cuenta en nuestros modelos.

## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
## 
##     first, last
## The following objects are masked from 'package:Hmisc':
## 
##     src, summarize
## The following object is masked from 'package:car':
## 
##     recode
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine

Trataremos de aumentar las correlaciones aplicando transformaciones

Apliquemos logaritmos eliminando los ceros en algunas variables (donde el total de ceros no es significativo con respecto al total de observaciones)

##       zeros        casos
##  [1,] "edad_jefe"  "0"  
##  [2,] "tot_integ"  "0"  
##  [3,] "ing_cor"    "0"  
##  [4,] "alimentos"  "9"  
##  [5,] "vesti_calz" "433"
##  [6,] "vivienda"   "26" 
##  [7,] "limpieza"   "24" 
##  [8,] "salud"      "911"
##  [9,] "transporte" "112"
## [10,] "educa_espa" "554"
## [11,] "personales" "12"

No alicaremos logaritmo en Vestimenta y Calzado, Salud, Transporte y Educación y Esparcimiento dado que su total de ceros es un tanto significativo.

Podemos observar que la correlación aumentó usando la tranformación logaritmo en personales y vivienda, así que usaremos esas transformaciones en nuestros modelos:

MODELOS PROPUESTOS
## 
## Attaching package: 'purrr'
## The following object is masked from 'package:car':
## 
##     some
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
## 
## Modelos propuestos de RLS SIN Outliers
## -----------------------------------------------------------------------------------------------------------------------------------
##                                                                            log(ing_cor)                                            
##                                  Model 1    Model 2    Model 3    Model 4    Model 5     Model 6    Model 7    Model 8    Model 9  
## -----------------------------------------------------------------------------------------------------------------------------------
## sqrt(alimentos)                  0.014***                                                                                          
##                                  (0.0005)                                                                                          
## sqrt(educa_espa)                            0.007***                                                                               
##                                             (0.0004)                                                                               
## sqrt(limpieza)                                         0.020***                                                                    
##                                                        (0.001)                                                                     
## sqrt(salud)                                                       0.008***                                                         
##                                                                   (0.001)                                                          
## sqrt(tot_integ)                                                              0.470***                                              
##                                                                              (0.031)                                               
## sqrt(transporte)                                                                        0.013***                                   
##                                                                                         (0.0004)                                   
## sqrt(vesti_calz)                                                                                    0.013***                       
##                                                                                                     (0.001)                        
## log(personales)                                                                                                0.424***            
##                                                                                                                (0.015)             
## log(vivienda)                                                                                                             0.251*** 
##                                                                                                                           (0.015)  
## Constant                         8.953***   9.998***   9.577***  10.158***   9.365***   9.520***    9.912***   7.205***   8.446*** 
##                                  (0.045)    (0.021)    (0.031)    (0.019)    (0.062)     (0.023)    (0.023)    (0.107)    (0.110)  
## N                                  1779       1779       1779       1779       1779       1779        1779       1779       1779   
## R-squared                         0.345      0.159      0.250      0.058      0.112       0.445      0.175      0.319      0.136   
## Adj. R-squared                    0.345      0.159      0.250      0.058      0.111       0.445      0.174      0.319      0.135   
## Residual Std. Error (df = 1777)   0.547      0.619      0.585      0.655      0.637       0.503      0.613      0.557      0.628   
## F Statistic (df = 1; 1777)      936.222*** 335.916*** 592.450*** 110.352*** 223.803*** 1427.412*** 376.822*** 833.916*** 279.475***
## -----------------------------------------------------------------------------------------------------------------------------------
## ***p < .01; **p < .05; *p < .1
## Warning: attributes are not identical across measure variables;
## they will be dropped

## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## Joining, by = "Estadística"
## Warning: attributes are not identical across measure variables;
## they will be dropped
## # A tibble: 12 x 10
##    Estadística `Modelo Aliment~ `Modelo Educaci~ `Modelo Limpiez~ `Modelo Salud`
##    <chr>                  <dbl>            <dbl>            <dbl>          <dbl>
##  1 r.squared          3.45e-  1         1.59e- 1        2.50e-  1       5.85e- 2
##  2 adj.r.squa~        3.45e-  1         1.59e- 1        2.50e-  1       5.79e- 2
##  3 sigma              5.47e-  1         6.19e- 1        5.85e-  1       6.55e- 1
##  4 statistic          9.36e+  2         3.36e+ 2        5.92e+  2       1.10e+ 2
##  5 p.value            1.60e-165         7.32e-69        3.55e-113       4.38e-25
##  6 df                 1   e+  0         1   e+ 0        1   e+  0       1   e+ 0
##  7 logLik            -1.45e+  3        -1.67e+ 3       -1.57e+  3      -1.77e+ 3
##  8 AIC                2.90e+  3         3.35e+ 3        3.14e+  3       3.55e+ 3
##  9 BIC                2.92e+  3         3.36e+ 3        3.16e+  3       3.57e+ 3
## 10 deviance           5.31e+  2         6.82e+ 2        6.08e+  2       7.63e+ 2
## 11 df.residual        1.78e+  3         1.78e+ 3        1.78e+  3       1.78e+ 3
## 12 nobs               1.78e+  3         1.78e+ 3        1.78e+  3       1.78e+ 3
## # ... with 5 more variables: Modelo Integrantes <dbl>, Modelo Transpote <dbl>,
## #   Modelo Vestimenta <dbl>, Modelo Personales <dbl>, Modelo Vivienda <dbl>