Regresión lineal y MCO

Consideramos la siguiente simulaciòn:

Creamos las observaciones con un proceso generador dado:

library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.5
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.4     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.1     v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.0.5
## Warning: package 'tibble' was built under R version 4.0.5
## Warning: package 'tidyr' was built under R version 4.0.5
## Warning: package 'readr' was built under R version 4.0.5
## Warning: package 'dplyr' was built under R version 4.0.5
## Warning: package 'forcats' was built under R version 4.0.5
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
set.seed(1)
tb <- tibble(
  x = rnorm(10000),
  u = rnorm(10000),
  y = 5.5*x + 12*u
) 

Efectuamos la regresiòn lineal:

reg_tb <- tb %>% 
  lm(y ~ x, .) %>%
  print()
## 
## Call:
## lm(formula = y ~ x, data = .)
## 
## Coefficients:
## (Intercept)            x  
##    -0.04991      5.55690
reg_tb$coefficients
## (Intercept)           x 
## -0.04990882  5.55690164

Ponemos las estimaciones en un dataframe:

tb <- tb %>% 
  mutate(
    yhat1 = predict(lm(y ~ x, .)),
    yhat2 = 0.0732608 + 5.685033*x, 
    uhat1 = residuals(lm(y ~ x, .)),
    uhat2 = y - yhat2
  )

summary(tb[-1:-3])
##      yhat1               yhat2              uhat1              uhat2         
##  Min.   :-20.45096   Min.   :-20.7982   Min.   :-51.5275   Min.   :-51.5247  
##  1st Qu.: -3.79189   1st Qu.: -3.7550   1st Qu.: -8.1520   1st Qu.: -8.2751  
##  Median : -0.13842   Median : -0.0173   Median : -0.1727   Median : -0.3147  
##  Mean   : -0.08624   Mean   :  0.0361   Mean   :  0.0000   Mean   : -0.1223  
##  3rd Qu.:  3.71578   3rd Qu.:  3.9258   3rd Qu.:  7.9778   3rd Qu.:  7.8506  
##  Max.   : 21.12342   Max.   : 21.7348   Max.   : 44.7176   Max.   : 44.4416

Ploteando:

tb %>% 
  lm(y ~ x, .) %>% 
  ggplot(aes(x=x, y=y)) + 
  ggtitle("Minimos cuadrados") +
  geom_point(size = 0.05, color = "black", alpha = 0.5) +
  geom_smooth(method = lm, color = "black") +
  annotate("text", x = -1.5, y = 30, color = "red", 
           label = paste("Intercept = ", -0.0732608)) +
  annotate("text", x = 1.5, y = -30, color = "blue", 
           label = paste("Slope =", 5.685033))
## `geom_smooth()` using formula 'y ~ x'

Los estimadores que obtenemos resultan similares a los reales del proceso generador de datos que en este caso conocemos.

Una vez que tenemos los estimadores podemos predecir el valor de cualquier y a partir de las x. La MCO es el mejor predictor lineal y minimiza el error de predicción minimizando la distancias verticales de las observaciones a la recta de regresión.

El coeficiente de la x nos permite entender el efecto marginal de unos cambios en esta:

\[\begin{align} \Delta \widehat{y}=\widehat{\beta}_1 \Delta x \end{align}\]

Dependendo de la transformación de nuestras variables tendremos diferentes interpretaciones de los coeficientes estimados:

Una vez estimados \(\beta_0\) y \(\beta_1\) podemos utlizarlos para obtener los valores ajustados de nuestra regresión:

\[\begin{align} \widehat{y_i}=\widehat{\beta}_0+\widehat{\beta}_1x_i \end{align}\]

Y también los relativos residuales:

\[\begin{align} \widehat{u_i}=y_i - \widehat{\beta}_0 - \widehat{\beta}_1 x_i \end{align}\]

La mayoría son distintos de 0.

¿ Que significa cuando un residual es positivo? ¿Y cuando es negativo?

Si ploteamos los residuales obtendremos:

El patron esferico nos sugiere ausencia de correlación entre los residuales y los valores ajustados obtenidos.

Tenemos diferentes medidas de error para evaluar la bondad de ajuste:

$$\[\begin{align} SST & = \sum_{i=1}^n (y_i - \overline{y})^2 \\ SSE & = \sum_{i=1}^n (\widehat{y_i} - \overline{y})^2 \\ SSR & = \sum_{i=1}^n \widehat{u_i}^2 \end{align}\]$$

Si dividimos SST por n-1 obtenemos la varianza muestral de y.

Para poder ocupar la regresión lineal de manera eficaz y así obtener estimadores de los coeficientes poblacionales inssesgado se tienen que cumplir algunos supuestos:

  1. Modelo lineral en los parametros

\(y=\beta_0+\beta_1 x_1 + \dots + \beta_k x_k + \epsilon\)

  1. Media nula y exogeneidad estricta

Implica que el valor medio del error condicionado a las explicativas es igual al valor esperado no condicionado y vale cero. Además, la exogeneidad estricta exige que los errores del modelo no estén correlacionados con ninguna observación. \(E(\epsilon_i)=0 \wedge E(\epsilon_i|x_{11}, x_{21} \dots x_{kn})=E(\epsilon_i)\)

  1. No multicolinealidad exacta

En la muestra ninguna de las variables explicativas es constante. No existen relaciones lineales exactas entre variables explicativas. No excluye cierta correlación (no perfecta) entre las variables. Según Gauss y Márkov, cuando un modelo tiene multicolinealidad exacta suele ser por un error del analista.

  1. Homocedasticidad

La varianza del error, y por tanto de Y, es independiente de los valores de las explicativas y, además, la varianza del error constante. Matemáticamente se expresa como:

\(V(\epsilon_i|X)=V(\epsilon_i|x_{11}, x_{21} \dots x_{kn})=V(\epsilon_i)=\sigma^2\)

  1. No autocorrelacion

Los términos de error de dos observaciones diferentes condicionadas a X están incorrelacionados. Si la muestra es aleatoria no existirá autocorrelación.

\(Cov(\epsilon_i, \epsilon_h|X)=0\)

Ejemplo

Utilizamos una base ya presente en r:

library(wooldridge)
## Warning: package 'wooldridge' was built under R version 4.0.5

En particular ocuparemos la CPS que es la current population surveys. Analizamos los datos presentes en la base:

data("cps78_85")
names(cps78_85)
##  [1] "educ"     "south"    "nonwhite" "female"   "married"  "exper"   
##  [7] "expersq"  "union"    "lwage"    "age"      "year"     "y85"     
## [13] "y85fem"   "y85educ"  "y85union"

Podemos etiquetar las variables:

library(Hmisc)
## Warning: package 'Hmisc' was built under R version 4.0.5
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Warning: package 'Formula' was built under R version 4.0.3
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
label(cps78_85$lwage) <- "Logaritmo del salario por hora"
describe(cps78_85)
## cps78_85 
## 
##  15  Variables      1084  Observations
## --------------------------------------------------------------------------------
## educ 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     1084        0       18    0.927    12.77    2.882        8       10 
##      .25      .50      .75      .90      .95 
##       12       12       14       16       18 
## 
## lowest :  1  2  3  4  5, highest: 14 15 16 17 18
##                                                                             
## Value          1     2     3     4     5     6     7     8     9    10    11
## Frequency      1     2     1     3     2    13    13    39    27    50    50
## Proportion 0.001 0.002 0.001 0.003 0.002 0.012 0.012 0.036 0.025 0.046 0.046
##                                                     
## Value         12    13    14    15    16    17    18
## Frequency    447    74    98    38   127    39    60
## Proportion 0.412 0.068 0.090 0.035 0.117 0.036 0.055
## --------------------------------------------------------------------------------
## south 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.623      319   0.2943   0.4157 
## 
## --------------------------------------------------------------------------------
## nonwhite 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.304      124   0.1144   0.2028 
## 
## --------------------------------------------------------------------------------
## female 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.729      452    0.417   0.4867 
## 
## --------------------------------------------------------------------------------
## married 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.679      709   0.6541   0.4529 
## 
## --------------------------------------------------------------------------------
## exper 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     1084        0       54    0.999    18.28    14.49        2        3 
##      .25      .50      .75      .90      .95 
##        8       15       28       38       42 
## 
## lowest :  0  1  2  3  4, highest: 49 50 51 54 55
## --------------------------------------------------------------------------------
## expersq 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     1084        0       54    0.999    499.8    605.7        4        9 
##      .25      .50      .75      .90      .95 
##       64      225      784     1444     1764 
## 
## lowest :    0    1    4    9   16, highest: 2401 2500 2601 2916 3025
## --------------------------------------------------------------------------------
## union 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.553      264   0.2435   0.3688 
## 
## --------------------------------------------------------------------------------
## lwage : Logaritmo del salario por hora 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     1084        0      441        1    1.867   0.6116    1.065    1.209 
##      .25      .50      .75      .90      .95 
##    1.470    1.833    2.225    2.565    2.772 
## 
## lowest : -0.4700 -0.0780  0.0000  0.3567  0.4520
## highest:  3.2189  3.2581  3.2692  3.3514  3.7955
## --------------------------------------------------------------------------------
## age 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     1084        0       47    0.999    36.54    13.85       20       22 
##      .25      .50      .75      .90      .95 
##       27       34       46       56       59 
## 
## lowest : 18 19 20 21 22, highest: 60 61 62 63 64
## --------------------------------------------------------------------------------
## year 
##        n  missing distinct     Info     Mean      Gmd 
##     1084        0        2     0.75    81.45    3.502 
##                       
## Value         78    85
## Frequency    550   534
## Proportion 0.507 0.493
## --------------------------------------------------------------------------------
## y85 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2     0.75      534   0.4926   0.5004 
## 
## --------------------------------------------------------------------------------
## y85fem 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.525      245    0.226   0.3502 
## 
## --------------------------------------------------------------------------------
## y85educ 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     1084        0       18    0.861    6.413     7.19     0.00     0.00 
##      .25      .50      .75      .90      .95 
##     0.00     0.00    12.00    16.00    16.85 
## 
## lowest :  0  2  3  4  5, highest: 14 15 16 17 18
##                                                                             
## Value          0     2     3     4     5     6     7     8     9    10    11
## Frequency    550     1     1     1     1     3     5    15    12    17    27
## Proportion 0.507 0.001 0.001 0.001 0.001 0.003 0.005 0.014 0.011 0.016 0.025
##                                                     
## Value         12    13    14    15    16    17    18
## Frequency    219    37    56    13    71    24    31
## Proportion 0.202 0.034 0.052 0.012 0.065 0.022 0.029
## --------------------------------------------------------------------------------
## y85union 
##        n  missing distinct     Info      Sum     Mean      Gmd 
##     1084        0        2    0.242       96  0.08856   0.1616 
## 
## --------------------------------------------------------------------------------

Podemos renombrar los datos:

library(dplyr)
names(cps78_85)
##  [1] "educ"     "south"    "nonwhite" "female"   "married"  "exper"   
##  [7] "expersq"  "union"    "lwage"    "age"      "year"     "y85"     
## [13] "y85fem"   "y85educ"  "y85union"
rename(cps78_85, sur = south, año = year)
##      educ sur nonwhite female married exper expersq union   lwage age año y85
## 1      12   0        0      0       0     8      64     0  1.2150  25  78   0
## 2      12   0        0      1       1    30     900     1  1.6094  47  78   0
## 3       6   0        0      0       1    38    1444     1  2.1401  49  78   0
## 4      12   0        0      0       1    19     361     1  2.0732  36  78   0
## 5      12   0        0      0       1    11     121     0  1.6490  28  78   0
## 6       8   0        0      0       1    43    1849     0  1.7148  56  78   0
## 7      11   0        0      0       0     2       4     0  1.0986  18  78   0
## 8      15   0        0      1       0     9      81     0  1.8326  29  78   0
## 9      16   0        0      1       0    17     289     0  0.3567  38  78   0
## 10     15   0        0      0       1    23     529     1  2.1547  43  78   0
## 11     15   0        0      0       1    39    1521     1  1.9867  59  78   0
## 12     12   0        0      1       1     5      25     1  1.7047  22  78   0
## 13     11   0        0      0       1    27     729     1  2.1102  43  78   0
## 14     12   0        0      0       1    29     841     0  1.8326  46  78   0
## 15     12   0        0      0       0     7      49     0  1.3083  24  78   0
## 16     12   0        0      1       0    42    1764     1  2.2300  59  78   0
## 17     18   0        0      0       1    35    1225     1  2.5257  58  78   0
## 18     18   0        0      1       1    31     961     1  2.3979  54  78   0
## 19      6   0        0      0       1    24     576     0  1.2528  35  78   0
## 20     14   0        1      0       1    14     196     1  2.0794  33  78   0
## 21     12   0        0      1       0    40    1600     1  2.0149  57  78   0
## 22     12   0        0      1       0    10     100     0  1.2040  27  78   0
## 23     13   0        0      1       0     3       9     0  1.3863  21  78   0
## 24     13   0        0      0       0     2       4     0  1.2311  20  78   0
## 25     15   0        0      0       0     7      49     0  1.5041  27  78   0
## 26     16   0        0      0       0    29     841     0  2.5997  50  78   0
## 27     13   0        0      0       1    27     729     1  2.2380  45  78   0
## 28     18   0        0      0       0     8      64     0  2.3539  31  78   0
## 29     10   0        0      0       1     6      36     1  2.5257  21  78   0
## 30     14   0        0      1       0     2       4     0  0.9361  21  78   0
## 31      8   0        0      0       0    36    1296     1  2.0149  49  78   0
## 32     15   0        0      1       1    23     529     1  1.1314  43  78   0
## 33      8   0        0      1       1    48    2304     1  1.6582  61  78   0
## 34     12   0        0      0       0    21     441     1  2.0677  38  78   0
## 35      8   0        0      0       1    11     121     1  2.0820  24  78   0
## 36     12   0        0      1       1    26     676     1  2.1547  43  78   0
## 37     16   0        0      1       1    10     100     0  1.9671  31  78   0
## 38     14   0        0      0       1    37    1369     0  2.7593  56  78   0
## 39     13   0        0      0       1    21     441     0  1.2972  39  78   0
## 40     16   0        0      1       1    21     441     0  1.2528  42  78   0
## 41     13   0        0      0       0     6      36     1  2.3749  24  78   0
## 42     12   0        0      0       1    25     625     1  1.6368  42  78   0
## 43     13   0        0      0       0     5      25     0  1.2321  23  78   0
## 44     11   0        0      0       0    13     169     1  1.7492  29  78   0
## 45     16   0        0      0       0    15     225     0  2.3026  36  78   0
## 46     12   0        0      1       1     8      64     0  1.5581  25  78   0
## 47     10   0        0      0       1     8      64     1  1.6094  23  78   0
## 48     14   0        0      0       1    11     121     0  1.5581  30  78   0
## 49     12   0        1      0       1    34    1156     1  2.0541  51  78   0
## 50     13   0        0      0       0     8      64     0  1.8326  26  78   0
## 51     12   0        0      0       1    36    1296     0  1.9459  53  78   0
## 52     12   0        0      1       1    30     900     0  1.8326  47  78   0
## 53     16   0        0      1       1     5      25     1  1.1856  26  78   0
## 54     11   0        0      1       1    13     169     0  0.9118  29  78   0
## 55     11   0        0      0       0     2       4     1  1.8718  18  78   0
## 56      9   0        0      0       1    12     144     1  1.9459  26  78   0
## 57     18   0        0      0       1    24     576     0  2.1691  47  78   0
## 58     12   0        1      0       1    17     289     1  2.0149  34  78   0
## 59      8   0        0      0       1    50    2500     0  1.6448  63  78   0
## 60     18   0        0      0       1     8      64     0  2.1072  31  78   0
## 61     12   0        0      1       0    11     121     1  1.6292  28  78   0
## 62     12   0        0      0       1     7      49     0  1.0594  24  78   0
## 63     17   0        0      1       1    26     676     1  2.1691  48  78   0
## 64      8   0        0      0       1    19     361     0  1.3218  32  78   0
## 65     12   0        1      1       0    13     169     1  1.8555  30  78   0
## 66     12   0        0      0       1     9      81     1  1.7492  26  78   0
## 67     14   0        0      0       1    38    1444     0  1.9661  57  78   0
## 68     12   0        0      0       0     4      16     0  1.1982  21  78   0
## 69     14   0        0      1       0    11     121     0  1.9279  30  78   0
## 70     10   0        0      0       1    43    1849     0  2.3026  58  78   0
## 71     11   0        1      0       1    15     225     0  1.3863  31  78   0
## 72     12   0        1      0       1    31     961     1 -0.4700  48  78   0
## 73      6   0        1      0       1    44    1936     1  1.3151  55  78   0
## 74     16   0        0      0       1    16     256     0  2.8994  37  78   0
## 75     12   0        0      0       1    25     625     1  1.9981  42  78   0
## 76     14   0        0      0       1    19     361     1  1.7047  38  78   0
## 77     12   0        0      1       0     3       9     0  1.1787  20  78   0
## 78     13   0        0      1       0    14     196     0  1.6094  32  78   0
## 79     12   0        0      0       1    30     900     0  2.0149  47  78   0
## 80     12   0        0      0       1    32    1024     1  2.4849  49  78   0
## 81     10   0        0      0       1    48    2304     1  2.0794  63  78   0
## 82     12   0        0      0       0    36    1296     1  2.1401  53  78   0
## 83     12   0        0      1       1     7      49     1  1.5828  24  78   0
## 84     12   0        0      0       1    19     361     1  2.3346  36  78   0
## 85     18   0        0      0       0    11     121     0  1.6503  34  78   0
## 86     13   0        0      0       1    32    1024     1  1.5476  50  78   0
## 87     12   0        0      1       1    10     100     0  1.7707  27  78   0
## 88     14   0        0      1       0     3       9     0  1.6094  22  78   0
## 89     16   0        0      1       1    10     100     0  1.2947  31  78   0
## 90     16   0        0      1       1     9      81     0  2.0402  30  78   0
## 91     12   0        0      1       1    13     169     1  1.3218  30  78   0
## 92     12   0        0      0       1    20     400     0  1.8563  37  78   0
## 93     12   0        0      0       1    30     900     1  2.1102  47  78   0
## 94     12   0        0      0       1    10     100     1  2.3632  27  78   0
## 95     18   0        0      1       0    17     289     0  0.6707  40  78   0
## 96     10   0        0      0       1     7      49     1  1.5790  22  78   0
## 97      8   0        0      0       1    32    1024     0  2.1401  45  78   0
## 98      9   0        0      0       1    36    1296     1  1.6630  50  78   0
## 99     14   0        0      0       1    43    1849     0  2.6127  62  78   0
## 100    16   0        0      0       1     9      81     0  2.1691  30  78   0
## 101     8   0        0      0       1    41    1681     1  1.6094  54  78   0
## 102    12   0        0      0       1    21     441     1  2.0794  38  78   0
## 103    14   0        0      0       1    26     676     0  1.5141  45  78   0
## 104    12   0        0      1       1    21     441     0  1.1907  38  78   0
## 105    12   0        0      1       1    42    1764     0  1.7918  59  78   0
## 106    12   0        0      0       1    41    1681     0  2.2300  58  78   0
## 107    13   0        0      1       1    22     484     0  0.9746  40  78   0
## 108    18   0        0      0       1    10     100     0  2.0412  33  78   0
## 109    12   0        0      0       0     3       9     1  1.7918  20  78   0
## 110    14   0        0      0       0    14     196     0  2.1628  33  78   0
## 111    12   0        0      0       1    24     576     1  2.4849  41  78   0
## 112    12   0        0      0       1    13     169     1  1.7918  30  78   0
## 113    12   0        0      1       0    41    1681     1  1.6956  58  78   0
## 114    14   0        0      0       1    16     256     0  2.5257  35  78   0
## 115    12   1        0      0       0     3       9     0  0.9746  20  78   0
## 116    16   1        0      0       1    27     729     0  2.1090  48  78   0
## 117     7   1        0      1       0    31     961     0  1.2947  43  78   0
## 118    11   1        0      1       0     2       4     0  0.9746  18  78   0
## 119    12   1        0      0       1    19     361     0  1.2238  36  78   0
## 120     1   1        0      0       1    47    2209     0  1.2040  53  78   0
## 121    12   1        0      0       0     1       1     0  1.0473  18  78   0
## 122     9   1        0      0       1     5      25     0  1.8216  19  78   0
## 123    12   1        1      1       0    38    1444     1  1.1394  55  78   0
## 124    12   1        0      1       0     2       4     0  0.9163  19  78   0
## 125    12   1        0      0       1    19     361     0  2.2083  36  78   0
## 126    12   1        0      0       1    38    1444     1  2.1691  55  78   0
## 127    12   1        0      0       1    22     484     0  1.7918  39  78   0
## 128    12   1        0      0       1     6      36     0  1.3863  23  78   0
## 129    13   1        0      1       1    15     225     0  1.8718  33  78   0
## 130    12   1        0      0       1    27     729     0  1.2040  44  78   0
## 131    12   1        0      1       0     1       1     0  1.2164  18  78   0
## 132    17   1        0      1       1    12     144     0  1.9095  34  78   0
## 133    16   1        0      0       1    31     961     0  1.7636  52  78   0
## 134    10   1        0      0       1    18     324     0  1.2958  33  78   0
## 135     7   1        1      1       0    33    1089     0  1.3218  45  78   0
## 136     6   1        0      0       0    39    1521     0  1.5669  50  78   0
## 137    16   1        0      0       0     4      16     0  1.6094  25  78   0
## 138    14   1        0      1       0     4      16     0  1.4291  23  78   0
## 139    14   1        0      1       0     2       4     0  1.6582  21  78   0
## 140    17   1        0      0       0     4      16     0  1.9058  26  78   0
## 141    13   1        0      1       0    21     441     1  2.0149  39  78   0
## 142     4   1        0      0       0    13     169     0  0.9555  22  78   0
## 143    17   1        0      0       1    18     324     0  2.6455  40  78   0
## 144    14   1        0      1       0     9      81     0  2.5269  28  78   0
## 145    16   1        0      0       0     8      64     0  1.6094  29  78   0
## 146    10   1        1      0       1    35    1225     0  1.3863  50  78   0
## 147     6   1        0      1       1    17     289     0  1.0647  28  78   0
## 148    13   0        0      0       0     1       1     0  1.5261  19  78   0
## 149    16   0        0      0       1     3       9     1  1.4469  24  78   0
## 150    10   0        0      0       1    41    1681     1  1.8718  56  78   0
## 151    12   0        0      1       1    41    1681     1  3.0564  58  78   0
## 152    18   0        0      0       1    36    1296     0  1.8839  59  78   0
## 153    10   0        1      1       1    16     256     1  1.2528  31  78   0
## 154    12   0        1      1       0    36    1296     1  1.5892  53  78   0
## 155    12   0        1      0       1    39    1521     0  1.8205  56  78   0
## 156    13   0        0      0       1     2       4     0  1.7918  20  78   0
## 157    15   0        0      0       1     8      64     0  1.8137  28  78   0
## 158    12   0        0      0       1    35    1225     0  2.1972  52  78   0
## 159    12   0        0      1       0    12     144     0  1.6607  29  78   0
## 160    12   0        0      1       0    11     121     0  1.6094  28  78   0
## 161    18   0        1      1       0    10     100     0  1.8839  33  78   0
## 162    16   0        1      1       0     3       9     0  1.3218  24  78   0
## 163    10   0        0      0       1    48    2304     1  1.2528  63  78   0
## 164    15   0        0      0       0    20     400     1  2.4950  40  78   0
## 165     6   0        0      0       1    51    2601     1  1.8718  62  78   0
## 166    12   0        0      1       1    12     144     0  1.2238  29  78   0
## 167    10   0        0      0       1    26     676     0  1.7385  41  78   0
## 168     9   0        0      1       1    34    1156     1  2.0794  48  78   0
## 169    13   0        0      1       1    35    1225     0  1.4453  53  78   0
## 170    12   0        0      1       0    12     144     0  1.4469  29  78   0
## 171    11   0        0      0       0     5      25     0  1.2879  21  78   0
## 172    14   0        0      0       0     8      64     0  1.7492  27  78   0
## 173    12   0        0      0       1    29     841     1  2.0477  46  78   0
## 174     7   0        0      0       1    38    1444     1  1.8326  50  78   0
## 175    12   0        0      0       1    33    1089     0  1.3987  50  78   0
## 176     8   0        0      0       1    42    1764     0  1.8326  55  78   0
## 177    16   0        0      0       0     1       1     0  1.9315  22  78   0
## 178    13   0        1      0       0    17     289     1  1.9577  35  78   0
## 179    16   0        0      1       1     5      25     0  1.8326  26  78   0
## 180    12   0        0      1       0    13     169     0  1.2528  30  78   0
## 181    12   0        0      1       1    23     529     0  1.2384  40  78   0
## 182    16   0        0      1       1    12     144     1  0.6131  33  78   0
## 183    12   0        1      0       1    20     400     1  2.0149  37  78   0
## 184    13   0        0      0       1    33    1089     0  2.1691  51  78   0
## 185     9   0        0      0       1    22     484     0  1.4300  36  78   0
## 186    10   0        0      1       0    27     729     1  1.6405  42  78   0
## 187    14   0        0      0       1     9      81     1  1.9279  28  78   0
## 188    16   0        0      0       0     5      25     0  1.9810  26  78   0
## 189    12   0        0      0       1     8      64     0  1.5581  25  78   0
## 190    12   0        0      0       1    32    1024     1  2.1691  49  78   0
## 191    11   0        0      0       1    12     144     1  2.0149  28  78   0
## 192    16   0        0      0       0     2       4     0  1.9772  23  78   0
## 193    12   0        0      0       1    32    1024     1  1.9033  49  78   0
## 194    12   0        0      0       1    32    1024     0  1.8326  49  78   0
## 195    18   0        1      0       1    13     169     1  2.2571  36  78   0
## 196     8   0        0      0       1    34    1156     1  1.8563  47  78   0
## 197     9   0        0      1       0    16     256     0 -0.0780  30  78   0
## 198    16   0        0      0       1     8      64     0  1.6740  29  78   0
## 199    10   0        1      0       0    33    1089     0  1.6094  48  78   0
## 200    12   0        0      0       1    24     576     1  2.0794  41  78   0
## 201     9   0        1      0       1    34    1156     1  1.8326  48  78   0
## 202    18   0        0      0       1    30     900     0  2.9208  53  78   0
## 203    12   0        0      0       0     4      16     1  1.1394  21  78   0
## 204    16   0        1      1       1     5      25     0  1.8326  26  78   0
## 205    12   0        0      1       1     5      25     0  1.5841  22  78   0
## 206    10   0        0      0       1    44    1936     1  2.0820  59  78   0
## 207    11   0        0      0       0     8      64     0  1.7047  24  78   0
## 208    12   0        0      1       1    26     676     0  1.8245  43  78   0
## 209    14   0        0      0       1    37    1369     0  1.9924  56  78   0
## 210    12   0        1      1       0    20     400     0  1.0296  37  78   0
## 211    16   0        1      0       1    16     256     1  2.2558  37  78   0
## 212    12   0        0      0       1    14     196     0  2.3026  31  78   0
## 213    10   0        0      1       0    15     225     1  1.6376  30  78   0
## 214    12   0        0      0       0     3       9     1  1.5841  20  78   0
## 215    16   0        0      0       1    11     121     0  2.1768  32  78   0
## 216     8   0        0      0       1    40    1600     1  1.8326  53  78   0
## 217    12   0        0      1       0    21     441     0  2.4079  38  78   0
## 218    13   0        0      0       1     3       9     0  1.9636  21  78   0
## 219    12   0        0      1       0    17     289     0  1.9741  34  78   0
## 220    12   0        0      0       0     6      36     0  1.4351  23  78   0
## 221    11   1        1      0       1    28     784     1  2.0794  44  78   0
## 222    12   1        0      1       1     6      36     0  1.2040  23  78   0
## 223    14   1        0      1       0     4      16     0  1.2528  23  78   0
## 224    12   1        0      0       1    41    1681     0  2.1691  58  78   0
## 225    12   1        0      0       0    16     256     1  2.0149  33  78   0
## 226    12   1        0      1       1     6      36     0  0.4520  23  78   0
## 227    12   1        0      0       1    39    1521     1  2.0794  56  78   0
## 228    10   1        0      0       1    15     225     0  1.6928  30  78   0
## 229    12   1        0      1       1    18     324     0  1.4325  35  78   0
## 230    15   1        0      0       1     7      49     0  1.4929  27  78   0
## 231    16   1        0      0       1    36    1296     0  1.1394  57  78   0
## 232    14   1        0      1       1     6      36     0  1.7237  25  78   0
## 233    12   1        1      1       0    13     169     0  1.5261  30  78   0
## 234    13   1        0      0       0     2       4     0  1.0986  20  78   0
## 235     5   1        0      0       1    50    2500     0  1.1575  60  78   0
## 236    12   1        0      1       1    21     441     0  1.5581  38  78   0
## 237    12   1        0      0       1    28     784     0  1.2936  45  78   0
## 238    12   1        0      0       1    12     144     1  1.4759  29  78   0
## 239    15   1        1      1       1    29     841     0  1.2809  49  78   0
## 240    12   1        0      0       1     7      49     0  1.3863  24  78   0
## 241    12   1        0      0       1    22     484     0  2.1203  39  78   0
## 242    12   1        1      1       0    11     121     0  1.3481  28  78   0
## 243    12   0        0      1       0    40    1600     0  1.5217  57  78   0
## 244    12   0        0      0       1    31     961     0  1.5315  48  78   0
## 245    12   0        0      1       1    10     100     0  1.4214  27  78   0
## 246    16   0        0      0       1     9      81     0  1.9810  30  78   0
## 247    12   0        1      1       1    10     100     1  1.4469  27  78   0
## 248    15   0        0      0       1    42    1764     0  3.1322  62  78   0
## 249    12   0        0      1       1    45    2025     0  0.8873  62  78   0
## 250    17   0        0      0       1     8      64     1  2.3514  30  78   0
## 251    15   0        0      0       1    32    1024     0  2.1691  52  78   0
## 252    14   0        0      0       0     1       1     0  1.2528  20  78   0
## 253    12   0        0      1       1    17     289     0  1.4271  34  78   0
## 254    14   0        0      0       1    10     100     0  1.7405  29  78   0
## 255    12   0        0      0       1    18     324     1  2.2266  35  78   0
## 256    12   0        0      1       0    10     100     1  0.9676  27  78   0
## 257    12   0        0      0       1    29     841     1  1.8326  46  78   0
## 258    12   0        0      1       0    39    1521     0  1.6094  56  78   0
## 259    12   0        0      1       1    31     961     0  1.1787  48  78   0
## 260    10   0        0      0       1    18     324     1  2.2513  33  78   0
## 261    12   0        1      1       1    14     196     1  2.0149  31  78   0
## 262    12   0        0      1       1     8      64     0  1.0116  25  78   0
## 263    12   1        0      0       0     9      81     0  1.6094  26  78   0
## 264    16   1        0      1       0     3       9     0  1.0296  24  78   0
## 265     9   1        1      1       1    24     576     0  0.9746  38  78   0
## 266     7   1        0      1       1    21     441     0  0.8109  33  78   0
## 267    12   1        0      0       1    15     225     0  1.2879  32  78   0
## 268    18   1        0      0       0     2       4     0  1.8005  25  78   0
## 269    16   1        1      1       0    12     144     0  1.0986  33  78   0
## 270    12   1        1      1       1     7      49     0  1.1939  24  78   0
## 271     9   1        1      1       0    33    1089     0  1.3218  47  78   0
## 272    15   1        0      0       0     5      25     0  1.6487  25  78   0
## 273    18   1        0      1       0     3       9     0  1.3218  26  78   0
## 274    11   1        0      1       1     8      64     0  0.8990  24  78   0
## 275    13   1        0      1       1     5      25     0  1.3797  23  78   0
## 276    12   1        0      1       1     1       1     0  1.2264  18  78   0
## 277    12   0        0      1       1    21     441     0  0.9220  38  78   0
## 278    12   0        0      0       0     1       1     0  0.9773  18  78   0
## 279    11   0        0      1       1    37    1369     0  1.0159  53  78   0
## 280    12   0        0      0       1    17     289     1  1.6094  34  78   0
## 281    12   0        0      1       0    43    1849     0  1.6582  60  78   0
## 282    12   0        0      0       0     4      16     0  1.7272  21  78   0
## 283    12   0        0      0       0     6      36     0  1.0986  23  78   0
## 284     8   0        0      0       1    49    2401     1  1.9459  62  78   0
## 285    16   0        0      0       1    13     169     0  2.2783  34  78   0
## 286    18   0        0      0       1    11     121     1  1.5333  34  78   0
## 287     8   0        0      1       1    18     324     0  1.0473  31  78   0
## 288     7   1        1      0       1    14     196     0  1.5179  26  78   0
## 289    15   1        0      1       1    20     400     0  1.6297  40  78   0
## 290    14   1        0      1       0    38    1444     0  1.8718  57  78   0
## 291    10   1        0      0       1    46    2116     1  1.6094  61  78   0
## 292    18   1        0      0       1    20     400     0  2.6872  43  78   0
## 293    16   1        0      1       0     7      49     0  1.8908  28  78   0
## 294    12   1        0      1       1    10     100     0  1.1787  27  78   0
## 295    18   1        0      0       1    12     144     0  2.7080  35  78   0
## 296    12   1        0      1       0    13     169     0  2.1914  30  78   0
## 297    16   1        0      0       1    20     400     0  2.1203  41  78   0
## 298    12   1        0      0       0     6      36     0  1.5041  23  78   0
## 299     9   1        0      1       0     6      36     0  1.1787  20  78   0
## 300     8   1        0      0       1    40    1600     0  1.1632  53  78   0
## 301    12   1        0      1       0     1       1     0  0.9445  18  78   0
## 302    10   1        1      0       0    14     196     1  1.6094  29  78   0
## 303    12   1        0      0       0     5      25     0  1.0647  22  78   0
## 304     8   1        0      0       1    17     289     0  1.0647  30  78   0
## 305    12   1        0      0       1    14     196     0  2.0015  31  78   0
## 306    12   1        0      1       1    12     144     0  1.1394  29  78   0
## 307    13   1        0      0       1    30     900     1  1.9913  48  78   0
## 308    14   1        0      0       1    38    1444     1  2.0149  57  78   0
## 309    12   1        1      0       1    23     529     0  1.0647  40  78   0
## 310     9   1        0      0       0     5      25     0  0.9746  19  78   0
## 311    12   1        0      0       1    36    1296     1  2.1576  53  78   0
## 312    11   1        1      1       0    34    1156     0  1.1787  50  78   0
## 313    13   1        0      0       1     5      25     1  1.9936  23  78   0
## 314     6   0        1      0       1    48    2304     0  1.5738  59  78   0
## 315     6   0        0      0       1    38    1444     0  2.2225  49  78   0
## 316    15   0        1      1       0     8      64     0  1.6549  28  78   0
## 317    12   0        0      1       0    39    1521     1  1.7272  56  78   0
## 318    16   0        0      1       0    16     256     1  2.0314  37  78   0
## 319    14   0        0      1       1    25     625     0  0.4520  44  78   0
## 320    13   1        0      0       1     4      16     0  1.3218  22  78   0
## 321    12   1        0      0       0     6      36     0  1.6094  23  78   0
## 322    12   1        0      1       0    46    2116     0  2.0215  63  78   0
## 323    18   1        1      1       0    22     484     0  1.6818  45  78   0
## 324    11   1        0      0       1    27     729     0  1.8326  43  78   0
## 325    12   1        0      0       1     4      16     1  1.2528  21  78   0
## 326    11   1        0      0       1    41    1681     1  1.6341  57  78   0
## 327    16   1        1      1       0    30     900     1  2.3026  51  78   0
## 328    14   1        0      1       1     3       9     0  1.7430  22  78   0
## 329     7   1        1      0       1    21     441     1  1.8326  33  78   0
## 330    12   1        1      1       1    22     484     0  1.0498  39  78   0
## 331    18   1        0      0       0     9      81     0  2.1576  32  78   0
## 332    16   1        0      0       1    27     729     0  2.3826  48  78   0
## 333    16   1        0      1       0     2       4     0  1.5581  23  78   0
## 334    12   0        0      1       1     8      64     1  1.4231  25  78   0
## 335    10   0        0      1       1    27     729     0  1.1632  42  78   0
## 336    12   0        0      0       1    13     169     0  1.6243  30  78   0
## 337    10   0        0      0       1    43    1849     1  2.0149  58  78   0
## 338    14   0        0      0       1    16     256     0  1.9867  35  78   0
## 339    12   0        0      0       1    12     144     0  1.0498  29  78   0
## 340    15   0        0      1       0     4      16     0  1.3863  24  78   0
## 341    12   0        0      1       1     4      16     0  1.3218  21  78   0
## 342    12   0        0      1       0    12     144     1  1.5261  29  78   0
## 343    16   0        0      0       1     5      25     0  2.1972  26  78   0
## 344    18   1        0      0       1    36    1296     0  1.8971  59  78   0
## 345     2   1        1      0       1    55    3025     0  1.1394  62  78   0
## 346    12   1        0      0       0    17     289     0  1.3545  34  78   0
## 347    12   1        0      0       1    14     196     0  2.1203  31  78   0
## 348    18   1        0      0       0    31     961     0  2.4920  54  78   0
## 349    12   1        0      1       0    21     441     0  1.0986  38  78   0
## 350    12   1        0      0       0     5      25     0  1.5993  22  78   0
## 351    14   1        0      1       1    22     484     0  2.0949  41  78   0
## 352     7   1        0      0       1    19     361     1  1.6094  31  78   0
## 353    11   1        0      0       1    30     900     0  2.5257  46  78   0
## 354    14   1        0      0       1     9      81     0  1.8326  28  78   0
## 355    12   1        0      1       1    30     900     0  1.5686  47  78   0
## 356    12   1        0      0       0     9      81     1  1.7143  26  78   0
## 357    12   1        0      1       0     7      49     0  1.1787  24  78   0
## 358    13   1        0      1       0     1       1     0  0.6931  19  78   0
## 359    12   1        0      0       1    14     196     1  1.5581  31  78   0
## 360     8   0        0      0       1    37    1369     1  2.3979  50  78   0
## 361    12   0        0      1       1    28     784     0  1.6094  45  78   0
## 362    13   0        0      1       1     8      64     1  1.7492  26  78   0
## 363    12   0        0      0       1    36    1296     1  1.6292  53  78   0
## 364    12   0        0      1       0     1       1     0  1.2528  18  78   0
## 365    12   0        0      1       0    17     289     0  1.6094  34  78   0
## 366    15   0        0      0       0     5      25     0  1.3218  25  78   0
## 367    12   0        0      1       1     4      16     0  1.2528  21  78   0
## 368    12   0        0      0       1    15     225     1  1.9021  32  78   0
## 369     8   1        0      0       1    18     324     0  0.9925  31  78   0
## 370    16   1        0      0       1     2       4     0  1.3863  23  78   0
## 371    16   1        0      0       1     6      36     0  1.8971  27  78   0
## 372    12   1        0      1       1    23     529     0  1.7272  40  78   0
## 373    12   1        0      1       0    12     144     0  0.9746  29  78   0
## 374    12   1        0      0       1    20     400     1  2.3026  37  78   0
## 375    16   1        0      0       1    17     289     0  2.3026  38  78   0
## 376    16   0        0      1       1     8      64     0  2.0412  29  78   0
## 377    12   0        0      1       0     4      16     0  1.5315  21  78   0
## 378    12   0        1      0       0    13     169     0  1.3863  30  78   0
## 379    16   0        0      0       0    12     144     0  2.0468  33  78   0
## 380    15   0        0      0       0    17     289     0  2.2900  37  78   0
## 381    17   0        0      1       1     8      64     0  1.8718  30  78   0
## 382    10   0        0      0       1    42    1764     0  1.8654  57  78   0
## 383    10   0        0      0       0     5      25     1  1.7309  20  78   0
## 384    16   0        0      0       0    18     324     1  1.9741  39  78   0
## 385    12   0        0      1       0     3       9     0  1.4469  20  78   0
## 386     8   0        0      0       0    22     484     0  1.4271  35  78   0
## 387    12   0        0      1       1    18     324     0  1.2649  35  78   0
## 388    12   0        0      0       1     8      64     0  1.9636  25  78   0
## 389    15   0        0      0       1     1       1     0  1.7272  21  78   0
## 390    15   0        0      1       0     4      16     0  1.4858  24  78   0
## 391    12   0        0      0       1    11     121     0  1.3863  28  78   0
## 392    12   0        0      0       1    45    2025     1  2.1518  62  78   0
## 393    12   0        0      0       1    35    1225     0  2.1019  52  78   0
## 394    11   1        1      0       0    22     484     0  1.0116  38  78   0
## 395    12   1        0      1       1    13     169     0  1.7272  30  78   0
## 396    14   1        0      0       1    34    1156     0  3.3514  53  78   0
## 397    10   1        0      0       1     9      81     1  1.3218  24  78   0
## 398    10   1        0      0       1    36    1296     0  1.7918  51  78   0
## 399    10   1        0      0       1    14     196     0  1.6094  29  78   0
## 400    12   0        0      1       1     2       4     0  1.1291  19  78   0
## 401     8   0        0      0       1    32    1024     1  1.6487  45  78   0
## 402    14   0        0      1       0    39    1521     0  1.9459  58  78   0
## 403    12   0        0      1       1     9      81     0  0.8650  26  78   0
## 404    18   0        0      0       1     3       9     0  1.9373  26  78   0
## 405    10   0        0      0       1     8      64     0  0.8650  23  78   0
## 406    16   0        0      0       1     7      49     0  1.3806  28  78   0
## 407    14   0        0      0       1     7      49     0  1.6094  26  78   0
## 408    13   0        0      0       1     4      16     0  1.8326  22  78   0
## 409    16   0        0      0       0     5      25     0  1.6677  26  78   0
## 410    14   1        1      0       0     6      36     0  1.0986  25  78   0
## 411    12   1        0      0       1    37    1369     0  1.8795  54  78   0
## 412     6   1        1      0       0    11     121     0  1.0986  22  78   0
## 413     8   1        0      1       0    41    1681     1  1.6094  54  78   0
## 414    12   1        1      1       0    30     900     0  2.7444  47  78   0
## 415    16   1        0      0       1    13     169     0  2.1638  34  78   0
## 416    18   0        0      1       0     4      16     0  1.6094  27  78   0
## 417    12   0        0      1       1    16     256     0  1.7272  33  78   0
## 418    13   0        0      0       1     8      64     1  1.3083  26  78   0
## 419    16   0        0      0       1    32    1024     0  2.0149  53  78   0
## 420    12   0        0      1       0     6      36     0  0.9704  23  78   0
## 421    14   0        0      1       1    30     900     0  1.3610  49  78   0
## 422    12   0        0      1       0     1       1     0  1.0986  18  78   0
## 423    12   0        0      0       0     4      16     1  1.6487  21  78   0
## 424    13   0        0      0       1    41    1681     1  2.6912  59  78   0
## 425    12   0        0      0       1    22     484     1  2.0412  39  78   0
## 426    12   0        0      0       1    22     484     0  1.7619  39  78   0
## 427    15   0        0      0       1    31     961     1  2.5257  51  78   0
## 428    16   0        0      1       0     2       4     1  1.8524  23  78   0
## 429    15   0        0      0       1    19     361     1  2.0794  39  78   0
## 430    12   0        0      1       1    14     196     0  1.8101  31  78   0
## 431    11   0        0      1       0    16     256     0  1.2040  32  78   0
## 432    12   1        0      0       0     3       9     0  1.3466  20  78   0
## 433    12   1        0      0       1     3       9     1  1.5146  20  78   0
## 434     8   1        0      0       1    30     900     1  2.1102  43  78   0
## 435    12   1        0      1       0     3       9     0  0.9163  20  78   0
## 436     4   1        1      0       1    55    3025     0  1.1474  64  78   0
## 437    12   1        0      0       0     3       9     0  1.1394  20  78   0
## 438    11   1        0      0       1    19     361     1  2.5257  35  78   0
## 439     9   1        0      1       0    27     729     1  1.4553  41  78   0
## 440    12   1        0      0       1     9      81     1  1.7918  26  78   0
## 441    12   0        1      0       0    13     169     0  1.4351  30  78   0
## 442    16   0        0      0       1    31     961     0  2.5494  52  78   0
## 443    12   0        0      1       0    16     256     0  1.5422  33  78   0
## 444    11   0        0      0       0     4      16     0  0.9746  20  78   0
## 445    16   0        0      0       1     3       9     0  2.0015  24  78   0
## 446    16   0        0      1       0     4      16     0  1.4469  25  78   0
## 447    12   0        0      1       1    36    1296     1  1.3218  53  78   0
## 448     9   1        0      0       1     6      36     0  1.6094  20  78   0
## 449    12   1        0      0       1    19     361     0  1.9867  36  78   0
## 450    18   1        0      0       1    14     196     0  2.0669  37  78   0
## 451    12   0        0      0       1    38    1444     0  1.4610  55  78   0
## 452    13   0        0      0       1     8      64     1  1.8101  26  78   0
## 453    12   0        0      1       1     4      16     0  1.5581  21  78   0
## 454    15   0        0      0       0    12     144     0  1.8326  32  78   0
## 455    12   0        0      0       1    41    1681     0  2.4445  58  78   0
## 456    12   0        0      1       1    24     576     0  1.7430  41  78   0
## 457    11   0        0      0       1    17     289     0  1.7918  33  78   0
## 458    12   0        0      1       1     8      64     0  1.1787  25  78   0
## 459    12   0        0      0       0     2       4     0  1.3863  19  78   0
## 460    12   0        0      0       1     2       4     0  1.2448  19  78   0
## 461    12   0        0      1       1    39    1521     0  1.4469  56  78   0
## 462    12   0        0      0       1     6      36     0  2.5257  23  78   0
## 463     9   0        0      1       1    34    1156     0  1.0296  48  78   0
## 464    17   0        0      0       1    14     196     0  2.0149  36  78   0
## 465    17   0        0      0       1     7      49     0  2.0949  29  78   0
## 466    10   0        0      1       0    46    2116     0  0.9943  61  78   0
## 467    18   0        0      0       1     4      16     0  1.9279  27  78   0
## 468    12   0        0      1       1    12     144     0  0.5596  29  78   0
## 469    12   0        0      1       1     6      36     0  1.2164  23  78   0
## 470     6   0        0      0       1    15     225     0  1.4469  26  78   0
## 471    13   0        0      0       1    12     144     1  1.5041  30  78   0
## 472    17   0        0      0       1    15     225     0  2.1691  37  78   0
## 473    12   0        0      0       1    15     225     0  2.0794  32  78   0
## 474    12   0        1      1       1    12     144     1  1.1151  29  78   0
## 475    12   0        0      0       1    23     529     0  1.6790  40  78   0
## 476    14   0        0      0       0    41    1681     0  2.1848  60  78   0
## 477    12   0        0      1       0    42    1764     0  1.5041  59  78   0
## 478    12   0        0      0       1    10     100     0  1.7047  27  78   0
## 479    10   0        0      0       1    20     400     0  1.4586  35  78   0
## 480    13   0        0      0       1     4      16     1  1.7297  22  78   0
## 481    16   0        0      1       1    11     121     1  1.8326  32  78   0
## 482    12   0        0      1       0     6      36     0  1.1394  23  78   0
## 483    14   0        0      0       1    19     361     0  1.2496  38  78   0
## 484    12   0        0      0       1    32    1024     0  2.2401  49  78   0
## 485    12   0        0      0       1    21     441     0  1.3863  38  78   0
## 486    11   0        0      0       1    39    1521     0  1.2164  55  78   0
## 487    18   0        0      0       1    15     225     0  2.0815  38  78   0
## 488    12   0        0      1       1    25     625     1  1.5943  42  78   0
## 489    12   0        0      1       0    18     324     0  1.0733  35  78   0
## 490    12   0        0      1       1    21     441     0  1.7047  38  78   0
## 491    17   0        0      1       1    11     121     1  2.2437  33  78   0
## 492    14   0        0      0       0     6      36     0  1.1394  25  78   0
## 493    12   0        1      0       0     5      25     1  0.8755  22  78   0
## 494    15   1        1      1       1    12     144     0  2.1041  32  78   0
## 495     8   1        1      0       1    44    1936     0  1.0986  57  78   0
## 496    16   1        1      1       0     7      49     0  2.1691  28  78   0
## 497    16   1        1      1       0    25     625     0  1.3481  46  78   0
## 498    12   0        0      1       0     5      25     1  1.0986  22  78   0
## 499    12   0        0      0       1    27     729     0  2.0794  44  78   0
## 500    10   0        0      1       0    36    1296     1  1.2936  51  78   0
## 501    12   0        0      0       0    31     961     0  2.1401  48  78   0
## 502    14   0        0      0       0    27     729     0  2.4049  46  78   0
## 503    13   0        0      1       1    44    1936     0  1.3987  62  78   0
## 504    16   0        0      1       0     7      49     0  1.4291  28  78   0
## 505    12   0        0      0       0    13     169     1  1.9913  30  78   0
## 506    14   0        0      1       1    36    1296     0  1.3545  55  78   0
## 507    12   0        0      1       0     4      16     0  1.2669  21  78   0
## 508    12   0        0      0       1    30     900     1  2.0477  47  78   0
## 509    10   0        0      0       1    16     256     0  1.6094  31  78   0
## 510    17   0        0      0       1    15     225     1  2.0149  37  78   0
## 511    13   0        0      1       0     2       4     0  0.9725  20  78   0
## 512    12   0        0      0       1    32    1024     1  1.8326  49  78   0
## 513    12   0        0      0       1     9      81     0  1.2040  26  78   0
## 514    18   0        0      0       1    21     441     0  2.3026  44  78   0
## 515    12   0        0      1       1     4      16     0  1.2528  21  78   0
## 516    13   0        0      1       1    35    1225     0  1.5041  53  78   0
## 517    14   0        0      1       1     5      25     0  1.3863  24  78   0
## 518    12   0        0      1       0     1       1     0  1.0116  18  78   0
## 519    10   0        0      0       0     3       9     0  1.3657  18  78   0
## 520    12   0        0      1       0     3       9     0  1.3218  20  78   0
## 521    12   0        0      0       1    21     441     0  2.3026  38  78   0
## 522    12   0        0      0       1     6      36     0  2.0149  23  78   0
## 523    18   1        0      0       0    34    1156     0  3.2179  57  78   0
## 524    12   1        0      1       0    22     484     0  1.6094  39  78   0
## 525    17   1        0      0       1    16     256     0  2.5840  38  78   0
## 526    13   0        0      1       0     4      16     0  1.3218  22  78   0
## 527    18   0        0      0       1    15     225     0  2.1019  38  78   0
## 528    13   0        0      0       1    26     676     0  1.6784  44  78   0
## 529    17   0        0      1       1    19     361     1  1.7492  41  78   0
## 530     7   0        0      0       1    43    1849     0  0.9746  55  78   0
## 531     8   0        0      0       1    18     324     0  1.8718  31  78   0
## 532    17   0        0      0       1    10     100     1  1.6094  32  78   0
## 533    10   0        0      0       0     3       9     0  0.7985  18  78   0
## 534     9   0        0      0       1    46    2116     0  1.2040  60  78   0
## 535    12   0        0      1       1    10     100     1  1.4171  27  78   0
## 536    17   0        0      0       1     5      25     1  1.8871  27  78   0
## 537    14   0        0      0       0     5      25     0  1.6503  24  78   0
## 538    12   0        0      1       0     7      49     0  1.1925  24  78   0
## 539    12   0        0      0       1    15     225     1  2.3933  32  78   0
## 540    12   0        0      0       1    31     961     1  2.1889  48  78   0
## 541    12   0        0      0       1    39    1521     0  2.5257  56  78   0
## 542    14   0        0      0       1     8      64     0  1.6094  27  78   0
## 543    13   0        0      1       1    28     784     0  0.9163  46  78   0
## 544    16   0        0      1       0    10     100     1  2.4145  31  78   0
## 545    12   0        0      0       1    36    1296     1  2.5257  53  78   0
## 546    15   0        0      1       1     3       9     1  2.0794  23  78   0
## 547    12   0        0      0       1    27     729     1  2.6583  44  78   0
## 548     8   0        0      0       1    47    2209     1  2.4744  60  78   0
## 549    12   0        0      1       0    39    1521     1  2.6391  56  78   0
## 550    15   0        0      0       0    12     144     0  2.5257  32  78   0
## 551    10   0        0      0       1    27     729     0  2.1972  43  85   1
## 552    12   0        0      0       1    20     400     0  1.7047  38  85   1
## 553    12   0        0      1       0     4      16     0  1.3350  22  85   1
## 554    12   0        0      1       1    29     841     0  2.3514  47  85   1
## 555    12   0        0      0       1    40    1600     1  2.7080  58  85   1
## 556    16   0        0      1       1    27     729     0  2.1972  49  85   1
## 557    12   0        0      1       1     5      25     1  2.2586  23  85   1
## 558    14   0        0      0       0    22     484     0  2.7080  42  85   1
## 559     8   0        0      0       1    42    1764     0  2.3979  56  85   1
## 560    12   0        0      1       1    14     196     0  1.6094  32  85   1
## 561    17   0        0      0       1    18     324     0  3.2179  41  85   1
## 562    17   0        0      0       0     3       9     0  3.0155  26  85   1
## 563    14   0        0      0       0     4      16     1  3.2189  24  85   1
## 564    14   0        0      0       0    14     196     0  2.6376  34  85   1
## 565    12   0        0      0       1    35    1225     0  1.2528  53  85   1
## 566    14   0        0      0       0     0       0     0  1.6094  20  85   1
## 567    16   0        0      0       1     7      49     1  2.3026  29  85   1
## 568    16   0        1      0       1    26     676     1  2.7080  48  85   1
## 569    13   0        1      0       0     3       9     0  1.7630  22  85   1
## 570    13   0        0      0       0    16     256     0  2.2083  35  85   1
## 571    17   0        1      1       1    32    1024     0  2.4204  55  85   1
## 572    12   0        1      0       1    25     625     1  2.5649  43  85   1
## 573    14   0        0      1       0    15     225     1  2.0794  35  85   1
## 574    12   0        0      1       1    38    1444     0  1.4540  56  85   1
## 575    16   0        1      0       1    17     289     0  2.0637  39  85   1
## 576    12   0        0      1       0     7      49     0  1.9379  25  85   1
## 577    17   0        0      1       0     5      25     0  3.2179  28  85   1
## 578    14   0        0      0       1    22     484     0  2.3026  42  85   1
## 579    14   0        0      0       1    21     441     0  2.6210  41  85   1
## 580    13   0        0      1       1     2       4     0  1.7272  21  85   1
## 581    14   0        1      0       1    16     256     0  2.6858  36  85   1
## 582    16   0        0      0       1    18     324     0  3.2179  40  85   1
## 583    12   0        0      0       1    14     196     0  2.4849  32  85   1
## 584    18   0        0      0       1    12     144     0  2.7080  36  85   1
## 585    16   0        0      0       0     3       9     0  1.7535  25  85   1
## 586    17   0        0      1       1    13     169     0  2.5377  36  85   1
## 587    16   0        0      1       0    42    1764     0  2.4605  64  85   1
## 588    12   0        0      0       1     8      64     0  2.5649  26  85   1
## 589    15   0        0      1       1     6      36     0  2.5257  27  85   1
## 590    16   0        0      0       1    22     484     0  3.1135  44  85   1
## 591    16   0        1      1       0     3       9     0  2.4204  25  85   1
## 592    16   0        0      0       1    33    1089     0  2.7331  55  85   1
## 593    13   0        0      1       0     8      64     1  2.0412  27  85   1
## 594    12   0        0      0       1    26     676     0  2.4715  44  85   1
## 595    14   0        0      0       1     0       0     0  1.6094  20  85   1
## 596    12   0        0      0       1    28     784     0  1.8718  46  85   1
## 597     8   0        0      0       1    33    1089     1  2.1972  47  85   1
## 598    12   0        0      0       0     0       0     0  1.2090  18  85   1
## 599    12   0        0      1       1     7      49     0  1.5041  25  85   1
## 600    14   0        0      1       1    12     144     0  2.3539  32  85   1
## 601     9   0        0      0       1    47    2209     1  1.2528  62  85   1
## 602    16   0        0      0       1    12     144     0  2.7080  34  85   1
## 603    12   0        0      1       0    25     625     0  2.1401  43  85   1
## 604    12   0        0      1       1    44    1936     0  2.2159  62  85   1
## 605     9   0        0      0       0    33    1089     1  2.2618  48  85   1
## 606     8   0        0      1       1    22     484     0  1.9279  36  85   1
## 607    18   0        0      1       1    14     196     0  2.6355  38  85   1
## 608    14   0        1      0       0    22     484     0  2.3026  42  85   1
## 609    12   0        0      1       0    41    1681     0  1.3218  59  85   1
## 610    12   0        0      1       0     8      64     0  2.0794  26  85   1
## 611    12   0        0      1       1    43    1849     0  2.4567  61  85   1
## 612     8   0        1      1       0    29     841     0  2.1844  43  85   1
## 613    12   0        1      0       0     6      36     1  1.3863  24  85   1
## 614    12   0        1      1       0    21     441     0  1.7047  39  85   1
## 615    16   0        1      0       0     3       9     0  1.2090  25  85   1
## 616    12   0        0      1       1    40    1600     0  2.3805  58  85   1
## 617    12   0        0      0       1     5      25     0  1.9459  23  85   1
## 618    13   0        0      0       1    34    1156     1  2.3026  53  85   1
## 619    16   0        0      1       1    10     100     0  1.6864  32  85   1
## 620    12   0        0      1       0    10     100     0  2.0149  28  85   1
## 621    12   0        0      0       1    41    1681     1  2.4204  59  85   1
## 622    10   0        0      1       1    25     625     1  2.3026  41  85   1
## 623    13   0        0      0       0     0       0     0  1.3863  19  85   1
## 624    18   0        0      0       1    14     196     1  2.6037  38  85   1
## 625    12   0        0      0       0    22     484     0  1.9095  40  85   1
## 626    14   0        0      1       1    32    1024     0  2.6593  52  85   1
## 627    15   0        0      1       1     9      81     0  2.2773  30  85   1
## 628    12   0        0      1       0     0       0     0  1.2090  18  85   1
## 629     8   0        0      1       0    49    2401     0  1.2238  63  85   1
## 630    14   0        0      1       1    32    1024     0  1.7272  52  85   1
## 631    12   0        0      0       1     7      49     1  1.9459  25  85   1
## 632    16   0        0      1       1    10     100     0  2.3026  32  85   1
## 633    10   0        0      1       0    44    1936     1  1.8083  60  85   1
## 634    12   0        0      1       1    27     729     0  1.4279  45  85   1
## 635    12   0        0      1       1    16     256     0  1.5686  34  85   1
## 636    12   0        0      0       1     3       9     0  1.7492  21  85   1
## 637    12   0        0      0       1     8      64     0  1.5581  26  85   1
## 638    17   0        0      0       1     7      49     1  2.2380  30  85   1
## 639    12   0        0      1       0     8      64     0  1.6582  26  85   1
## 640     9   0        0      1       1    42    1764     0  1.5994  57  85   1
## 641    16   0        0      1       1    11     121     0  2.9640  33  85   1
## 642    12   0        0      0       1    23     529     0  2.9947  41  85   1
## 643    12   0        0      0       0     4      16     0  1.3863  22  85   1
## 644    12   0        0      1       0     0       0     0  1.6094  18  85   1
## 645    14   0        0      0       1    25     625     0  2.3590  45  85   1
## 646    12   0        1      0       0    22     484     1  2.3026  40  85   1
## 647    14   0        0      1       0    15     225     0  1.9981  35  85   1
## 648    15   0        0      0       0    10     100     0  2.5257  31  85   1
## 649    16   0        0      1       0    20     400     0  1.3863  42  85   1
## 650    12   0        0      1       1    24     576     0  2.7101  42  85   1
## 651    12   1        0      0       1    12     144     0  2.7726  30  85   1
## 652    12   1        0      1       0    12     144     0  1.2698  30  85   1
## 653    12   1        0      0       0    16     256     0  1.5041  34  85   1
## 654    12   1        0      1       0     4      16     0  1.5151  22  85   1
## 655    12   1        0      1       1    43    1849     0  1.2809  61  85   1
## 656    12   1        0      1       1    14     196     0  2.0794  32  85   1
## 657    12   1        0      1       0    10     100     0  1.5581  28  85   1
## 658    12   1        0      0       1     2       4     0  1.9066  20  85   1
## 659    12   1        0      0       1    28     784     0  2.4079  46  85   1
## 660     7   1        0      1       1    15     225     0  1.7918  28  85   1
## 661    12   1        0      0       1    20     400     0  2.3026  38  85   1
## 662    12   1        0      1       1    30     900     0  2.4204  48  85   1
## 663    12   1        0      1       1     9      81     0  1.3737  27  85   1
## 664    16   1        1      0       1    13     169     0  2.8622  35  85   1
## 665    13   1        0      1       0     1       1     0  1.2669  20  85   1
## 666    16   1        0      0       0     8      64     0  1.7918  30  85   1
## 667    14   1        0      0       1    15     225     0  3.0910  35  85   1
## 668    12   1        0      1       0     6      36     0  1.8326  24  85   1
## 669     7   1        0      0       1    14     196     0  1.5041  27  85   1
## 670    13   1        0      1       0    28     784     0  2.3341  47  85   1
## 671    14   1        0      0       1    10     100     0  2.5014  30  85   1
## 672    17   1        0      0       0    14     196     0  2.8994  37  85   1
## 673    16   1        0      0       1    10     100     0  2.7080  32  85   1
## 674    13   1        0      1       1    10     100     0  2.1691  29  85   1
## 675    14   1        0      0       1    44    1936     0  2.9947  64  85   1
## 676    16   0        0      1       0    10     100     1  1.8971  32  85   1
## 677    14   0        0      0       1    22     484     1  2.2644  42  85   1
## 678    11   0        0      0       1    18     324     1  1.7047  35  85   1
## 679    12   0        0      1       0     9      81     0  2.0794  27  85   1
## 680    18   0        0      1       1    19     361     0  2.9957  43  85   1
## 681    17   0        0      1       1    14     196     0  2.2513  37  85   1
## 682    16   0        0      1       0     6      36     1  2.4672  28  85   1
## 683    16   0        0      1       0    17     289     0  2.6311  39  85   1
## 684    11   0        0      1       1    24     576     0  1.7047  41  85   1
## 685    11   0        0      1       0    12     144     0  1.9459  29  85   1
## 686    12   0        0      1       1    38    1444     0  2.2670  56  85   1
## 687    15   0        0      1       0    33    1089     0  2.3618  54  85   1
## 688     2   0        0      0       0    16     256     0  1.3218  24  85   1
## 689    14   0        0      1       1    10     100     0  2.4849  30  85   1
## 690    14   0        0      1       1    14     196     0  2.1471  34  85   1
## 691    14   0        0      0       0    16     256     0  2.7813  36  85   1
## 692    11   0        0      0       0    11     121     0  1.3218  28  85   1
## 693    16   0        1      1       1     6      36     0  2.1972  28  85   1
## 694    12   0        1      1       1    33    1089     0  2.5745  51  85   1
## 695    16   0        0      0       0    10     100     0  2.5802  32  85   1
## 696    12   0        0      0       0    19     361     0  2.2246  37  85   1
## 697    12   0        0      0       0     4      16     0  1.6094  22  85   1
## 698    17   0        0      1       0     3       9     1  1.7918  26  85   1
## 699    12   0        0      1       1    32    1024     0  1.9459  50  85   1
## 700     8   0        0      0       1    19     361     0  1.5476  33  85   1
## 701    16   0        0      1       1    22     484     0  2.0149  44  85   1
## 702    18   0        0      0       1    33    1089     0  1.9459  57  85   1
## 703    18   0        0      0       1    19     361     0  2.4174  43  85   1
## 704    18   0        0      0       1     3       9     0  1.7430  27  85   1
## 705    12   0        0      0       1    12     144     0  1.7047  30  85   1
## 706    12   0        0      0       1    16     256     0  2.1972  34  85   1
## 707    12   0        0      1       1     4      16     0  1.4171  22  85   1
## 708    12   0        0      0       1    11     121     1  2.3026  29  85   1
## 709    12   0        0      0       1    17     289     0  2.0149  35  85   1
## 710    11   0        0      0       0    16     256     0  1.2947  33  85   1
## 711    12   0        0      0       1    18     324     0  2.1848  36  85   1
## 712    18   0        0      0       1    15     225     0  2.8904  39  85   1
## 713    14   0        1      0       0     0       0     0  1.2090  20  85   1
## 714    16   0        1      0       0     8      64     0  2.5990  30  85   1
## 715    16   0        0      0       1    17     289     0  3.1135  39  85   1
## 716    18   0        0      0       0    13     169     0  2.9444  37  85   1
## 717    12   0        0      1       1    18     324     0  2.1894  36  85   1
## 718    11   0        1      1       1    16     256     0  1.9459  33  85   1
## 719    14   0        0      1       0    24     576     0  1.4271  44  85   1
## 720    12   0        0      0       1    23     529     0  2.2854  41  85   1
## 721    12   0        0      0       0     1       1     0  1.8971  19  85   1
## 722    12   0        0      1       1    10     100     1  1.9459  28  85   1
## 723    12   0        0      1       1    42    1764     0  1.2910  60  85   1
## 724    18   0        0      1       0    37    1369     0  3.1279  61  85   1
## 725    12   0        0      1       1    14     196     0  1.6094  32  85   1
## 726    18   0        0      0       1    14     196     0  3.1135  38  85   1
## 727    12   0        0      1       1    11     121     0  2.4849  29  85   1
## 728    12   0        0      1       1    38    1444     0  1.8374  56  85   1
## 729    12   0        0      1       0     3       9     0  1.5041  21  85   1
## 730    12   0        0      0       1     9      81     0  1.7918  27  85   1
## 731    10   0        0      0       1    13     169     0  1.9095  29  85   1
## 732    12   0        0      0       0     9      81     0  2.1691  27  85   1
## 733    16   0        0      0       1    11     121     0  2.5859  33  85   1
## 734    13   0        0      1       1    30     900     0  1.8326  49  85   1
## 735    12   0        0      1       0    15     225     1  2.1961  33  85   1
## 736    14   0        0      0       0     2       4     0  2.0149  22  85   1
## 737    17   0        0      1       1    24     576     0  2.4849  47  85   1
## 738    18   0        0      1       0    31     961     1  2.6391  55  85   1
## 739    14   0        0      0       0    19     361     0  2.7988  39  85   1
## 740    14   0        0      0       0     2       4     0  1.8326  22  85   1
## 741    12   0        0      0       1     4      16     1  2.3514  22  85   1
## 742     9   0        0      1       1    46    2116     1  2.2513  61  85   1
## 743     6   0        0      1       1    43    1849     1  1.0986  55  85   1
## 744    14   0        0      1       1    13     169     0  2.2214  33  85   1
## 745    12   0        0      1       0    15     225     0  1.3863  33  85   1
## 746    12   0        0      1       0    16     256     0  1.3350  34  85   1
## 747    12   0        0      1       1    19     361     0  1.7918  37  85   1
## 748    12   0        0      1       1    28     784     0  1.6094  46  85   1
## 749    12   0        0      0       1    42    1764     0  2.7080  60  85   1
## 750    11   0        0      1       0    45    2025     1  1.7138  62  85   1
## 751    16   0        1      0       1     7      49     0  2.1972  29  85   1
## 752    17   0        0      0       1    31     961     0  3.2179  54  85   1
## 753    12   0        0      1       1    24     576     0  2.1389  42  85   1
## 754    14   0        0      1       1    17     289     0  1.6094  37  85   1
## 755    12   0        0      0       1    26     676     1  3.1001  44  85   1
## 756    16   0        1      0       1     5      25     1  2.2235  27  85   1
## 757    16   0        0      1       1    17     289     0  2.0794  39  85   1
## 758    10   1        0      1       0    33    1089     0  1.2528  49  85   1
## 759    13   1        0      1       1     2       4     0  1.2090  21  85   1
## 760    16   1        1      1       1    14     196     0  1.2090  36  85   1
## 761    16   1        0      1       1    28     784     1  2.9957  50  85   1
## 762    12   1        0      1       0    46    2116     0  1.3863  64  85   1
## 763    16   1        0      0       1    38    1444     0  2.8904  60  85   1
## 764    13   1        0      1       0     0       0     0  1.5041  19  85   1
## 765    12   1        0      1       0     1       1     0  2.0557  19  85   1
## 766    12   1        0      1       1     5      25     0  0.5596  23  85   1
## 767    18   1        0      1       1    13     169     0  1.6487  37  85   1
## 768    10   1        0      0       0    19     361     0  2.1691  35  85   1
## 769    12   1        0      0       1     5      25     0  1.6094  23  85   1
## 770    12   1        1      1       1     6      36     0  1.3218  24  85   1
## 771    13   1        0      0       1     9      81     0  1.7834  28  85   1
## 772    12   1        0      0       0     7      49     0  1.3863  25  85   1
## 773     3   1        0      0       1    55    3025     0  1.9459  64  85   1
## 774    17   1        0      1       0     1       1     0  1.6094  24  85   1
## 775     6   1        1      1       0    33    1089     0  1.5304  45  85   1
## 776    12   1        0      1       1    21     441     0  1.7492  39  85   1
## 777    18   0        0      0       1    29     841     0  3.2179  53  85   1
## 778    18   0        0      0       1     7      49     0  2.7593  31  85   1
## 779    16   0        0      0       0    10     100     0  2.7444  32  85   1
## 780    16   0        0      0       0     9      81     0  1.2090  31  85   1
## 781    18   0        0      0       1     7      49     0  2.8994  31  85   1
## 782    18   0        0      0       0    33    1089     1  2.0794  57  85   1
## 783    13   0        0      0       0    31     961     0  1.7918  50  85   1
## 784    18   0        0      0       1     5      25     0  2.8478  29  85   1
## 785    16   0        0      1       0     2       4     0  1.7047  24  85   1
## 786    12   0        0      0       0    20     400     0  2.0347  38  85   1
## 787    16   0        1      0       0     4      16     0  1.8326  26  85   1
## 788    12   0        0      1       1    45    2025     0  1.8563  63  85   1
## 789    12   0        0      1       1    24     576     0  1.8839  42  85   1
## 790    12   0        0      0       1    43    1849     0  2.5257  61  85   1
## 791    18   0        0      0       1    10     100     0  2.5903  34  85   1
## 792    12   0        0      0       0     3       9     0  1.7047  21  85   1
## 793    15   0        0      0       0     5      25     0  2.4204  26  85   1
## 794    12   0        0      1       0    45    2025     0  2.3632  63  85   1
## 795    12   0        1      1       1    43    1849     1  2.0794  61  85   1
## 796    17   0        0      1       1    26     676     1  2.3224  49  85   1
## 797    12   0        0      1       1    42    1764     0  1.7561  60  85   1
## 798    12   0        0      0       1    37    1369     0  1.9879  55  85   1
## 799    14   0        0      1       0     1       1     0  3.7955  21  85   1
## 800    13   0        0      1       1    14     196     0  2.3514  33  85   1
## 801    12   0        0      0       1     8      64     0  2.2364  26  85   1
## 802    12   0        0      1       1    24     576     0  1.6487  42  85   1
## 803    12   0        0      1       1    20     400     0  1.4469  38  85   1
## 804    17   0        0      1       0    13     169     1  2.7695  36  85   1
## 805    15   0        0      0       1    12     144     0  3.1135  33  85   1
## 806    16   1        0      1       1     4      16     0  1.6094  26  85   1
## 807    12   1        1      0       1    14     196     0  1.6677  32  85   1
## 808    18   1        0      0       1    14     196     0  1.8326  38  85   1
## 809    18   1        0      1       0    13     169     0  2.3026  37  85   1
## 810    12   1        0      0       1    20     400     0  1.7047  38  85   1
## 811     9   1        0      1       1    30     900     0  1.9169  45  85   1
## 812    12   1        0      1       1    28     784     0  1.0986  46  85   1
## 813    16   1        0      0       1    14     196     1  2.3026  36  85   1
## 814    10   1        0      0       0    13     169     0  1.5790  29  85   1
## 815    12   1        0      0       1    32    1024     0  2.2425  50  85   1
## 816    15   1        0      1       0    26     676     0  1.7918  47  85   1
## 817    13   1        0      1       0     0       0     0  1.4469  19  85   1
## 818    14   1        0      0       1    12     144     1  2.3997  32  85   1
## 819    12   1        1      1       1    32    1024     0  2.4982  50  85   1
## 820    12   1        0      0       1    12     144     0  2.1318  30  85   1
## 821    12   1        0      0       0     3       9     0  2.4361  21  85   1
## 822     9   1        0      0       1    29     841     0  2.9947  44  85   1
## 823    14   1        0      1       0    10     100     0  1.9279  30  85   1
## 824    12   0        0      1       1    16     256     1  1.7430  34  85   1
## 825    12   0        0      1       1     8      64     0  1.2090  26  85   1
## 826     9   0        0      1       1    16     256     0  1.5790  31  85   1
## 827    12   0        0      1       1    15     225     0  1.7492  33  85   1
## 828    12   0        0      1       1    18     324     0  1.6864  36  85   1
## 829    12   0        0      1       1    38    1444     0  2.5770  56  85   1
## 830    12   0        0      1       1    13     169     0  2.4262  31  85   1
## 831    13   0        0      0       1    18     324     0  2.1691  37  85   1
## 832    12   0        0      0       1    19     361     1  2.5031  37  85   1
## 833    10   0        0      0       1    15     225     0  1.6582  31  85   1
## 834    14   1        0      0       0     5      25     0  1.7148  25  85   1
## 835    12   1        0      1       1    36    1296     0  1.5239  54  85   1
## 836    12   1        0      0       1    38    1444     0  2.0149  56  85   1
## 837    12   1        0      0       0     5      25     0  2.4849  23  85   1
## 838    12   1        0      0       1    35    1225     1  2.7726  53  85   1
## 839    11   1        1      0       0     3       9     0  1.2090  20  85   1
## 840    10   1        0      0       0    27     729     0  1.4929  43  85   1
## 841    12   1        0      1       1    29     841     0  1.4469  47  85   1
## 842    10   1        1      1       1    38    1444     0  2.5726  54  85   1
## 843    10   1        0      0       1     9      81     0  1.9459  25  85   1
## 844     6   1        0      0       1    45    2025     0  1.7492  57  85   1
## 845     8   1        0      0       1    27     729     0  1.8718  41  85   1
## 846    12   1        1      0       1    20     400     0  2.0293  38  85   1
## 847    16   1        0      0       1    14     196     1  3.0204  36  85   1
## 848    12   1        0      0       0     1       1     0  1.8326  19  85   1
## 849    11   1        1      1       1    25     625     0  1.3455  42  85   1
## 850    14   1        0      0       1    21     441     0  2.8124  41  85   1
## 851    17   0        0      1       0    10     100     0  2.4204  33  85   1
## 852    14   0        0      0       0     2       4     0  1.7317  22  85   1
## 853    11   0        0      0       0    17     289     0  1.8718  34  85   1
## 854    12   0        0      1       1    24     576     0  2.0477  42  85   1
## 855    12   0        0      0       1    26     676     1  1.9359  44  85   1
## 856    12   0        0      0       1    39    1521     1  2.7080  57  85   1
## 857     7   0        1      0       1    42    1764     1  1.9459  55  85   1
## 858     7   1        0      0       1    43    1849     0  1.2090  56  85   1
## 859    12   1        0      0       0     5      25     0  1.8718  23  85   1
## 860    16   1        0      1       1     7      49     0  1.8326  29  85   1
## 861    13   1        0      1       1     6      36     0  1.6094  25  85   1
## 862    13   1        1      1       0     1       1     0  1.2384  20  85   1
## 863    14   1        0      0       1    41    1681     0  2.1748  61  85   1
## 864    16   1        0      1       1     4      16     0  2.3026  26  85   1
## 865    11   1        0      1       1    25     625     1  1.3863  42  85   1
## 866    12   1        0      1       1    39    1521     0  2.2513  57  85   1
## 867    14   1        0      1       1    15     225     0  2.3447  35  85   1
## 868    18   1        0      0       1    10     100     0  1.6506  34  85   1
## 869    12   1        0      1       0    20     400     0  2.0149  38  85   1
## 870    17   1        0      0       1     2       4     0  1.9459  25  85   1
## 871    11   1        1      0       1    28     784     1  2.3777  45  85   1
## 872    10   1        0      0       1    27     729     1  2.1861  43  85   1
## 873    16   1        0      1       0    13     169     0  1.3218  35  85   1
## 874    15   1        0      0       0     4      16     0  1.3218  25  85   1
## 875    12   0        0      0       0    13     169     0  2.2460  31  85   1
## 876    12   0        0      0       1    33    1089     1  2.7080  51  85   1
## 877    12   0        0      1       0     6      36     0  1.2809  24  85   1
## 878    18   0        0      0       1    23     529     1  2.4849  47  85   1
## 879    16   0        0      1       1     6      36     0  2.3632  28  85   1
## 880    16   0        0      1       1    16     256     0  2.6391  38  85   1
## 881    16   0        0      0       0     3       9     1  1.6094  25  85   1
## 882    12   0        0      0       0    19     361     1  2.4423  37  85   1
## 883    12   0        0      0       1    43    1849     1  2.6181  61  85   1
## 884    12   1        0      0       1    34    1156     0  2.3632  52  85   1
## 885    12   1        0      1       0    25     625     0  2.0082  43  85   1
## 886    10   1        1      0       1    41    1681     1  1.9095  57  85   1
## 887    17   1        1      1       0     6      36     0  1.7707  29  85   1
## 888    12   1        1      0       0     2       4     0  1.2321  20  85   1
## 889     8   1        1      1       1    37    1369     0  1.4702  51  85   1
## 890    12   1        1      0       1    19     361     1  2.5649  37  85   1
## 891     5   1        0      0       1    44    1936     0  2.6391  55  85   1
## 892    10   1        1      1       1    37    1369     0  1.2566  53  85   1
## 893    13   1        0      0       0     8      64     0  1.4586  27  85   1
## 894    18   1        0      0       1    12     144     0  1.7670  36  85   1
## 895    12   0        0      0       0     8      64     0  1.7918  26  85   1
## 896    16   0        0      0       1    13     169     1  2.3979  35  85   1
## 897    13   0        0      0       0    32    1024     0  3.0564  51  85   1
## 898    16   0        0      0       1    18     324     0  2.6759  40  85   1
## 899    12   0        1      0       0     8      64     0  1.9242  26  85   1
## 900    16   0        0      1       0     0       0     0  2.3026  18  85   1
## 901    16   0        0      1       1     7      49     0  2.3026  29  85   1
## 902    16   1        0      1       0     5      25     0  3.2179  27  85   1
## 903    12   1        0      1       1    17     289     0  1.3218  35  85   1
## 904    11   1        0      0       1    39    1521     0  1.8718  56  85   1
## 905    12   1        0      0       0     4      16     0  1.6094  22  85   1
## 906     8   1        0      1       0    45    2025     0  1.5151  59  85   1
## 907    12   0        0      0       0     8      64     0  1.8718  26  85   1
## 908    16   0        0      0       0     9      81     0  2.3585  31  85   1
## 909    12   0        0      0       1    23     529     0  2.2576  41  85   1
## 910    16   0        0      1       1    14     196     0  2.4849  36  85   1
## 911    12   0        0      1       0    16     256     0  2.1401  34  85   1
## 912    12   0        0      1       1    15     225     0  1.4110  33  85   1
## 913    12   0        0      1       0    15     225     0  1.5041  33  85   1
## 914    16   0        0      0       1    16     256     0  2.4423  38  85   1
## 915    14   0        0      0       0    13     169     0  2.1861  33  85   1
## 916    11   0        0      0       0    15     225     1  2.6539  32  85   1
## 917    16   0        0      0       1    11     121     0  2.6137  33  85   1
## 918    18   0        0      1       0    40    1600     0  3.1001  64  85   1
## 919    18   0        0      1       1    11     121     0  2.7080  35  85   1
## 920    13   1        0      0       1    17     289     0  2.0869  36  85   1
## 921    12   1        0      0       1    12     144     0  1.9095  30  85   1
## 922    11   1        1      0       1    14     196     0  1.5041  31  85   1
## 923    12   1        0      1       1    26     676     0  1.9459  44  85   1
## 924    12   1        1      1       1    27     729     0  2.0149  45  85   1
## 925    12   1        0      1       1    16     256     0  2.0149  34  85   1
## 926    12   1        1      0       0     2       4     0  2.1401  20  85   1
## 927     7   1        0      0       1    44    1936     0  2.0794  57  85   1
## 928     8   1        0      0       1     8      64     0  1.2528  22  85   1
## 929    12   1        0      0       1     9      81     0  2.5257  27  85   1
## 930    12   1        0      0       0     1       1     1  1.7918  19  85   1
## 931    16   1        0      1       0     2       4     0  1.6582  24  85   1
## 932    12   1        0      0       0     6      36     0  1.6094  24  85   1
## 933    11   1        0      1       1    17     289     0  1.2528  34  85   1
## 934    14   1        0      0       1    14     196     1  2.3979  34  85   1
## 935    12   0        0      0       0     3       9     0  2.0149  21  85   1
## 936    12   0        0      0       1    13     169     0  2.1401  31  85   1
## 937    12   0        0      0       0    11     121     0  2.5257  29  85   1
## 938    12   0        0      0       1    24     576     1  2.3749  42  85   1
## 939    12   0        0      1       1    14     196     1  2.5257  32  85   1
## 940    17   0        0      0       1     7      49     0  2.0541  30  85   1
## 941    17   0        0      0       1    13     169     0  2.4849  36  85   1
## 942    12   1        1      1       1    10     100     0  1.2090  28  85   1
## 943    12   1        0      0       1    13     169     1  2.9895  31  85   1
## 944    13   1        0      0       1     7      49     0  1.7918  26  85   1
## 945     8   1        0      1       1    39    1521     0  1.4398  53  85   1
## 946    14   1        0      1       1     6      36     0  1.2528  26  85   1
## 947    12   1        0      0       1    20     400     1  2.4849  38  85   1
## 948    12   0        0      1       1     7      49     0  1.2090  25  85   1
## 949    12   0        0      0       1    20     400     1  2.1972  38  85   1
## 950    14   0        0      1       0     6      36     0  1.3813  26  85   1
## 951    12   0        0      1       1    39    1521     0  1.6094  57  85   1
## 952    16   0        0      0       1    15     225     0  2.5390  37  85   1
## 953    15   0        0      0       1    31     961     0  2.8478  52  85   1
## 954    12   0        0      1       0    25     625     0  2.2513  43  85   1
## 955    11   0        0      0       1    13     169     1  2.6391  30  85   1
## 956    12   0        1      0       1     8      64     1  2.1401  26  85   1
## 957    12   0        0      1       1     2       4     0  1.4469  20  85   1
## 958    16   0        0      0       1    14     196     0  1.7579  36  85   1
## 959    13   0        0      0       1    14     196     0  2.4204  33  85   1
## 960    18   0        0      1       1    18     324     1  2.4849  42  85   1
## 961    12   0        0      1       1    28     784     0  2.4204  46  85   1
## 962    16   0        0      0       1    10     100     1  2.0149  32  85   1
## 963    14   1        1      0       0    17     289     0  2.1041  37  85   1
## 964    12   1        0      1       1    14     196     0  1.5790  32  85   1
## 965    12   1        0      1       1     2       4     0  1.5581  20  85   1
## 966    16   1        0      0       1    29     841     0  1.7047  51  85   1
## 967    11   1        0      0       1    29     841     0  2.2513  46  85   1
## 968    12   1        0      1       1    14     196     0  2.2618  32  85   1
## 969    13   0        0      1       1    33    1089     0  1.5151  52  85   1
## 970    16   0        0      0       1     4      16     0  2.7558  26  85   1
## 971    15   0        0      0       1    13     169     0  2.2885  34  85   1
## 972    14   0        0      1       0    24     576     0  2.3026  44  85   1
## 973    13   0        0      0       0     5      25     0  1.7579  24  85   1
## 974    14   1        0      0       0     1       1     0  2.0186  21  85   1
## 975    11   1        0      0       1    37    1369     1  2.2773  54  85   1
## 976    11   1        0      0       1    18     324     1  2.5649  35  85   1
## 977    15   1        0      1       1    10     100     0  2.3302  31  85   1
## 978    12   1        0      0       1    16     256     1  2.5990  34  85   1
## 979    12   0        0      0       1    12     144     1  2.5313  30  85   1
## 980    14   0        0      1       0     4      16     0  2.1552  24  85   1
## 981    12   0        0      0       1    16     256     1  2.5848  34  85   1
## 982    14   0        1      0       1    34    1156     1  1.9242  54  85   1
## 983    13   0        0      0       1    10     100     1  2.5233  29  85   1
## 984    14   0        0      0       1    17     289     0  1.9661  37  85   1
## 985    13   0        0      1       1    16     256     0  2.5257  35  85   1
## 986    10   0        0      0       1    20     400     0  2.3026  36  85   1
## 987    10   0        0      0       1    12     144     0  2.3026  28  85   1
## 988    12   0        0      0       1    30     900     0  2.1691  48  85   1
## 989    16   0        0      1       1    26     676     0  2.2380  48  85   1
## 990    13   0        0      0       1    13     169     0  2.4079  32  85   1
## 991     8   0        0      1       1    21     441     0  1.6292  35  85   1
## 992    11   0        1      0       0     3       9     0  2.0149  20  85   1
## 993     8   0        1      1       1    29     841     0  1.2238  43  85   1
## 994    12   0        0      1       1     3       9     0  1.5041  21  85   1
## 995    18   0        1      0       1    27     729     0  1.8326  51  85   1
## 996    12   0        0      0       1    33    1089     0  3.0229  51  85   1
## 997    13   0        0      0       0    17     289     0  2.1282  36  85   1
## 998    12   0        0      1       1    15     225     0  2.0794  33  85   1
## 999     9   0        0      0       1    38    1444     0  2.1401  53  85   1
## 1000   12   0        0      0       0     9      81     0  1.3218  27  85   1
## 1001   12   0        0      0       1    10     100     0  2.1972  28  85   1
## 1002   16   0        0      1       0     6      36     0  2.4891  28  85   1
## 1003   12   0        0      1       1     7      49     0  1.5041  25  85   1
## 1004    9   0        1      0       0    16     256     0  1.5686  31  85   1
## 1005   10   0        0      0       1    30     900     0  1.8718  46  85   1
## 1006   12   0        0      0       1    19     361     0  2.0398  37  85   1
## 1007   12   0        0      1       0    15     225     0  2.2336  33  85   1
## 1008   12   0        1      0       1    12     144     0  1.6094  30  85   1
## 1009   12   0        1      1       1    33    1089     0  1.8083  51  85   1
## 1010   12   0        1      0       0    36    1296     0  2.3674  54  85   1
## 1011   12   0        1      1       0    25     625     0  1.2528  43  85   1
## 1012   12   0        1      0       1    35    1225     1  2.3026  53  85   1
## 1013   13   0        1      0       0     8      64     1  2.1972  27  85   1
## 1014   12   1        1      1       1    23     529     0  2.0149  41  85   1
## 1015   18   1        0      0       0     7      49     0  1.7430  31  85   1
## 1016   17   1        0      0       0     3       9     0  2.1401  26  85   1
## 1017   12   1        1      0       1     8      64     0  1.3863  26  85   1
## 1018    9   1        1      1       1    34    1156     1  1.7492  49  85   1
## 1019   12   0        0      0       0     2       4     0  1.6582  20  85   1
## 1020   12   0        0      0       1    34    1156     0  1.2528  52  85   1
## 1021   11   0        0      0       0     2       4     0  1.5041  19  85   1
## 1022   12   0        0      1       0    11     121     0  1.7047  29  85   1
## 1023   13   0        0      1       1     4      16     0  1.8326  23  85   1
## 1024   16   0        0      1       1    22     484     1  2.1848  44  85   1
## 1025   12   0        0      1       1    45    2025     0  1.6582  63  85   1
## 1026   14   0        0      1       1    26     676     0  2.3273  46  85   1
## 1027   14   0        0      1       1    12     144     0  1.8326  32  85   1
## 1028   12   0        0      1       1     3       9     0  1.4702  21  85   1
## 1029   13   0        0      0       0    36    1296     0  2.8824  55  85   1
## 1030   12   0        0      1       1     9      81     1  2.0149  27  85   1
## 1031   16   0        0      1       1     7      49     0  1.8326  29  85   1
## 1032   14   0        0      0       1    14     196     0  1.5041  34  85   1
## 1033   12   0        0      1       0     6      36     0  1.8563  24  85   1
## 1034   15   0        0      0       1     1       1     1  1.5766  22  85   1
## 1035   11   0        0      0       1     4      16     0  1.4231  21  85   1
## 1036   12   0        0      1       1     5      25     0  1.6351  23  85   1
## 1037    8   0        0      1       1    38    1444     0  1.6601  52  85   1
## 1038   16   0        0      1       1     6      36     0  2.0513  28  85   1
## 1039   13   0        0      0       0     9      81     1  2.5703  28  85   1
## 1040   13   0        0      1       1    15     225     0  2.0794  34  85   1
## 1041   15   0        0      1       1    11     121     0  2.0369  32  85   1
## 1042   12   0        0      0       0    17     289     0  2.0149  35  85   1
## 1043   12   0        0      0       0     1       1     0  1.0473  19  85   1
## 1044   12   0        0      0       1     9      81     0  1.8506  27  85   1
## 1045    9   0        0      0       0    48    2304     0  1.2528  63  85   1
## 1046   12   0        0      0       1    17     289     1  2.4292  35  85   1
## 1047   12   0        0      1       1    33    1089     0  1.7047  51  85   1
## 1048   12   0        0      0       1     7      49     0  2.2138  25  85   1
## 1049   14   0        0      1       1    12     144     0  2.0744  32  85   1
## 1050   16   0        0      1       1     6      36     0  1.7317  28  85   1
## 1051    4   0        0      0       1    54    2916     0  1.7918  64  85   1
## 1052   16   1        1      0       0    16     256     0  2.5990  38  85   1
## 1053   11   1        0      1       1     8      64     0  1.2947  25  85   1
## 1054    9   1        0      0       0    30     900     1  1.8326  45  85   1
## 1055   13   1        0      0       0     1       1     1  1.6390  20  85   1
## 1056   17   1        0      0       1    32    1024     0  3.2692  55  85   1
## 1057   13   1        0      0       0     0       0     0  0.6981  19  85   1
## 1058   12   1        0      1       0    26     676     0  1.6094  44  85   1
## 1059   11   0        0      1       0    36    1296     0  2.1691  53  85   1
## 1060   14   0        0      1       1    19     361     0  2.5257  39  85   1
## 1061   12   0        0      0       0    12     144     0  1.3863  30  85   1
## 1062   16   0        0      0       1    21     441     0  1.5041  43  85   1
## 1063   12   0        0      1       0    11     121     0  1.8718  29  85   1
## 1064   12   0        0      0       1    10     100     0  1.7047  28  85   1
## 1065   17   0        0      1       1    15     225     0  1.9279  38  85   1
## 1066   16   0        0      1       0    16     256     0  1.8165  38  85   1
## 1067   12   0        0      0       1    23     529     0  2.0513  41  85   1
## 1068   12   0        0      0       1    24     576     0  0.0000  42  85   1
## 1069   17   0        0      1       1    13     169     1  2.5257  36  85   1
## 1070   14   0        1      1       1    19     361     1  2.1804  39  85   1
## 1071   11   0        0      1       1    20     400     0  1.4702  37  85   1
## 1072   18   0        0      0       0     5      25     0  2.4304  29  85   1
## 1073    8   0        0      0       1    47    2209     1  2.1894  61  85   1
## 1074   11   0        0      1       1    33    1089     0  1.2528  50  85   1
## 1075   14   0        0      0       1    21     441     1  3.2581  41  85   1
## 1076   12   0        0      1       1    19     361     0  2.0794  37  85   1
## 1077   14   0        0      0       1    20     400     1  2.7726  40  85   1
## 1078   12   0        0      1       1    13     169     0  1.6771  31  85   1
## 1079   17   0        1      1       1    25     625     1  3.1463  48  85   1
## 1080   12   0        1      1       1    18     324     0  2.1552  36  85   1
## 1081   14   0        0      1       0    13     169     0  2.9178  33  85   1
## 1082   18   0        0      0       1     8      64     0  3.1001  32  85   1
## 1083   12   0        1      0       0    14     196     1  2.7887  32  85   1
## 1084   12   0        0      0       0     9      81     0  2.9689  27  85   1
##      y85fem y85educ y85union
## 1         0       0        0
## 2         0       0        0
## 3         0       0        0
## 4         0       0        0
## 5         0       0        0
## 6         0       0        0
## 7         0       0        0
## 8         0       0        0
## 9         0       0        0
## 10        0       0        0
## 11        0       0        0
## 12        0       0        0
## 13        0       0        0
## 14        0       0        0
## 15        0       0        0
## 16        0       0        0
## 17        0       0        0
## 18        0       0        0
## 19        0       0        0
## 20        0       0        0
## 21        0       0        0
## 22        0       0        0
## 23        0       0        0
## 24        0       0        0
## 25        0       0        0
## 26        0       0        0
## 27        0       0        0
## 28        0       0        0
## 29        0       0        0
## 30        0       0        0
## 31        0       0        0
## 32        0       0        0
## 33        0       0        0
## 34        0       0        0
## 35        0       0        0
## 36        0       0        0
## 37        0       0        0
## 38        0       0        0
## 39        0       0        0
## 40        0       0        0
## 41        0       0        0
## 42        0       0        0
## 43        0       0        0
## 44        0       0        0
## 45        0       0        0
## 46        0       0        0
## 47        0       0        0
## 48        0       0        0
## 49        0       0        0
## 50        0       0        0
## 51        0       0        0
## 52        0       0        0
## 53        0       0        0
## 54        0       0        0
## 55        0       0        0
## 56        0       0        0
## 57        0       0        0
## 58        0       0        0
## 59        0       0        0
## 60        0       0        0
## 61        0       0        0
## 62        0       0        0
## 63        0       0        0
## 64        0       0        0
## 65        0       0        0
## 66        0       0        0
## 67        0       0        0
## 68        0       0        0
## 69        0       0        0
## 70        0       0        0
## 71        0       0        0
## 72        0       0        0
## 73        0       0        0
## 74        0       0        0
## 75        0       0        0
## 76        0       0        0
## 77        0       0        0
## 78        0       0        0
## 79        0       0        0
## 80        0       0        0
## 81        0       0        0
## 82        0       0        0
## 83        0       0        0
## 84        0       0        0
## 85        0       0        0
## 86        0       0        0
## 87        0       0        0
## 88        0       0        0
## 89        0       0        0
## 90        0       0        0
## 91        0       0        0
## 92        0       0        0
## 93        0       0        0
## 94        0       0        0
## 95        0       0        0
## 96        0       0        0
## 97        0       0        0
## 98        0       0        0
## 99        0       0        0
## 100       0       0        0
## 101       0       0        0
## 102       0       0        0
## 103       0       0        0
## 104       0       0        0
## 105       0       0        0
## 106       0       0        0
## 107       0       0        0
## 108       0       0        0
## 109       0       0        0
## 110       0       0        0
## 111       0       0        0
## 112       0       0        0
## 113       0       0        0
## 114       0       0        0
## 115       0       0        0
## 116       0       0        0
## 117       0       0        0
## 118       0       0        0
## 119       0       0        0
## 120       0       0        0
## 121       0       0        0
## 122       0       0        0
## 123       0       0        0
## 124       0       0        0
## 125       0       0        0
## 126       0       0        0
## 127       0       0        0
## 128       0       0        0
## 129       0       0        0
## 130       0       0        0
## 131       0       0        0
## 132       0       0        0
## 133       0       0        0
## 134       0       0        0
## 135       0       0        0
## 136       0       0        0
## 137       0       0        0
## 138       0       0        0
## 139       0       0        0
## 140       0       0        0
## 141       0       0        0
## 142       0       0        0
## 143       0       0        0
## 144       0       0        0
## 145       0       0        0
## 146       0       0        0
## 147       0       0        0
## 148       0       0        0
## 149       0       0        0
## 150       0       0        0
## 151       0       0        0
## 152       0       0        0
## 153       0       0        0
## 154       0       0        0
## 155       0       0        0
## 156       0       0        0
## 157       0       0        0
## 158       0       0        0
## 159       0       0        0
## 160       0       0        0
## 161       0       0        0
## 162       0       0        0
## 163       0       0        0
## 164       0       0        0
## 165       0       0        0
## 166       0       0        0
## 167       0       0        0
## 168       0       0        0
## 169       0       0        0
## 170       0       0        0
## 171       0       0        0
## 172       0       0        0
## 173       0       0        0
## 174       0       0        0
## 175       0       0        0
## 176       0       0        0
## 177       0       0        0
## 178       0       0        0
## 179       0       0        0
## 180       0       0        0
## 181       0       0        0
## 182       0       0        0
## 183       0       0        0
## 184       0       0        0
## 185       0       0        0
## 186       0       0        0
## 187       0       0        0
## 188       0       0        0
## 189       0       0        0
## 190       0       0        0
## 191       0       0        0
## 192       0       0        0
## 193       0       0        0
## 194       0       0        0
## 195       0       0        0
## 196       0       0        0
## 197       0       0        0
## 198       0       0        0
## 199       0       0        0
## 200       0       0        0
## 201       0       0        0
## 202       0       0        0
## 203       0       0        0
## 204       0       0        0
## 205       0       0        0
## 206       0       0        0
## 207       0       0        0
## 208       0       0        0
## 209       0       0        0
## 210       0       0        0
## 211       0       0        0
## 212       0       0        0
## 213       0       0        0
## 214       0       0        0
## 215       0       0        0
## 216       0       0        0
## 217       0       0        0
## 218       0       0        0
## 219       0       0        0
## 220       0       0        0
## 221       0       0        0
## 222       0       0        0
## 223       0       0        0
## 224       0       0        0
## 225       0       0        0
## 226       0       0        0
## 227       0       0        0
## 228       0       0        0
## 229       0       0        0
## 230       0       0        0
## 231       0       0        0
## 232       0       0        0
## 233       0       0        0
## 234       0       0        0
## 235       0       0        0
## 236       0       0        0
## 237       0       0        0
## 238       0       0        0
## 239       0       0        0
## 240       0       0        0
## 241       0       0        0
## 242       0       0        0
## 243       0       0        0
## 244       0       0        0
## 245       0       0        0
## 246       0       0        0
## 247       0       0        0
## 248       0       0        0
## 249       0       0        0
## 250       0       0        0
## 251       0       0        0
## 252       0       0        0
## 253       0       0        0
## 254       0       0        0
## 255       0       0        0
## 256       0       0        0
## 257       0       0        0
## 258       0       0        0
## 259       0       0        0
## 260       0       0        0
## 261       0       0        0
## 262       0       0        0
## 263       0       0        0
## 264       0       0        0
## 265       0       0        0
## 266       0       0        0
## 267       0       0        0
## 268       0       0        0
## 269       0       0        0
## 270       0       0        0
## 271       0       0        0
## 272       0       0        0
## 273       0       0        0
## 274       0       0        0
## 275       0       0        0
## 276       0       0        0
## 277       0       0        0
## 278       0       0        0
## 279       0       0        0
## 280       0       0        0
## 281       0       0        0
## 282       0       0        0
## 283       0       0        0
## 284       0       0        0
## 285       0       0        0
## 286       0       0        0
## 287       0       0        0
## 288       0       0        0
## 289       0       0        0
## 290       0       0        0
## 291       0       0        0
## 292       0       0        0
## 293       0       0        0
## 294       0       0        0
## 295       0       0        0
## 296       0       0        0
## 297       0       0        0
## 298       0       0        0
## 299       0       0        0
## 300       0       0        0
## 301       0       0        0
## 302       0       0        0
## 303       0       0        0
## 304       0       0        0
## 305       0       0        0
## 306       0       0        0
## 307       0       0        0
## 308       0       0        0
## 309       0       0        0
## 310       0       0        0
## 311       0       0        0
## 312       0       0        0
## 313       0       0        0
## 314       0       0        0
## 315       0       0        0
## 316       0       0        0
## 317       0       0        0
## 318       0       0        0
## 319       0       0        0
## 320       0       0        0
## 321       0       0        0
## 322       0       0        0
## 323       0       0        0
## 324       0       0        0
## 325       0       0        0
## 326       0       0        0
## 327       0       0        0
## 328       0       0        0
## 329       0       0        0
## 330       0       0        0
## 331       0       0        0
## 332       0       0        0
## 333       0       0        0
## 334       0       0        0
## 335       0       0        0
## 336       0       0        0
## 337       0       0        0
## 338       0       0        0
## 339       0       0        0
## 340       0       0        0
## 341       0       0        0
## 342       0       0        0
## 343       0       0        0
## 344       0       0        0
## 345       0       0        0
## 346       0       0        0
## 347       0       0        0
## 348       0       0        0
## 349       0       0        0
## 350       0       0        0
## 351       0       0        0
## 352       0       0        0
## 353       0       0        0
## 354       0       0        0
## 355       0       0        0
## 356       0       0        0
## 357       0       0        0
## 358       0       0        0
## 359       0       0        0
## 360       0       0        0
## 361       0       0        0
## 362       0       0        0
## 363       0       0        0
## 364       0       0        0
## 365       0       0        0
## 366       0       0        0
## 367       0       0        0
## 368       0       0        0
## 369       0       0        0
## 370       0       0        0
## 371       0       0        0
## 372       0       0        0
## 373       0       0        0
## 374       0       0        0
## 375       0       0        0
## 376       0       0        0
## 377       0       0        0
## 378       0       0        0
## 379       0       0        0
## 380       0       0        0
## 381       0       0        0
## 382       0       0        0
## 383       0       0        0
## 384       0       0        0
## 385       0       0        0
## 386       0       0        0
## 387       0       0        0
## 388       0       0        0
## 389       0       0        0
## 390       0       0        0
## 391       0       0        0
## 392       0       0        0
## 393       0       0        0
## 394       0       0        0
## 395       0       0        0
## 396       0       0        0
## 397       0       0        0
## 398       0       0        0
## 399       0       0        0
## 400       0       0        0
## 401       0       0        0
## 402       0       0        0
## 403       0       0        0
## 404       0       0        0
## 405       0       0        0
## 406       0       0        0
## 407       0       0        0
## 408       0       0        0
## 409       0       0        0
## 410       0       0        0
## 411       0       0        0
## 412       0       0        0
## 413       0       0        0
## 414       0       0        0
## 415       0       0        0
## 416       0       0        0
## 417       0       0        0
## 418       0       0        0
## 419       0       0        0
## 420       0       0        0
## 421       0       0        0
## 422       0       0        0
## 423       0       0        0
## 424       0       0        0
## 425       0       0        0
## 426       0       0        0
## 427       0       0        0
## 428       0       0        0
## 429       0       0        0
## 430       0       0        0
## 431       0       0        0
## 432       0       0        0
## 433       0       0        0
## 434       0       0        0
## 435       0       0        0
## 436       0       0        0
## 437       0       0        0
## 438       0       0        0
## 439       0       0        0
## 440       0       0        0
## 441       0       0        0
## 442       0       0        0
## 443       0       0        0
## 444       0       0        0
## 445       0       0        0
## 446       0       0        0
## 447       0       0        0
## 448       0       0        0
## 449       0       0        0
## 450       0       0        0
## 451       0       0        0
## 452       0       0        0
## 453       0       0        0
## 454       0       0        0
## 455       0       0        0
## 456       0       0        0
## 457       0       0        0
## 458       0       0        0
## 459       0       0        0
## 460       0       0        0
## 461       0       0        0
## 462       0       0        0
## 463       0       0        0
## 464       0       0        0
## 465       0       0        0
## 466       0       0        0
## 467       0       0        0
## 468       0       0        0
## 469       0       0        0
## 470       0       0        0
## 471       0       0        0
## 472       0       0        0
## 473       0       0        0
## 474       0       0        0
## 475       0       0        0
## 476       0       0        0
## 477       0       0        0
## 478       0       0        0
## 479       0       0        0
## 480       0       0        0
## 481       0       0        0
## 482       0       0        0
## 483       0       0        0
## 484       0       0        0
## 485       0       0        0
## 486       0       0        0
## 487       0       0        0
## 488       0       0        0
## 489       0       0        0
## 490       0       0        0
## 491       0       0        0
## 492       0       0        0
## 493       0       0        0
## 494       0       0        0
## 495       0       0        0
## 496       0       0        0
## 497       0       0        0
## 498       0       0        0
## 499       0       0        0
## 500       0       0        0
## 501       0       0        0
## 502       0       0        0
## 503       0       0        0
## 504       0       0        0
## 505       0       0        0
## 506       0       0        0
## 507       0       0        0
## 508       0       0        0
## 509       0       0        0
## 510       0       0        0
## 511       0       0        0
## 512       0       0        0
## 513       0       0        0
## 514       0       0        0
## 515       0       0        0
## 516       0       0        0
## 517       0       0        0
## 518       0       0        0
## 519       0       0        0
## 520       0       0        0
## 521       0       0        0
## 522       0       0        0
## 523       0       0        0
## 524       0       0        0
## 525       0       0        0
## 526       0       0        0
## 527       0       0        0
## 528       0       0        0
## 529       0       0        0
## 530       0       0        0
## 531       0       0        0
## 532       0       0        0
## 533       0       0        0
## 534       0       0        0
## 535       0       0        0
## 536       0       0        0
## 537       0       0        0
## 538       0       0        0
## 539       0       0        0
## 540       0       0        0
## 541       0       0        0
## 542       0       0        0
## 543       0       0        0
## 544       0       0        0
## 545       0       0        0
## 546       0       0        0
## 547       0       0        0
## 548       0       0        0
## 549       0       0        0
## 550       0       0        0
## 551       0      10        0
## 552       0      12        0
## 553       1      12        0
## 554       1      12        0
## 555       0      12        1
## 556       1      16        0
## 557       1      12        1
## 558       0      14        0
## 559       0       8        0
## 560       1      12        0
## 561       0      17        0
## 562       0      17        0
## 563       0      14        1
## 564       0      14        0
## 565       0      12        0
## 566       0      14        0
## 567       0      16        1
## 568       0      16        1
## 569       0      13        0
## 570       0      13        0
## 571       1      17        0
## 572       0      12        1
## 573       1      14        1
## 574       1      12        0
## 575       0      16        0
## 576       1      12        0
## 577       1      17        0
## 578       0      14        0
## 579       0      14        0
## 580       1      13        0
## 581       0      14        0
## 582       0      16        0
## 583       0      12        0
## 584       0      18        0
## 585       0      16        0
## 586       1      17        0
## 587       1      16        0
## 588       0      12        0
## 589       1      15        0
## 590       0      16        0
## 591       1      16        0
## 592       0      16        0
## 593       1      13        1
## 594       0      12        0
## 595       0      14        0
## 596       0      12        0
## 597       0       8        1
## 598       0      12        0
## 599       1      12        0
## 600       1      14        0
## 601       0       9        1
## 602       0      16        0
## 603       1      12        0
## 604       1      12        0
## 605       0       9        1
## 606       1       8        0
## 607       1      18        0
## 608       0      14        0
## 609       1      12        0
## 610       1      12        0
## 611       1      12        0
## 612       1       8        0
## 613       0      12        1
## 614       1      12        0
## 615       0      16        0
## 616       1      12        0
## 617       0      12        0
## 618       0      13        1
## 619       1      16        0
## 620       1      12        0
## 621       0      12        1
## 622       1      10        1
## 623       0      13        0
## 624       0      18        1
## 625       0      12        0
## 626       1      14        0
## 627       1      15        0
## 628       1      12        0
## 629       1       8        0
## 630       1      14        0
## 631       0      12        1
## 632       1      16        0
## 633       1      10        1
## 634       1      12        0
## 635       1      12        0
## 636       0      12        0
## 637       0      12        0
## 638       0      17        1
## 639       1      12        0
## 640       1       9        0
## 641       1      16        0
## 642       0      12        0
## 643       0      12        0
## 644       1      12        0
## 645       0      14        0
## 646       0      12        1
## 647       1      14        0
## 648       0      15        0
## 649       1      16        0
## 650       1      12        0
## 651       0      12        0
## 652       1      12        0
## 653       0      12        0
## 654       1      12        0
## 655       1      12        0
## 656       1      12        0
## 657       1      12        0
## 658       0      12        0
## 659       0      12        0
## 660       1       7        0
## 661       0      12        0
## 662       1      12        0
## 663       1      12        0
## 664       0      16        0
## 665       1      13        0
## 666       0      16        0
## 667       0      14        0
## 668       1      12        0
## 669       0       7        0
## 670       1      13        0
## 671       0      14        0
## 672       0      17        0
## 673       0      16        0
## 674       1      13        0
## 675       0      14        0
## 676       1      16        1
## 677       0      14        1
## 678       0      11        1
## 679       1      12        0
## 680       1      18        0
## 681       1      17        0
## 682       1      16        1
## 683       1      16        0
## 684       1      11        0
## 685       1      11        0
## 686       1      12        0
## 687       1      15        0
## 688       0       2        0
## 689       1      14        0
## 690       1      14        0
## 691       0      14        0
## 692       0      11        0
## 693       1      16        0
## 694       1      12        0
## 695       0      16        0
## 696       0      12        0
## 697       0      12        0
## 698       1      17        1
## 699       1      12        0
## 700       0       8        0
## 701       1      16        0
## 702       0      18        0
## 703       0      18        0
## 704       0      18        0
## 705       0      12        0
## 706       0      12        0
## 707       1      12        0
## 708       0      12        1
## 709       0      12        0
## 710       0      11        0
## 711       0      12        0
## 712       0      18        0
## 713       0      14        0
## 714       0      16        0
## 715       0      16        0
## 716       0      18        0
## 717       1      12        0
## 718       1      11        0
## 719       1      14        0
## 720       0      12        0
## 721       0      12        0
## 722       1      12        1
## 723       1      12        0
## 724       1      18        0
## 725       1      12        0
## 726       0      18        0
## 727       1      12        0
## 728       1      12        0
## 729       1      12        0
## 730       0      12        0
## 731       0      10        0
## 732       0      12        0
## 733       0      16        0
## 734       1      13        0
## 735       1      12        1
## 736       0      14        0
## 737       1      17        0
## 738       1      18        1
## 739       0      14        0
## 740       0      14        0
## 741       0      12        1
## 742       1       9        1
## 743       1       6        1
## 744       1      14        0
## 745       1      12        0
## 746       1      12        0
## 747       1      12        0
## 748       1      12        0
## 749       0      12        0
## 750       1      11        1
## 751       0      16        0
## 752       0      17        0
## 753       1      12        0
## 754       1      14        0
## 755       0      12        1
## 756       0      16        1
## 757       1      16        0
## 758       1      10        0
## 759       1      13        0
## 760       1      16        0
## 761       1      16        1
## 762       1      12        0
## 763       0      16        0
## 764       1      13        0
## 765       1      12        0
## 766       1      12        0
## 767       1      18        0
## 768       0      10        0
## 769       0      12        0
## 770       1      12        0
## 771       0      13        0
## 772       0      12        0
## 773       0       3        0
## 774       1      17        0
## 775       1       6        0
## 776       1      12        0
## 777       0      18        0
## 778       0      18        0
## 779       0      16        0
## 780       0      16        0
## 781       0      18        0
## 782       0      18        1
## 783       0      13        0
## 784       0      18        0
## 785       1      16        0
## 786       0      12        0
## 787       0      16        0
## 788       1      12        0
## 789       1      12        0
## 790       0      12        0
## 791       0      18        0
## 792       0      12        0
## 793       0      15        0
## 794       1      12        0
## 795       1      12        1
## 796       1      17        1
## 797       1      12        0
## 798       0      12        0
## 799       1      14        0
## 800       1      13        0
## 801       0      12        0
## 802       1      12        0
## 803       1      12        0
## 804       1      17        1
## 805       0      15        0
## 806       1      16        0
## 807       0      12        0
## 808       0      18        0
## 809       1      18        0
## 810       0      12        0
## 811       1       9        0
## 812       1      12        0
## 813       0      16        1
## 814       0      10        0
## 815       0      12        0
## 816       1      15        0
## 817       1      13        0
## 818       0      14        1
## 819       1      12        0
## 820       0      12        0
## 821       0      12        0
## 822       0       9        0
## 823       1      14        0
## 824       1      12        1
## 825       1      12        0
## 826       1       9        0
## 827       1      12        0
## 828       1      12        0
## 829       1      12        0
## 830       1      12        0
## 831       0      13        0
## 832       0      12        1
## 833       0      10        0
## 834       0      14        0
## 835       1      12        0
## 836       0      12        0
## 837       0      12        0
## 838       0      12        1
## 839       0      11        0
## 840       0      10        0
## 841       1      12        0
## 842       1      10        0
## 843       0      10        0
## 844       0       6        0
## 845       0       8        0
## 846       0      12        0
## 847       0      16        1
## 848       0      12        0
## 849       1      11        0
## 850       0      14        0
## 851       1      17        0
## 852       0      14        0
## 853       0      11        0
## 854       1      12        0
## 855       0      12        1
## 856       0      12        1
## 857       0       7        1
## 858       0       7        0
## 859       0      12        0
## 860       1      16        0
## 861       1      13        0
## 862       1      13        0
## 863       0      14        0
## 864       1      16        0
## 865       1      11        1
## 866       1      12        0
## 867       1      14        0
## 868       0      18        0
## 869       1      12        0
## 870       0      17        0
## 871       0      11        1
## 872       0      10        1
## 873       1      16        0
## 874       0      15        0
## 875       0      12        0
## 876       0      12        1
## 877       1      12        0
## 878       0      18        1
## 879       1      16        0
## 880       1      16        0
## 881       0      16        1
## 882       0      12        1
## 883       0      12        1
## 884       0      12        0
## 885       1      12        0
## 886       0      10        1
## 887       1      17        0
## 888       0      12        0
## 889       1       8        0
## 890       0      12        1
## 891       0       5        0
## 892       1      10        0
## 893       0      13        0
## 894       0      18        0
## 895       0      12        0
## 896       0      16        1
## 897       0      13        0
## 898       0      16        0
## 899       0      12        0
## 900       1      16        0
## 901       1      16        0
## 902       1      16        0
## 903       1      12        0
## 904       0      11        0
## 905       0      12        0
## 906       1       8        0
## 907       0      12        0
## 908       0      16        0
## 909       0      12        0
## 910       1      16        0
## 911       1      12        0
## 912       1      12        0
## 913       1      12        0
## 914       0      16        0
## 915       0      14        0
## 916       0      11        1
## 917       0      16        0
## 918       1      18        0
## 919       1      18        0
## 920       0      13        0
## 921       0      12        0
## 922       0      11        0
## 923       1      12        0
## 924       1      12        0
## 925       1      12        0
## 926       0      12        0
## 927       0       7        0
## 928       0       8        0
## 929       0      12        0
## 930       0      12        1
## 931       1      16        0
## 932       0      12        0
## 933       1      11        0
## 934       0      14        1
## 935       0      12        0
## 936       0      12        0
## 937       0      12        0
## 938       0      12        1
## 939       1      12        1
## 940       0      17        0
## 941       0      17        0
## 942       1      12        0
## 943       0      12        1
## 944       0      13        0
## 945       1       8        0
## 946       1      14        0
## 947       0      12        1
## 948       1      12        0
## 949       0      12        1
## 950       1      14        0
## 951       1      12        0
## 952       0      16        0
## 953       0      15        0
## 954       1      12        0
## 955       0      11        1
## 956       0      12        1
## 957       1      12        0
## 958       0      16        0
## 959       0      13        0
## 960       1      18        1
## 961       1      12        0
## 962       0      16        1
## 963       0      14        0
## 964       1      12        0
## 965       1      12        0
## 966       0      16        0
## 967       0      11        0
## 968       1      12        0
## 969       1      13        0
## 970       0      16        0
## 971       0      15        0
## 972       1      14        0
## 973       0      13        0
## 974       0      14        0
## 975       0      11        1
## 976       0      11        1
## 977       1      15        0
## 978       0      12        1
## 979       0      12        1
## 980       1      14        0
## 981       0      12        1
## 982       0      14        1
## 983       0      13        1
## 984       0      14        0
## 985       1      13        0
## 986       0      10        0
## 987       0      10        0
## 988       0      12        0
## 989       1      16        0
## 990       0      13        0
## 991       1       8        0
## 992       0      11        0
## 993       1       8        0
## 994       1      12        0
## 995       0      18        0
## 996       0      12        0
## 997       0      13        0
## 998       1      12        0
## 999       0       9        0
## 1000      0      12        0
## 1001      0      12        0
## 1002      1      16        0
## 1003      1      12        0
## 1004      0       9        0
## 1005      0      10        0
## 1006      0      12        0
## 1007      1      12        0
## 1008      0      12        0
## 1009      1      12        0
## 1010      0      12        0
## 1011      1      12        0
## 1012      0      12        1
## 1013      0      13        1
## 1014      1      12        0
## 1015      0      18        0
## 1016      0      17        0
## 1017      0      12        0
## 1018      1       9        1
## 1019      0      12        0
## 1020      0      12        0
## 1021      0      11        0
## 1022      1      12        0
## 1023      1      13        0
## 1024      1      16        1
## 1025      1      12        0
## 1026      1      14        0
## 1027      1      14        0
## 1028      1      12        0
## 1029      0      13        0
## 1030      1      12        1
## 1031      1      16        0
## 1032      0      14        0
## 1033      1      12        0
## 1034      0      15        1
## 1035      0      11        0
## 1036      1      12        0
## 1037      1       8        0
## 1038      1      16        0
## 1039      0      13        1
## 1040      1      13        0
## 1041      1      15        0
## 1042      0      12        0
## 1043      0      12        0
## 1044      0      12        0
## 1045      0       9        0
## 1046      0      12        1
## 1047      1      12        0
## 1048      0      12        0
## 1049      1      14        0
## 1050      1      16        0
## 1051      0       4        0
## 1052      0      16        0
## 1053      1      11        0
## 1054      0       9        1
## 1055      0      13        1
## 1056      0      17        0
## 1057      0      13        0
## 1058      1      12        0
## 1059      1      11        0
## 1060      1      14        0
## 1061      0      12        0
## 1062      0      16        0
## 1063      1      12        0
## 1064      0      12        0
## 1065      1      17        0
## 1066      1      16        0
## 1067      0      12        0
## 1068      0      12        0
## 1069      1      17        1
## 1070      1      14        1
## 1071      1      11        0
## 1072      0      18        0
## 1073      0       8        1
## 1074      1      11        0
## 1075      0      14        1
## 1076      1      12        0
## 1077      0      14        1
## 1078      1      12        0
## 1079      1      17        1
## 1080      1      12        0
## 1081      1      14        0
## 1082      0      18        0
## 1083      0      12        1
## 1084      0      12        0

Summarise

summarise(): calcular diversas estadisticas

summarize(nombre_data_frame,formula_1, formula_2,…,formula_n)

n() - Num. de observaciones
n_distinct(x) - Num. de obs. unicas/distintas mean() - Promedio
median() - Mediana
sum() - Suma
sd() - Desv. Estandar IQR() - Rango Intercuartil mad() - Desviacion media absoluta:
min() - Minimo max() - Maximo quantile(x, 0.25) - Cuantil first() - Primero last() - Ultimo sum([condicion logica]) - Suma de casos que cumplen condicion mean([condicion logica]) - Promedio de casos que cumplen condicion

Lo utilizamos para hacer algunos calculos:

is.numeric(cps78_85$age)
## [1] TRUE
summarise(cps78_85, min(age), max(age), mean(age), sd(age))
##   min(age) max(age) mean(age)  sd(age)
## 1       18       64  36.53967 12.20392

Podemos calcular estadistica descriptivas por grupos utilizando el group by():

Sin group By:

summarise(cps78_85,
          prom_edad = mean(age, na.rm = TRUE),  # Promedio
          min_edad = min(age, na.rm = TRUE),    # Minimo
          max_edad = max(age, na.rm = TRUE),    # Maximo
          desv_edad = sd(age, na.rm = TRUE))    # Desviacion estandar
##   prom_edad min_edad max_edad desv_edad
## 1  36.53967       18       64  12.20392

Con Group By:

# Agrupar los datos y guardarlos en un nuevo data frame
sexo <- group_by(cps78_85, female)

summarise(sexo,       
          prom_edad = mean(age, na.rm = TRUE),  # Promedio
          min_edad = min(age, na.rm = TRUE),    # Minimo
          max_edad = max(age, na.rm = TRUE),    # Maximo
          desv_edad = sd(age, na.rm = TRUE))    # Desviacion estandar
## # A tibble: 2 x 5
##   female prom_edad min_edad max_edad desv_edad
##    <int>     <dbl>    <int>    <int>     <dbl>
## 1      0      36.7       18       64      12.2
## 2      1      36.3       18       64      12.2

Ahora utilizamos otra base para hacer unos calculos:

library(foreign)
hogar <- as_tibble(as.data.frame(read.dta("concentradohogar.dta")))
ingreso <- as_tibble(as.data.frame(read.dta("ingresos.dta")))
vivienda <- as_tibble(as.data.frame(read.dta("viviendas.dta")))

Analizamos la base:

View(hogar)
View(vivienda)
head(hogar)
## # A tibble: 6 x 126
##   folioviv   foliohog ubica_geo tam_loc est_socio est_dis upm     factor clase_hog
##   <chr>      <chr>    <chr>     <chr>   <chr>     <chr>   <chr>    <dbl> <chr>    
## 1 0100013601 1        01001     1       3         002     0000001    175 2        
## 2 0100013602 1        01001     1       3         002     0000001    175 2        
## 3 0100013603 1        01001     1       3         002     0000001    175 2        
## 4 0100013604 1        01001     1       3         002     0000001    175 2        
## 5 0100013606 1        01001     1       3         002     0000001    175 2        
## 6 0100026701 1        01001     1       3         002     0000002    189 2        
## # ... with 117 more variables: sexo_jefe <chr>, edad_jefe <dbl>,
## #   educa_jefe <chr>, tot_integ <dbl>, hombres <dbl>, mujeres <dbl>,
## #   mayores <dbl>, menores <dbl>, p12_64 <dbl>, p65mas <dbl>, ocupados <dbl>,
## #   percep_ing <dbl>, perc_ocupa <dbl>, ing_cor <dbl>, ingtrab <dbl>,
## #   trabajo <dbl>, sueldos <dbl>, horas_extr <dbl>, comisiones <dbl>,
## #   aguinaldo <dbl>, indemtrab <dbl>, otra_rem <dbl>, remu_espec <dbl>,
## #   negocio <dbl>, noagrop <dbl>, industria <dbl>, comercio <dbl>, ...
tail(hogar)
## # A tibble: 6 x 126
##   folioviv   foliohog ubica_geo tam_loc est_socio est_dis upm     factor clase_hog
##   <chr>      <chr>    <chr>     <chr>   <chr>     <chr>   <chr>    <dbl> <chr>    
## 1 3260798901 1        32046     4       2         543     0008395    192 2        
## 2 3260798902 1        32046     4       2         543     0008395    192 2        
## 3 3260798903 1        32046     4       2         543     0008395    192 2        
## 4 3260798904 1        32046     4       2         543     0008395    192 3        
## 5 3260798905 1        32046     4       2         543     0008395    192 1        
## 6 3260798906 1        32046     4       2         543     0008395    192 2        
## # ... with 117 more variables: sexo_jefe <chr>, edad_jefe <dbl>,
## #   educa_jefe <chr>, tot_integ <dbl>, hombres <dbl>, mujeres <dbl>,
## #   mayores <dbl>, menores <dbl>, p12_64 <dbl>, p65mas <dbl>, ocupados <dbl>,
## #   percep_ing <dbl>, perc_ocupa <dbl>, ing_cor <dbl>, ingtrab <dbl>,
## #   trabajo <dbl>, sueldos <dbl>, horas_extr <dbl>, comisiones <dbl>,
## #   aguinaldo <dbl>, indemtrab <dbl>, otra_rem <dbl>, remu_espec <dbl>,
## #   negocio <dbl>, noagrop <dbl>, industria <dbl>, comercio <dbl>, ...

Ejercicio 1

Calculamos el numero total de viviendas en México

Solución

vivienda %>%
  mutate(obs = 1,
         num = obs*factor) 
## # A tibble: 73,405 x 66
##    folioviv tipo_viv mat_pared mat_techos mat_pisos antiguedad antigua_ne cocina
##    <chr>    <chr>    <chr>     <chr>      <chr>          <dbl> <chr>      <chr> 
##  1 0100013~ 1        8         10         3                 42 " "        1     
##  2 0100013~ 1        8         10         3                 40 " "        1     
##  3 0100013~ 1        8         10         3                 50 " "        1     
##  4 0100013~ 1        8         10         3                 45 " "        1     
##  5 0100013~ 1        8         10         3                 40 " "        1     
##  6 0100026~ 1        8         10         3                  5 " "        1     
##  7 0100026~ 1        8         10         3                 25 " "        1     
##  8 0100026~ 1        8         10         3                 30 " "        1     
##  9 0100026~ 3        8         10         2                  1 " "        2     
## 10 0100027~ 1        8         10         3                 30 " "        1     
## # ... with 73,395 more rows, and 58 more variables: cocina_dor <chr>,
## #   cuart_dorm <dbl>, num_cuarto <dbl>, disp_agua <chr>, dotac_agua <chr>,
## #   excusado <chr>, uso_compar <chr>, sanit_agua <chr>, biodigest <chr>,
## #   bano_comp <dbl>, bano_excus <dbl>, bano_regad <dbl>, drenaje <chr>,
## #   disp_elect <chr>, focos_inca <dbl>, focos_ahor <dbl>, combustible <chr>,
## #   estufa_chi <chr>, eli_basura <chr>, tenencia <chr>, renta <dbl>,
## #   estim_pago <dbl>, pago_viv <dbl>, pago_mesp <chr>, tipo_adqui <chr>, ...

Por lo tanto podemos obtener nuestras estadisticas descriptivas por la nueva variable creada:

vivienda %>% 
  mutate(obs = 1,
         num = obs*factor) %>% 
  summarise(min(num), max(num), sum(num))
## # A tibble: 1 x 3
##   `min(num)` `max(num)` `sum(num)`
##        <dbl>      <dbl>      <dbl>
## 1          9       6727   34155615

Podemos hacerlo de distintas formas:

vivienda %>% summarise(min(factor), max(factor), sum(factor))
## # A tibble: 1 x 3
##   `min(factor)` `max(factor)` `sum(factor)`
##           <dbl>         <dbl>         <dbl>
## 1             9          6727      34155615

Vamos ahora a cambiar los nombres de los estados:

library(stringr)
vivienda <-
  vivienda %>% 
  mutate(cve_estado = str_sub(as.character(ubica_geo), end = 2),            ##usamos ubica_geo para condicionar
         estado = case_when(cve_estado == "01" ~ "Aguascalientes",          ##podemos hacer múltiples tareas
                            cve_estado == "02" ~ "Baja California",
                            cve_estado == "03" ~ "Baja California Sur",
                            cve_estado == "04" ~ "Campeche",
                            cve_estado == "05" ~ "Coahuila de Zaragoza",
                            cve_estado == "06" ~ "Colima",
                            cve_estado == "07" ~ "Chiapas",
                            cve_estado == "08" ~ "Chihuahua",
                            cve_estado == "09" ~ "Ciudad de México",
                            cve_estado == "10" ~ "Durango",
                            cve_estado == "11" ~ "Guanajuato",
                            cve_estado == "12" ~ "Guerrero",
                            cve_estado == "13" ~ "Hidalgo",
                            cve_estado == "14" ~ "Jalisco",
                            cve_estado == "15" ~ "Estado de México",
                            cve_estado == "16" ~ "Michoacán de Ocampo",
                            cve_estado == "17" ~ "Morelos",
                            cve_estado == "18" ~ "Nayarit",
                            cve_estado == "19" ~ "Nuevo León",
                            cve_estado == "20" ~ "Oaxaca",
                            cve_estado == "21" ~ "Puebla",
                            cve_estado == "22" ~ "Querétaro",
                            cve_estado == "23" ~ "Quintana Roo",
                            cve_estado == "24" ~ "San Luis Potos",
                            cve_estado == "25" ~ "Sinaloa",
                            cve_estado == "26" ~ "Sonora",
                            cve_estado == "27" ~ "Tabasco",
                            cve_estado == "28" ~ "Tamaulipas",
                            cve_estado == "29" ~ "Tlaxcala",
                            cve_estado == "30" ~ "Veracruz de Ignacio de la Llave",
                            cve_estado == "31" ~ "Yucatán",
                            cve_estado == "32" ~ "Zacatecas"))

Checkamos la base de nuevo:

describe(vivienda)
## vivienda 
## 
##  66  Variables      73405  Observations
## --------------------------------------------------------------------------------
## folioviv 
##        n  missing distinct 
##    73405        0    73405 
## 
## lowest : 0100013601 0100013602 0100013603 0100013604 0100013606
## highest: 3260798902 3260798903 3260798904 3260798905 3260798906
## --------------------------------------------------------------------------------
## tipo_viv 
##        n  missing distinct 
##    73405        0        6 
## 
## lowest : & 1 2 3 4, highest: 1 2 3 4 5
##                                               
## Value          &     1     2     3     4     5
## Frequency     51 69425  1940  1428    99   462
## Proportion 0.001 0.946 0.026 0.019 0.001 0.006
## --------------------------------------------------------------------------------
## mat_pared 
##        n  missing distinct 
##    73405        0        8 
## 
## lowest : 1 2 3 4 5, highest: 4 5 6 7 8
##                                                           
## Value          1     2     3     4     5     6     7     8
## Frequency    139   128   442   172   271  3397  6347 62509
## Proportion 0.002 0.002 0.006 0.002 0.004 0.046 0.086 0.852
## --------------------------------------------------------------------------------
## mat_techos 
##        n  missing distinct 
##    73405        0       10 
## 
## lowest : 01 02 03 04 05, highest: 06 07 08 09 10
##                                                                       
## Value          1     2     3     4     5     6     7     8     9    10
## Frequency    150   616 11500  4278   216   444  3009   990  1163 51039
## Proportion 0.002 0.008 0.157 0.058 0.003 0.006 0.041 0.013 0.016 0.695
## --------------------------------------------------------------------------------
## mat_pisos 
##        n  missing distinct 
##    73405        0        4 
##                                   
## Value          &     1     2     3
## Frequency      4  2277 40586 30538
## Proportion 0.000 0.031 0.553 0.416
## --------------------------------------------------------------------------------
## antiguedad 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    62501    10904       97    0.997    21.84    16.95        3        5 
##      .25      .50      .75      .90      .95 
##       10       20       30       40       50 
## 
## lowest :  0  1  2  3  4, highest: 95 96 97 98 99
## --------------------------------------------------------------------------------
## antigua_ne 
##        n  missing distinct    value 
##    10904    62501        1        1 
##                 
## Value          1
## Frequency  10904
## Proportion     1
## --------------------------------------------------------------------------------
## cocina 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  67586  5819
## Proportion 0.921 0.079
## --------------------------------------------------------------------------------
## cocina_dor 
##        n  missing distinct 
##    67586     5819        2 
##                       
## Value          1     2
## Frequency   4737 62849
## Proportion  0.07  0.93
## --------------------------------------------------------------------------------
## cuart_dorm 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    73405        0       11    0.881     2.03   0.9442        1        1 
##      .25      .50      .75      .90      .95 
##        1        2        3        3        4 
## 
## lowest :  1  2  3  4  5, highest:  7  8  9 10 11
##                                                                             
## Value          1     2     3     4     5     6     7     8     9    10    11
## Frequency  22270 31846 15233  3251   600   150    33    17     2     2     1
## Proportion 0.303 0.434 0.208 0.044 0.008 0.002 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## num_cuarto 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    73405        0       20    0.952    3.671    1.617        1        2 
##      .25      .50      .75      .90      .95 
##        3        4        4        6        6 
## 
## lowest :  1  2  3  4  5, highest: 16 17 18 20 22
##                                                                             
## Value          1     2     3     4     5     6     7     8     9    10    11
## Frequency   4112 10948 20402 19872 10684  4499  1678   711   276   129    38
## Proportion 0.056 0.149 0.278 0.271 0.146 0.061 0.023 0.010 0.004 0.002 0.001
##                                                                 
## Value         12    13    14    15    16    17    18    20    22
## Frequency     30     7     8     3     4     1     1     1     1
## Proportion 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## disp_agua 
##        n  missing distinct 
##    73405        0        7 
## 
## lowest : 1 2 3 4 5, highest: 3 4 5 6 7
##                                                     
## Value          1     2     3     4     5     6     7
## Frequency  52697 14701   231   328   658  1556  3234
## Proportion 0.718 0.200 0.003 0.004 0.009 0.021 0.044
## --------------------------------------------------------------------------------
## dotac_agua 
##        n  missing distinct 
##    67398     6007        5 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency  48148 11268  3559  2502  1921
## Proportion 0.714 0.167 0.053 0.037 0.029
## --------------------------------------------------------------------------------
## excusado 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  71408  1997
## Proportion 0.973 0.027
## --------------------------------------------------------------------------------
## uso_compar 
##        n  missing distinct 
##    71408     1997        2 
##                       
## Value          1     2
## Frequency   4896 66512
## Proportion 0.069 0.931
## --------------------------------------------------------------------------------
## sanit_agua 
##        n  missing distinct 
##    71408     1997        3 
##                             
## Value          1     2     3
## Frequency  48548 18070  4790
## Proportion 0.680 0.253 0.067
## --------------------------------------------------------------------------------
## biodigest 
##        n  missing distinct 
##    71408     1997        2 
##                       
## Value          1     2
## Frequency   1489 69919
## Proportion 0.021 0.979
## --------------------------------------------------------------------------------
## bano_comp 
##        n  missing distinct     Info     Mean      Gmd 
##    71408     1997        9    0.789   0.8721   0.7087 
## 
## lowest : 0 1 2 3 4, highest: 4 5 6 7 8
##                                                                 
## Value          0     1     2     3     4     5     6     7     8
## Frequency  20995 40603  8199  1283   246    56    19     6     1
## Proportion 0.294 0.569 0.115 0.018 0.003 0.001 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## bano_excus 
##        n  missing distinct     Info     Mean      Gmd 
##    71408     1997        9    0.723   0.4135   0.5207 
## 
## lowest : 0 1 2 3 4, highest: 4 5 6 8 9
##                                                                 
## Value          0     1     2     3     4     5     6     8     9
## Frequency  43499 26529  1269    74    13     6     1     5    12
## Proportion 0.609 0.372 0.018 0.001 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## bano_regad 
##        n  missing distinct     Info     Mean      Gmd 
##    71408     1997        9    0.107  0.04004  0.07735 
## 
## lowest : 0 1 2 3 4, highest: 4 5 6 8 9
##                                                                 
## Value          0     1     2     3     4     5     6     8     9
## Frequency  68773  2556    47     6     4     3     2     5    12
## Proportion 0.963 0.036 0.001 0.000 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## drenaje 
##        n  missing distinct 
##    73405        0        5 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency  48060 19453   714   265  4913
## Proportion 0.655 0.265 0.010 0.004 0.067
## --------------------------------------------------------------------------------
## disp_elect 
##        n  missing distinct 
##    73405        0        5 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency  72122   128   211   451   493
## Proportion 0.983 0.002 0.003 0.006 0.007
## --------------------------------------------------------------------------------
## focos_inca 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    72912      493       41    0.789    1.392    2.055        0        0 
##      .25      .50      .75      .90      .95 
##        0        0        2        4        6 
## 
## lowest :  0  1  2  3  4, highest: 50 52 60 80 98
## --------------------------------------------------------------------------------
## focos_ahor 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    72912      493       65     0.99    5.179    4.714        0        0 
##      .25      .50      .75      .90      .95 
##        2        4        7       10       13 
## 
## lowest :  0  1  2  3  4, highest: 80 83 89 90 99
## --------------------------------------------------------------------------------
## combustible 
##        n  missing distinct 
##    73405        0        7 
## 
## lowest : & 1 2 3 4, highest: 2 3 4 5 6
##                                                     
## Value          &     1     2     3     4     5     6
## Frequency      1 12935   277 54948  3783   958   503
## Proportion 0.000 0.176 0.004 0.749 0.052 0.013 0.007
## --------------------------------------------------------------------------------
## estufa_chi 
##        n  missing distinct 
##    13212    60193        2 
##                     
## Value         1    2
## Frequency  3695 9517
## Proportion 0.28 0.72
## --------------------------------------------------------------------------------
## eli_basura 
##        n  missing distinct 
##    73405        0        8 
## 
## lowest : 1 2 3 4 5, highest: 4 5 6 7 8
##                                                           
## Value          1     2     3     4     5     6     7     8
## Frequency  55926  1752  3835 10876   294   448   252    22
## Proportion 0.762 0.024 0.052 0.148 0.004 0.006 0.003 0.000
## --------------------------------------------------------------------------------
## tenencia 
##        n  missing distinct 
##    73405        0        6 
## 
## lowest : 1 2 3 4 5, highest: 2 3 4 5 6
##                                               
## Value          1     2     3     4     5     6
## Frequency   9097 10071  6360 46058  1277   542
## Proportion 0.124 0.137 0.087 0.627 0.017 0.007
## --------------------------------------------------------------------------------
## renta 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     9097    64308      190    0.995     2031     1608      500      700 
##      .25      .50      .75      .90      .95 
##     1000     1500     2300     3800     5000 
## 
## lowest :    83   120   150   167   200, highest: 28000 35000 36000 40000 44000
## --------------------------------------------------------------------------------
## estim_pago 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    64308     9097      154    0.989     1892     1627      500      500 
##      .25      .50      .75      .90      .95 
##     1000     1500     2000     3500     5000 
## 
## lowest :     1    50    80   100   120, highest: 40000 50000 55000 57000 60000
## --------------------------------------------------------------------------------
## pago_viv 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##     6360    67045      498    0.999     2690     2072      800     1000 
##      .25      .50      .75      .90      .95 
##     1300     2000     3100     5000     7000 
## 
## lowest :    83   100   125   150   200, highest: 28000 30000 40000 47000 70000
## --------------------------------------------------------------------------------
## pago_mesp 
##        n  missing distinct 
##    15455    57950        2 
##                       
## Value          1     2
## Frequency  14533   922
## Proportion  0.94  0.06
## --------------------------------------------------------------------------------
## tipo_adqui 
##        n  missing distinct 
##    52418    20987        4 
##                                   
## Value          1     2     3     4
## Frequency  13543 19027 16331  3517
## Proportion 0.258 0.363 0.312 0.067
## --------------------------------------------------------------------------------
## viv_usada 
##        n  missing distinct 
##    13543    59862        2 
##                       
## Value          1     2
## Frequency   6248  7295
## Proportion 0.461 0.539
## --------------------------------------------------------------------------------
## tipo_finan 
##        n  missing distinct 
##    48901    24504        6 
## 
## lowest : & 1 2 3 4, highest: 1 2 3 4 5
##                                               
## Value          &     1     2     3     4     5
## Frequency    463  8462  2387  1399  1602 34588
## Proportion 0.009 0.173 0.049 0.029 0.033 0.707
## --------------------------------------------------------------------------------
## num_dueno1 
##        n  missing distinct 
##    52418    20987       11 
## 
## lowest : 01 02 03 04 05, highest: 07 08 09 10 11
##                                                                             
## Value          1     2     3     4     5     6     7     8     9    10    11
## Frequency  44619  7096   474   105    56    38    15     7     4     3     1
## Proportion 0.851 0.135 0.009 0.002 0.001 0.001 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## hog_dueno1 
##        n  missing distinct 
##    52418    20987        3 
##                             
## Value          1     2     3
## Frequency  52351    63     4
## Proportion 0.999 0.001 0.000
## --------------------------------------------------------------------------------
## num_dueno2 
##        n  missing distinct 
##     2973    70432        6 
## 
## lowest : 01 02 03 04 05, highest: 02 03 04 05 06
##                                               
## Value          1     2     3     4     5     6
## Frequency    397  2499    46    19     8     4
## Proportion 0.134 0.841 0.015 0.006 0.003 0.001
## --------------------------------------------------------------------------------
## hog_dueno2 
##        n  missing distinct 
##     2973    70432        2 
##                       
## Value          1     2
## Frequency   2961    12
## Proportion 0.996 0.004
## --------------------------------------------------------------------------------
## escrituras 
##        n  missing distinct 
##    52418    20987        4 
##                                   
## Value          1     2     3     4
## Frequency  33065  4096 14789   468
## Proportion 0.631 0.078 0.282 0.009
## --------------------------------------------------------------------------------
## lavadero 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  60220 13185
## Proportion  0.82  0.18
## --------------------------------------------------------------------------------
## fregadero 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  42639 30766
## Proportion 0.581 0.419
## --------------------------------------------------------------------------------
## regadera 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  52843 20562
## Proportion  0.72  0.28
## --------------------------------------------------------------------------------
## tinaco_azo 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  39770 33635
## Proportion 0.542 0.458
## --------------------------------------------------------------------------------
## cisterna 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  12705 60700
## Proportion 0.173 0.827
## --------------------------------------------------------------------------------
## pileta 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  28216 45189
## Proportion 0.384 0.616
## --------------------------------------------------------------------------------
## calent_sol 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency   5841 67564
## Proportion  0.08  0.92
## --------------------------------------------------------------------------------
## calent_gas 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  25252 48153
## Proportion 0.344 0.656
## --------------------------------------------------------------------------------
## medidor_luz 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  67746  5659
## Proportion 0.923 0.077
## --------------------------------------------------------------------------------
## bomba_agua 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  16250 57155
## Proportion 0.221 0.779
## --------------------------------------------------------------------------------
## tanque_gas 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency   6584 66821
## Proportion  0.09  0.91
## --------------------------------------------------------------------------------
## aire_acond 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency  13712 59693
## Proportion 0.187 0.813
## --------------------------------------------------------------------------------
## calefacc 
##        n  missing distinct 
##    73405        0        2 
##                       
## Value          1     2
## Frequency   1958 71447
## Proportion 0.027 0.973
## --------------------------------------------------------------------------------
## tot_resid 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    73405        0       20    0.971    3.667    2.049        1        1 
##      .25      .50      .75      .90      .95 
##        2        4        5        6        7 
## 
## lowest :  1  2  3  4  5, highest: 16 17 18 20 22
##                                                                             
## Value          1     2     3     4     5     6     7     8     9    10    11
## Frequency   8345 13669 14114 16119 10807  5270  2529  1227   615   314   178
## Proportion 0.114 0.186 0.192 0.220 0.147 0.072 0.034 0.017 0.008 0.004 0.002
##                                                                 
## Value         12    13    14    15    16    17    18    20    22
## Frequency     86    61    37    11    13     4     4     1     1
## Proportion 0.001 0.001 0.001 0.000 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## tot_hom 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    73405        0       12    0.916    1.794     1.25        0        1 
##      .25      .50      .75      .90      .95 
##        1        2        2        3        4 
## 
## lowest :  0  1  2  3  4, highest:  7  8  9 10 11
##                                                                             
## Value          0     1     2     3     4     5     6     7     8     9    10
## Frequency   6785 27680 21535 11447  4104  1252   412   119    50     9     8
## Proportion 0.092 0.377 0.293 0.156 0.056 0.017 0.006 0.002 0.001 0.000 0.000
##                 
## Value         11
## Frequency      4
## Proportion 0.000
## --------------------------------------------------------------------------------
## tot_muj 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    73405        0       13     0.92    1.874    1.288        0        1 
##      .25      .50      .75      .90      .95 
##        1        2        3        3        4 
## 
## lowest :  0  1  2  3  4, highest:  8  9 10 11 12
##                                                                             
## Value          0     1     2     3     4     5     6     7     8     9    10
## Frequency   5923 26715 21842 12096  4545  1476   535   184    50    19    10
## Proportion 0.081 0.364 0.298 0.165 0.062 0.020 0.007 0.003 0.001 0.000 0.000
##                       
## Value         11    12
## Frequency      7     3
## Proportion 0.000 0.000
## --------------------------------------------------------------------------------
## tot_hog 
##        n  missing distinct     Info     Mean      Gmd 
##    73405        0        5    0.043    1.017  0.03341 
## 
## lowest : 1 2 3 4 5, highest: 1 2 3 4 5
##                                         
## Value          1     2     3     4     5
## Frequency  72336   926   118    20     5
## Proportion 0.985 0.013 0.002 0.000 0.000
## --------------------------------------------------------------------------------
## ubica_geo 
##        n  missing distinct 
##    73405        0      996 
## 
## lowest : 01001 01002 01003 01005 01006, highest: 32051 32052 32053 32054 32056
## --------------------------------------------------------------------------------
## tam_loc 
##        n  missing distinct 
##    73405        0        4 
##                                   
## Value          1     2     3     4
## Frequency  26303  9270  9666 28166
## Proportion 0.358 0.126 0.132 0.384
## --------------------------------------------------------------------------------
## est_socio 
##        n  missing distinct 
##    73405        0        4 
##                                   
## Value          1     2     3     4
## Frequency  17667 38573 12428  4737
## Proportion 0.241 0.525 0.169 0.065
## --------------------------------------------------------------------------------
## est_dis 
##        n  missing distinct 
##    73405        0      543 
## 
## lowest : 001 002 003 004 005, highest: 539 540 541 542 543
## --------------------------------------------------------------------------------
## upm 
##        n  missing distinct 
##    73405        0     8377 
## 
## lowest : 0000001 0000002 0000003 0000004 0000005
## highest: 0008391 0008392 0008393 0008394 0008395
## --------------------------------------------------------------------------------
## factor 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##    73405        0     1747        1    465.3    436.2       58       97 
##      .25      .50      .75      .90      .95 
##      170      323      594      940     1350 
## 
## lowest :    9   18   19   21   22, highest: 5465 5538 6045 6371 6727
## --------------------------------------------------------------------------------
## procaptar 
##        n  missing distinct 
##    73405        0        2 
##                                                                      
## Value                                                       No aplica
## Frequency                                           72694            
## Proportion                                          0.99             
##                                                                      
## Value      Vivienda con precipitación pluvial mayor o igual a 1500 mm
## Frequency                                             711            
## Proportion                                          0.01             
## --------------------------------------------------------------------------------
## cve_estado 
##        n  missing distinct 
##    73405        0       32 
## 
## lowest : 01 02 03 04 05, highest: 28 29 30 31 32
## --------------------------------------------------------------------------------
## estado 
##        n  missing distinct 
##    73405        0       32 
## 
## lowest : Aguascalientes                  Baja California                 Baja California Sur             Campeche                        Chiapas                        
## highest: Tamaulipas                      Tlaxcala                        Veracruz de Ignacio de la Llave Yucatán                         Zacatecas                      
## --------------------------------------------------------------------------------

Ejercicio 2

Calculamos el numero de viviendas por estados y el numero de viviendas rurales porcentualmente en cada estado.

Solución

numero_viviendas <- 
  vivienda %>% 
  mutate(esvivienda = 1,
         esrural = if_else(tam_loc == 4, 1, 0), # Contamos el numero de viv. en localidades con menos de 2.5 k
         totalviviendas = esvivienda*factor,
         totalviviendas_rural = esrural*factor) %>% 
  group_by(estado) %>% 
  summarise(totalviviendas = sum(totalviviendas),
            totalviviendas_rural = sum(totalviviendas_rural)/sum(totalviviendas), 4)

numero_viviendas
## # A tibble: 32 x 4
##    estado               totalviviendas totalviviendas_rural   `4`
##    <chr>                         <dbl>                <dbl> <dbl>
##  1 Aguascalientes               339512              0.216       4
##  2 Baja California             1074429              0.0944      4
##  3 Baja California Sur          255062              0.151       4
##  4 Campeche                     252458              0.268       4
##  5 Chiapas                     1307648              0.487       4
##  6 Chihuahua                   1147242              0.150       4
##  7 Ciudad de México            2601456              0.00564     4
##  8 Coahuila de Zaragoza         840362              0.106       4
##  9 Colima                       228268              0.123       4
## 10 Durango                      487076              0.298       4
## # ... with 22 more rows

Ejercicio 3

Promedio y mediana de numero de cuartos por vivienda por tamanio de localidad

Solución

media_mediana<-vivienda %>% 
  group_by(tam_loc) %>% 
  summarise(promedio_cuartos = mean(num_cuarto, na.rm = TRUE),
            mediana_cuartos = median(num_cuarto, na.rm = TRUE),.groups='drop')

Tamaño localidad es una variable:

print(typeof(vivienda$tam_loc))
## [1] "character"
levels(vivienda$tam_loc)
## NULL

El resutlado será:

media_mediana
## # A tibble: 4 x 3
##   tam_loc promedio_cuartos mediana_cuartos
##   <chr>              <dbl>           <dbl>
## 1 1                   4.00               4
## 2 2                   3.68               4
## 3 3                   3.56               3
## 4 4                   3.40               3

Si queremos modificar el tipo de variable de tam_loc:

vivienda<-vivienda %>% mutate(tam_loc=as.factor(tam_loc))

Ahora volviendo a correr el codigo anterior:

is.factor(vivienda$tam_loc)
## [1] TRUE
levels(vivienda$tam_loc)
## [1] "1" "2" "3" "4"

Ejercicio 4

Ingreso trimestral del hogar por tamaño de localidad

Solución

Tenemos más que un lugar por vivienda

hogar %>% 
  select(folioviv, foliohog)
## # A tibble: 74,647 x 2
##    folioviv   foliohog
##    <chr>      <chr>   
##  1 0100013601 1       
##  2 0100013602 1       
##  3 0100013603 1       
##  4 0100013604 1       
##  5 0100013606 1       
##  6 0100026701 1       
##  7 0100026703 1       
##  8 0100026704 1       
##  9 0100026706 1       
## 10 0100027201 1       
## # ... with 74,637 more rows

por lo tanto tendremos que crear una clave unica:

hogar <- 
  hogar %>% 
  mutate(folioviv_hog = str_c(folioviv, as.character(foliohog))) 

Analizamos el resultado obtenido:

hogar %>% 
  select(folioviv, foliohog, folioviv_hog)
## # A tibble: 74,647 x 3
##    folioviv   foliohog folioviv_hog
##    <chr>      <chr>    <chr>       
##  1 0100013601 1        01000136011 
##  2 0100013602 1        01000136021 
##  3 0100013603 1        01000136031 
##  4 0100013604 1        01000136041 
##  5 0100013606 1        01000136061 
##  6 0100026701 1        01000267011 
##  7 0100026703 1        01000267031 
##  8 0100026704 1        01000267041 
##  9 0100026706 1        01000267061 
## 10 0100027201 1        01000272011 
## # ... with 74,637 more rows

Calculamos el ingreso por hogar:

calculo_ingreso <- 
  ingreso %>% 
  mutate(folioviv_hog = str_c(folioviv, as.character(foliohog))) %>% #Mismo identificador que creamos antes
  group_by(folioviv_hog) %>% #Cálculo por hogar
  summarise(ingreso_hogar = sum(ing_tri),.groups='drop') #Sumamos las fuentes de ingreso

Hacemos un join para asociar el resultado obtenido a toda la listqa de hogares que habiamos identificado:

hogar <- 
  left_join(hogar, calculo_ingreso, by = c("folioviv_hog"))

Ahora podemos calcular el ingreso por localidad:

ingreso_por_localidad <- 
  hogar %>% 
  group_by(tam_loc) %>% 
  summarise(media = mean(ingreso_hogar, na.rm = TRUE),
            pc50 = median(ingreso_hogar, na.rm = TRUE),
            min = min(ingreso_hogar, na.rm = TRUE),
            max = max(ingreso_hogar, na.rm = TRUE)) 

ingreso_por_localidad
## # A tibble: 4 x 5
##   tam_loc  media   pc50   min       max
##   <chr>    <dbl>  <dbl> <dbl>     <dbl>
## 1 1       52856. 37746.  68.5  3916956.
## 2 2       42304. 30962. 293.   2738151.
## 3 3       35928. 26053. 293.   1626365.
## 4 4       30099. 20543.  49.2 17757845.

Ejercicio 5

¿Cuántos hogares reciben más de 15% de su ingreso como beneficio del gobierno?

Solución

Vamos, antes que todo, a definir una dummie para identificar

hogar <- 
  hogar %>% 
  mutate(folioviv_hog = str_c(folioviv, as.character(foliohog)),     ##indicador para hogar
         prop_gobierno = bene_gob/ing_cor,                           ##la variable de fraccion
         dmas15 = if_else(prop_gobierno > .15, 1, 0))

Calculamos el numero de hogares para cada localidad:

hogares_loc <- 
  hogar %>% 
  group_by(folioviv_hog) %>% 
  mutate(obs = 1,
         num = obs*factor) %>% 
  ungroup() %>% 
  group_by(tam_loc) %>% 
  summarise(sumahogares = sum(num),.groups='drop') 

hogares_loc
## # A tibble: 4 x 2
##   tam_loc sumahogares
##   <chr>         <dbl>
## 1 1          16735454
## 2 2           5107996
## 3 3           4876725
## 4 4           8024643

Las que si reciben más de 15% en aydua gubernamental:

hogares_d <- 
  hogar %>% 
  filter(is.na(dmas15) != TRUE) %>% 
  group_by(folioviv_hog) %>% 
  mutate(obs = 1,
         num = obs*factor) %>% 
  ungroup() %>%
  group_by(tam_loc, dmas15) %>% 
  summarise(num = sum(num))
## `summarise()` has grouped output by 'tam_loc'. You can override using the `.groups` argument.
hogares_d
## # A tibble: 8 x 3
## # Groups:   tam_loc [4]
##   tam_loc dmas15      num
##   <chr>    <dbl>    <dbl>
## 1 1            0 16434595
## 2 1            1   297487
## 3 2            0  4882380
## 4 2            1   224555
## 5 3            0  4394684
## 6 3            1   481800
## 7 4            0  6160257
## 8 4            1  1864247

Construimos nuestra tabla de resumen:

hogares_loc_d <- left_join(hogares_loc, hogares_d, by = "tam_loc")

hogares_loc_d <- 
  hogares_loc_d %>% 
  mutate(proporcion = num/sumahogares) 

hogares_loc_d
## # A tibble: 8 x 5
##   tam_loc sumahogares dmas15      num proporcion
##   <chr>         <dbl>  <dbl>    <dbl>      <dbl>
## 1 1          16735454      0 16434595     0.982 
## 2 1          16735454      1   297487     0.0178
## 3 2           5107996      0  4882380     0.956 
## 4 2           5107996      1   224555     0.0440
## 5 3           4876725      0  4394684     0.901 
## 6 3           4876725      1   481800     0.0988
## 7 4           8024643      0  6160257     0.768 
## 8 4           8024643      1  1864247     0.232

Ejercicio 6

Porcentaje promedio de gasto de hogares en materiales y servicios de reparacion por tamanio de localidad

Solución

hogar <- 
  hogar %>% 
  mutate(prop_mater_serv = mater_serv/gasto_mon)

hogares_serv_loc <-
  hogar %>% 
  group_by(tam_loc) %>%
  summarise(prom_prop_mater_serv = mean(prop_mater_serv, na.rm = TRUE))

hogares_serv_loc
## # A tibble: 4 x 2
##   tam_loc prom_prop_mater_serv
##   <chr>                  <dbl>
## 1 1                    0.00740
## 2 2                    0.00840
## 3 3                    0.0107 
## 4 4                    0.0119

Ejercicio 7

Regresión de porcentaje transferencia con educacióon y edad
Solución

modelo_lineal <-lm(prop_gobierno ~ edad_jefe + educa_jefe ,hogar)
summary(modelo_lineal)
## 
## Call:
## lm(formula = prop_gobierno ~ edad_jefe + educa_jefe, data = hogar)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.14571 -0.03797 -0.01724  0.00309  0.86447 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   8.084e-02  1.950e-03  41.463   <2e-16 ***
## edad_jefe     6.360e-04  2.332e-05  27.270   <2e-16 ***
## educa_jefe02 -1.522e-02  1.017e-02  -1.497    0.134    
## educa_jefe03 -3.714e-02  1.436e-03 -25.860   <2e-16 ***
## educa_jefe04 -6.621e-02  1.463e-03 -45.270   <2e-16 ***
## educa_jefe05 -8.178e-02  2.186e-03 -37.402   <2e-16 ***
## educa_jefe06 -8.230e-02  1.445e-03 -56.955   <2e-16 ***
## educa_jefe07 -9.349e-02  2.229e-03 -41.939   <2e-16 ***
## educa_jefe08 -9.673e-02  1.637e-03 -59.088   <2e-16 ***
## educa_jefe09 -1.026e-01  2.365e-03 -43.379   <2e-16 ***
## educa_jefe10 -1.062e-01  1.676e-03 -63.347   <2e-16 ***
## educa_jefe11 -1.102e-01  2.797e-03 -39.409   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.08856 on 74627 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.1377, Adjusted R-squared:  0.1376 
## F-statistic:  1084 on 11 and 74627 DF,  p-value: < 2.2e-16

MCO Ejemplo

Importamos los datos y renombramos en español:

datos<-as_tibble(wooldridge::wage1) %>% 
  rename(SalarioHora=wage,
         Educación=educ,
         Experiencia=exper,
         Antiguedad=tenure,
nero=female,
         EdoCivil=married)  %>%
  mutate(Género = recode_factor(Género, `1` = "Mujer", `0` = "Hombre"),
         EdoCivil = recode_factor(EdoCivil, `1` = "Casad@", `0` = "Solter@"))

Analizamos la base:

View(datos)

Empezamos con un modelo ingenuo, para determinare el salario por hora:

modelo0<-lm(SalarioHora~Género,data = datos)

Para obtener una tabla de resumen de esta regresión podemos hacer:

summary(modelo0)
## 
## Call:
## lm(formula = SalarioHora ~ Género, data = datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.5995 -1.8495 -0.9877  1.4260 17.8805 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    4.5877     0.2190  20.950  < 2e-16 ***
## GéneroHombre   2.5118     0.3034   8.279 1.04e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.476 on 524 degrees of freedom
## Multiple R-squared:  0.1157, Adjusted R-squared:  0.114 
## F-statistic: 68.54 on 1 and 524 DF,  p-value: 1.042e-15

O:

library(stargazer)
## 
## 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
stargazer(modelo0,type = "text")
## 
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                             SalarioHora        
## -----------------------------------------------
## GéneroHombre                 2.512***          
##                               (0.303)          
##                                                
## Constant                     4.588***          
##                               (0.219)          
##                                                
## -----------------------------------------------
## Observations                    526            
## R2                             0.116           
## Adjusted R2                    0.114           
## Residual Std. Error      3.476 (df = 524)      
## F Statistic           68.537*** (df = 1; 524)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01

Ahora añadimos un control:

modelo1<-lm(SalarioHora~Género+Educación,data = datos)
summary(modelo1)
## 
## Call:
## lm(formula = SalarioHora ~ Género + Educación, data = datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.9890 -1.8702 -0.6651  1.0447 15.4998 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.65055    0.65232  -2.530   0.0117 *  
## GéneroHombre  2.27336    0.27904   8.147 2.76e-15 ***
## Educación     0.50645    0.05039  10.051  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.186 on 523 degrees of freedom
## Multiple R-squared:  0.2588, Adjusted R-squared:  0.256 
## F-statistic: 91.32 on 2 and 523 DF,  p-value: < 2.2e-16

Podemos cambiar la categoria de referencia:

datos <- datos %>%
  mutate(Género = relevel(Género, ref = "Hombre"),EdoCivil=relevel(EdoCivil,ref="Solter@"))

Ahora nuestor modelo será:

modelo1.1<-lm(SalarioHora~Género+Educación,data = datos)
summary(modelo1.1)
## 
## Call:
## lm(formula = SalarioHora ~ Género + Educación, data = datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.9890 -1.8702 -0.6651  1.0447 15.4998 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.62282    0.67253   0.926    0.355    
## GéneroMujer -2.27336    0.27904  -8.147 2.76e-15 ***
## Educación    0.50645    0.05039  10.051  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.186 on 523 degrees of freedom
## Multiple R-squared:  0.2588, Adjusted R-squared:  0.256 
## F-statistic: 91.32 on 2 and 523 DF,  p-value: < 2.2e-16

Podemos calcular los interceptos especificos para cada genero.

interceptos <- c(coef(modelo1.1)["(Intercept)"],  #intercepto de hombres
                coef(modelo1.1)["(Intercept)"] + coef(modelo1.1)["GéneroMujer"]) #intercepto de mujeres
              

rectas.df<- data.frame(interceptos = interceptos,
                       slopes = rep(coef(modelo1.1)["Educación"], 2),
                       Género = levels(datos$Género))

Y plotearlo:

qplot(x = Educación, y = SalarioHora, color = Género, data = datos) + 
  geom_abline(aes(intercept = interceptos, 
                  slope = slopes, 
                  color = Género), data = rectas.df)

Siendo female= 1 si la persona es mujer y female= 0 si la persona es hombre el parámetro de “female” tiene la interpretación siguiente: es la diferencia del salario por hora entre hombres y mujeres, dada una misma cantidad de educación (y un mismo término del error,u). Determina si hay discriminación en contra de las mujeres: si, para un mismo nivel de los demás factores, parámetro de female <0, las mujeres ganan, en promedio, menos que los hombres.

Podemos interpretar el parametro female = E(wage| female,educ) - E(wage|male,educ)

coef(modelo1.1)["GéneroMujer"]
## GéneroMujer 
##   -2.273362
  #intercepto Hombres
  interceptos[1]
## (Intercept) 
##   0.6228168
  #intercepto Mujeres
  interceptos[2]
## (Intercept) 
##   -1.650545

Podemos efectuar una regresión sin intercepto:

library(kableExtra)
## Warning: package 'kableExtra' was built under R version 4.0.5
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library(xtable)
## 
## Attaching package: 'xtable'
## The following objects are masked from 'package:Hmisc':
## 
##     label, label<-
modelo1.2<-lm(SalarioHora~Género+Educación-1,data = datos)
salida.modelo1.2<- data.frame(xtable(summary(modelo1.2))) #Resumen del modelo 1.7
kable(salida.modelo1.2, caption="Ecuación de Salario con Género y Educación, sin intercepto")
Ecuación de Salario con Género y Educación, sin intercepto
Estimate Std..Error t.value Pr…t..
GéneroHombre 0.6228168 0.6725334 0.9260756 0.3548338
GéneroMujer -1.6505451 0.6523170 -2.5302806 0.0116894
Educación 0.5064521 0.0503906 10.0505201 0.0000000

En este caso como se interpretan los coeficientes?

Los interceptos serán dados por el parametro asociado al genero.

Podemos añadir más covariables (X).

modelo1.3<-lm(SalarioHora~Género+Educación+Experiencia+Antiguedad,data = datos)

salida.modelo1.3<- data.frame(xtable(summary(modelo1.3))) #Resumen del modelo 1.7
kable(salida.modelo1.3, caption="Modelo de regresión múltiple para el Salario por hora")
Modelo de regresión múltiple para el Salario por hora
Estimate Std..Error t.value Pr…t..
(Intercept) -1.5679387 0.7245511 -2.164014 0.0309170
GéneroMujer -1.8108522 0.2648252 -6.837915 0.0000000
Educación 0.5715048 0.0493373 11.583621 0.0000000
Experiencia 0.0253959 0.0115694 2.195083 0.0285981
Antiguedad 0.1410051 0.0211617 6.663225 0.0000000

Podemos utilziar más de una variable dicotomica en una regresión:

modelo1.4<-lm(log(SalarioHora)~Género+Educación+EdoCivil+
                   Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

El resultado arrojado será:

salida.modelo1.4<- data.frame(xtable(summary(modelo1.4))) #Resumen del modelo 1.7
kable(salida.modelo1.4, caption="Modelo con dos variables dicotómicas")
Modelo con dos variables dicotómicas
Estimate Std..Error t.value Pr…t..
(Intercept) 0.4177837 0.0988662 4.225749 0.0000281
GéneroMujer -0.2901837 0.0361121 -8.035646 0.0000000
Educación 0.0791547 0.0068003 11.639885 0.0000000
EdoCivilCasad@ 0.0529219 0.0407561 1.298503 0.1946922
Experiencia 0.0269535 0.0053258 5.060949 0.0000006
I(Experiencia^2) -0.0005399 0.0001122 -4.813500 0.0000019
Antiguedad 0.0312962 0.0068482 4.569988 0.0000061
I(Antiguedad^2) -0.0005744 0.0002347 -2.447533 0.0147147

Una limitación importante de este modelo es que se supone que la prima de casado es la misma para hombres que para mujeres; esto se soluciona en el siguitnte modelo

Creamos una variable categorica que defina la combinación de casado y genero:

datos<-datos %>% mutate(GenEdoCivil=as.factor(case_when(
  Género=="Mujer" & EdoCivil=="Casad@" ~ "MujerCasada",
  Género=="Mujer" & EdoCivil=="Solter@" ~ "MujerSoltera",
  Género=="Hombre" & EdoCivil=="Casad@" ~ "HombreCasado",
  Género=="Hombre" & EdoCivil=="Solter@" ~ str_c("Hombre","Soltero")))) 

Cambiamos la base de referencia a hombres solteros:

levels(datos$GenEdoCivil)  #HombreCasado es la base de referencia por default
## [1] "HombreCasado"  "HombreSoltero" "MujerCasada"   "MujerSoltera"
datos <- datos %>% mutate(GenEdoCivil = relevel(GenEdoCivil, ref = "HombreSoltero"))
levels(datos$GenEdoCivil)
## [1] "HombreSoltero" "HombreCasado"  "MujerCasada"   "MujerSoltera"

Corremos de nuevo el modelo:

library(stargazer)
modelo1.5<-lm(log(SalarioHora)~GenEdoCivil+Educación+
                Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

stargazer(modelo1.5,type = "text")
## 
## ===================================================
##                             Dependent variable:    
##                         ---------------------------
##                              log(SalarioHora)      
## ---------------------------------------------------
## GenEdoCivilHombreCasado          0.213***          
##                                   (0.055)          
##                                                    
## GenEdoCivilMujerCasada           -0.198***         
##                                   (0.058)          
##                                                    
## GenEdoCivilMujerSoltera          -0.110**          
##                                   (0.056)          
##                                                    
## Educación                        0.079***          
##                                   (0.007)          
##                                                    
## Experiencia                      0.027***          
##                                   (0.005)          
##                                                    
## I(Experiencia2)                  -0.001***         
##                                  (0.0001)          
##                                                    
## Antiguedad                       0.029***          
##                                   (0.007)          
##                                                    
## I(Antiguedad2)                   -0.001**          
##                                  (0.0002)          
##                                                    
## Constant                         0.321***          
##                                   (0.100)          
##                                                    
## ---------------------------------------------------
## Observations                        526            
## R2                                 0.461           
## Adjusted R2                        0.453           
## Residual Std. Error          0.393 (df = 517)      
## F Statistic               55.246*** (df = 8; 517)  
## ===================================================
## Note:                   *p<0.1; **p<0.05; ***p<0.01

Para interpretar los coeficientes de las variables binarias, hay que recordar que el grupo base es hombres solteros. De esta manera, las estimaciones para las tres variables binarias miden la diferencia proporcional en el salario con relación a los hombres solteros.

a diferencia proporcional estimada entre las mujeres solteras y casadas es 0.110 - (-0.198) = 0.088, ¿Pero es estadísticamente significativa?

Volvemos a correr el modelo utilziando uno de estos grupo como base:

datos <- datos %>% mutate(GenEdoCivil = relevel(GenEdoCivil, ref = "MujerCasada"))
modelo1.6<-lm(log(SalarioHora)~GenEdoCivil+Educación+
                Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

stargazer(modelo1.6,type = "text")
## 
## ====================================================
##                              Dependent variable:    
##                          ---------------------------
##                               log(SalarioHora)      
## ----------------------------------------------------
## GenEdoCivilHombreSoltero          0.198***          
##                                    (0.058)          
##                                                     
## GenEdoCivilHombreCasado           0.411***          
##                                    (0.046)          
##                                                     
## GenEdoCivilMujerSoltera            0.088*           
##                                    (0.052)          
##                                                     
## Educación                         0.079***          
##                                    (0.007)          
##                                                     
## Experiencia                       0.027***          
##                                    (0.005)          
##                                                     
## I(Experiencia2)                   -0.001***         
##                                   (0.0001)          
##                                                     
## Antiguedad                        0.029***          
##                                    (0.007)          
##                                                     
## I(Antiguedad2)                    -0.001**          
##                                   (0.0002)          
##                                                     
## Constant                            0.123           
##                                    (0.106)          
##                                                     
## ----------------------------------------------------
## Observations                         526            
## R2                                  0.461           
## Adjusted R2                         0.453           
## Residual Std. Error           0.393 (df = 517)      
## F Statistic                55.246*** (df = 8; 517)  
## ====================================================
## Note:                    *p<0.1; **p<0.05; ***p<0.01

En lugar de construir categorias ad hoc podemos ocupar las intereacción entre variables:

Grupo base: La combinación female 0 y married 0 corresponde al grupo de los hombres solteros.

Hay diferentes formas para meter las interaciones.

Primera forma:

modelo1.7<-lm(log(SalarioHora)~Género+EdoCivil+Género:EdoCivil+Educación+
                Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

Segunda forma:

modelo1.7<-lm(log(SalarioHora)~Género*EdoCivil+Educación+
                Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

Tercera forma (actualización)

modelo1.7<- update(modelo1.4,.~.+Género:EdoCivil)

El resultado es el siguiente:

salida.modelo1.7<- data.frame(xtable(summary(modelo1.7))) #Resumen del modelo 1.7
kable(salida.modelo1.7, caption="Ecuación de Salario con interacción entre regresoras categóricas")
Ecuación de Salario con interacción entre regresoras categóricas
Estimate Std..Error t.value Pr…t..
(Intercept) 0.3213781 0.1000090 3.213492 0.0013931
GéneroMujer -0.1103502 0.0557421 -1.979658 0.0482719
Educación 0.0789103 0.0066945 11.787333 0.0000000
EdoCivilCasad@ 0.2126757 0.0553572 3.841881 0.0001373
Experiencia 0.0268006 0.0052428 5.111835 0.0000004
I(Experiencia^2) -0.0005352 0.0001104 -4.847105 0.0000017
Antiguedad 0.0290875 0.0067620 4.301614 0.0000203
I(Antiguedad^2) -0.0005331 0.0002312 -2.305553 0.0215306
GéneroMujer:EdoCivilCasad@ -0.3005931 0.0717669 -4.188461 0.0000330

Podemos considerar pendientes distintas:

modelo1.8<-lm(log(SalarioHora)~Género+Género:Educación+Educación+
                Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

modelo1.8<- lm(log(SalarioHora)~Género*Educación,data=datos)

stargazer(modelo1.8,type = "text")
## 
## =================================================
##                           Dependent variable:    
##                       ---------------------------
##                            log(SalarioHora)      
## -------------------------------------------------
## GéneroMujer                     -0.360*          
##                                 (0.185)          
##                                                  
## Educación                      0.077***          
##                                 (0.009)          
##                                                  
## GéneroMujer:Educación           -0.0001          
##                                 (0.015)          
##                                                  
## Constant                       0.826***          
##                                 (0.118)          
##                                                  
## -------------------------------------------------
## Observations                      526            
## R2                               0.300           
## Adjusted R2                      0.296           
## Residual Std. Error        0.446 (df = 522)      
## F Statistic             74.649*** (df = 3; 522)  
## =================================================
## Note:                 *p<0.1; **p<0.05; ***p<0.01

Y calcular los interceptos especificos por genero:

interceptos <- c(coef(modelo1.8)["(Intercept)"],  #intercepto de hombres
                 coef(modelo1.8)["(Intercept)"] + coef(modelo1.8)["GéneroMujer"])

Calculamos las pendientes específicos de la Educación según el género:

pendientes<- c(coef(modelo1.8)["Educación"],  #Pendiente de hombres
                 coef(modelo1.8)["Educación"] + coef(modelo1.8)["GéneroMujer:Educación"]) #Pendiente de mujeres

rectas.df<- data.frame(interceptos = interceptos,
                       pendientes = pendientes,
                       Género = levels(datos$Género))

qplot(x = Educación, y = log(SalarioHora), color = Género, data = datos) + 
  geom_abline(aes(intercept = interceptos, 
                  slope = pendientes, 
                  color = Género), data = rectas.df)

O alternativamente podemos:

qplot(x = Educación, y = log(SalarioHora) , color = Género, data = datos) +
  stat_smooth(method = "lm", se = FALSE, fullrange = F)
## `geom_smooth()` using formula 'y ~ x'

#Otra forma alternativa es
ggplot(datos, aes(x =Educación, y = log(SalarioHora), colour = Género)) + geom_point() +
  stat_smooth(method = "lm", formula = y ~ x, se = FALSE)

Ejemplo: efecto de la raza sobre los sueldos de los jugadores de beisbol:

modelo<-lm(SalarioHora~Género+Educación+ Experiencia+Educación:Experiencia,data = datos)

modelo<-lm(log(SalarioHora)~Género+Educación+Educación:Experiencia+
                Experiencia+I(Experiencia^2)+Antiguedad+I(Antiguedad^2),data = datos)

modelo<-lm(log(SalarioHora)~Educación+Educación:Experiencia+
             Experiencia+I(Experiencia^2),data = datos)

modelo<-lm(log(SalarioHora)~Educación+Educación:Experiencia+
             Experiencia,data = datos)


salida.modelo<- data.frame(xtable(summary(modelo)))
kable(salida.modelo, caption="Ecuación de Salario con interacción y términos cuadráticos")
Ecuación de Salario con interacción y términos cuadráticos
Estimate Std..Error t.value Pr…t..
(Intercept) 0.1532232 0.1673326 0.9156805 0.3602573
Educación 0.1030365 0.0127368 8.0896528 0.0000000
Experiencia 0.0132641 0.0060374 2.1969857 0.0284602
Educación:Experiencia -0.0002473 0.0004945 -0.5000819 0.6172282

Ploteamos nuestros resultados:

library(jtools)
## Warning: package 'jtools' was built under R version 4.0.5
## 
## Attaching package: 'jtools'
## The following object is masked from 'package:Hmisc':
## 
##     %nin%
library(interactions)
## Warning: package 'interactions' was built under R version 4.0.5
interact_plot(modelo, pred =Educación, modx =Experiencia,
              plot.points = TRUE,main.title="Interacción Educ*Exp",data = datos)

Plot sin nube de puntos:

interact_plot(modelo, pred = Experiencia, modx =Educación,plot.points =F,data = datos)

Plot con los puntos de datos:

interact_plot(modelo, pred = Experiencia, modx =Educación,
              plot.points = TRUE,main.title="Interacción Educ*Exp",data = datos)