Data preparation 2

Changes in the Justification of Pension Inequality in Chile (2016–2023) and its Relationship to Social Class and Beliefs in Meritocracy

Author

René Canales & Andreas Laffert

Published

December 8, 2025

1 Presentation

This is the data preparation code for the paper “Changes in the Justification of Pension Inequality in Chile (2016–2023) and its Relationship to Social Class and Beliefs in Meritocracy”. The prepared dataset is ELSOC_Long_2016_2023_1.00.RData.

2 Libraries

if (! require("pacman")) install.packages("pacman")

pacman::p_load(tidyverse,
               car,
               sjmisc, 
               here,
               sjlabelled,
               SciViews,
               naniar,
               readxl,
               sjPlot,
               DIGCLASS)


options(scipen=999)
rm(list = ls())

3 Data

load(url("https://dataverse.harvard.edu/api/access/datafile/10797987"))

glimpse(elsoc_long_2016_2023)

4 Processing

elsoc_long_2016_2023[elsoc_long_2016_2023 ==-999] <- NA
elsoc_long_2016_2023[elsoc_long_2016_2023 ==-888] <- NA
elsoc_long_2016_2023[elsoc_long_2016_2023 ==-777] <- NA
elsoc_long_2016_2023[elsoc_long_2016_2023 ==-666] <- NA

elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(just_pension = d02_01, 
         merit_effort = c18_09,
         merit_talent = c18_10, 
         age = m0_edad, m01, 
         sex = m0_sexo, 
         ideo = c15) %>% 
  as_tibble() %>% 
  sjlabelled::drop_labels(., drop.na = FALSE)
# Market Justice Preferences

frq(elsoc_long_2016_2023$just_pension)
Grado de acuerdo: Justicia distributiva en pensiones (x) <numeric> 
# total N=20761 valid N=17966 mean=2.24 sd=1.11

Value |                          Label |    N | Raw % | Valid % | Cum. %
------------------------------------------------------------------------
    1 |       Totalmente en desacuerdo | 4889 | 23.55 |   27.21 |  27.21
    2 |                  En desacuerdo | 7802 | 37.58 |   43.43 |  70.64
    3 | Ni de acuerdo ni en desacuerdo | 1740 |  8.38 |    9.68 |  80.32
    4 |                     De acuerdo | 3087 | 14.87 |   17.18 |  97.51
    5 |          Totalmente de acuerdo |  448 |  2.16 |    2.49 | 100.00
 <NA> |                           <NA> | 2795 | 13.46 |    <NA> |   <NA>
elsoc_long_2016_2023$just_pension <- car::recode(elsoc_long_2016_2023$just_pension, 
recodes = c("1='Strongly disagree'; 2='Disagree'; 3='Neither agree nor disagree'; 4='Agree'; 5='Strongly agree'"), 
levels = c("Strongly disagree", "Disagree", "Neither agree nor disagree", "Agree", "Strongly agree"),
as.factor = T)
                                                 
elsoc_long_2016_2023$just_pension <- sjlabelled::set_label(elsoc_long_2016_2023$just_pension, 
                        label = "Pension distributive justice")
# Social class scheme EGP

# ISCO 08 

frq(elsoc_long_2016_2023$ciuo88_m03)
CIUO (1988) del entrevistado (x) <numeric> 
# total N=20761 valid N=1801 mean=5720.01 sd=2420.11

Value |     N | Raw % | Valid % | Cum. %
----------------------------------------
 1229 |     1 |  0.00 |    0.06 |   0.06
 1232 |     1 |  0.00 |    0.06 |   0.11
 1239 |     1 |  0.00 |    0.06 |   0.17
 1252 |     1 |  0.00 |    0.06 |   0.22
 1312 |     3 |  0.01 |    0.17 |   0.39
 1313 |     2 |  0.01 |    0.11 |   0.50
 1314 |    52 |  0.25 |    2.89 |   3.39
 1315 |     8 |  0.04 |    0.44 |   3.83
 1316 |     2 |  0.01 |    0.11 |   3.94
 1317 |     7 |  0.03 |    0.39 |   4.33
 1318 |     1 |  0.00 |    0.06 |   4.39
 1319 |     3 |  0.01 |    0.17 |   4.55
 2114 |     2 |  0.01 |    0.11 |   4.66
 2122 |     1 |  0.00 |    0.06 |   4.72
 2131 |     5 |  0.02 |    0.28 |   5.00
 2132 |     1 |  0.00 |    0.06 |   5.05
 2141 |     5 |  0.02 |    0.28 |   5.33
 2142 |     4 |  0.02 |    0.22 |   5.55
 2143 |     3 |  0.01 |    0.17 |   5.72
 2146 |     1 |  0.00 |    0.06 |   5.77
 2147 |     2 |  0.01 |    0.11 |   5.89
 2149 |    19 |  0.09 |    1.05 |   6.94
 2211 |     2 |  0.01 |    0.11 |   7.05
 2213 |     2 |  0.01 |    0.11 |   7.16
 2221 |     3 |  0.01 |    0.17 |   7.33
 2222 |     2 |  0.01 |    0.11 |   7.44
 2223 |     1 |  0.00 |    0.06 |   7.50
 2229 |     2 |  0.01 |    0.11 |   7.61
 2230 |     8 |  0.04 |    0.44 |   8.05
 2310 |    10 |  0.05 |    0.56 |   8.61
 2320 |    10 |  0.05 |    0.56 |   9.16
 2331 |    32 |  0.15 |    1.78 |  10.94
 2332 |     7 |  0.03 |    0.39 |  11.33
 2340 |     3 |  0.01 |    0.17 |  11.49
 2359 |     3 |  0.01 |    0.17 |  11.66
 2411 |    12 |  0.06 |    0.67 |  12.33
 2412 |     1 |  0.00 |    0.06 |  12.38
 2419 |     6 |  0.03 |    0.33 |  12.72
 2421 |     5 |  0.02 |    0.28 |  12.99
 2429 |     2 |  0.01 |    0.11 |  13.10
 2432 |     5 |  0.02 |    0.28 |  13.38
 2441 |     1 |  0.00 |    0.06 |  13.44
 2442 |     1 |  0.00 |    0.06 |  13.49
 2445 |    10 |  0.05 |    0.56 |  14.05
 2446 |     8 |  0.04 |    0.44 |  14.49
 2451 |     4 |  0.02 |    0.22 |  14.71
 2452 |     1 |  0.00 |    0.06 |  14.77
 2455 |     1 |  0.00 |    0.06 |  14.83
 2460 |     1 |  0.00 |    0.06 |  14.88
 3112 |     7 |  0.03 |    0.39 |  15.27
 3114 |     2 |  0.01 |    0.11 |  15.38
 3118 |     1 |  0.00 |    0.06 |  15.44
 3121 |     6 |  0.03 |    0.33 |  15.77
 3131 |     2 |  0.01 |    0.11 |  15.88
 3132 |     1 |  0.00 |    0.06 |  15.94
 3152 |     9 |  0.04 |    0.50 |  16.44
 3212 |     4 |  0.02 |    0.22 |  16.66
 3213 |     2 |  0.01 |    0.11 |  16.77
 3221 |     5 |  0.02 |    0.28 |  17.05
 3222 |     2 |  0.01 |    0.11 |  17.16
 3223 |     4 |  0.02 |    0.22 |  17.38
 3225 |     3 |  0.01 |    0.17 |  17.55
 3226 |     3 |  0.01 |    0.17 |  17.71
 3229 |     2 |  0.01 |    0.11 |  17.82
 3231 |    17 |  0.08 |    0.94 |  18.77
 3310 |     1 |  0.00 |    0.06 |  18.82
 3320 |    10 |  0.05 |    0.56 |  19.38
 3330 |     2 |  0.01 |    0.11 |  19.49
 3340 |     4 |  0.02 |    0.22 |  19.71
 3411 |    10 |  0.05 |    0.56 |  20.27
 3412 |     4 |  0.02 |    0.22 |  20.49
 3413 |     5 |  0.02 |    0.28 |  20.77
 3415 |    13 |  0.06 |    0.72 |  21.49
 3416 |     2 |  0.01 |    0.11 |  21.60
 3417 |     1 |  0.00 |    0.06 |  21.65
 3419 |     2 |  0.01 |    0.11 |  21.77
 3422 |     2 |  0.01 |    0.11 |  21.88
 3423 |     8 |  0.04 |    0.44 |  22.32
 3432 |     1 |  0.00 |    0.06 |  22.38
 3433 |    14 |  0.07 |    0.78 |  23.15
 3441 |     1 |  0.00 |    0.06 |  23.21
 3449 |     1 |  0.00 |    0.06 |  23.26
 3452 |     2 |  0.01 |    0.11 |  23.38
 3471 |     4 |  0.02 |    0.22 |  23.60
 3472 |     2 |  0.01 |    0.11 |  23.71
 3473 |     5 |  0.02 |    0.28 |  23.99
 3474 |     1 |  0.00 |    0.06 |  24.04
 3475 |     4 |  0.02 |    0.22 |  24.26
 4113 |     2 |  0.01 |    0.11 |  24.38
 4115 |    49 |  0.24 |    2.72 |  27.10
 4121 |     4 |  0.02 |    0.22 |  27.32
 4122 |     5 |  0.02 |    0.28 |  27.60
 4131 |    27 |  0.13 |    1.50 |  29.09
 4132 |     6 |  0.03 |    0.33 |  29.43
 4133 |     4 |  0.02 |    0.22 |  29.65
 4142 |     2 |  0.01 |    0.11 |  29.76
 4190 |    56 |  0.27 |    3.11 |  32.87
 4211 |    22 |  0.11 |    1.22 |  34.09
 4215 |     2 |  0.01 |    0.11 |  34.20
 4222 |    12 |  0.06 |    0.67 |  34.87
 4223 |     4 |  0.02 |    0.22 |  35.09
 5112 |     1 |  0.00 |    0.06 |  35.15
 5121 |     3 |  0.01 |    0.17 |  35.31
 5122 |    56 |  0.27 |    3.11 |  38.42
 5123 |    20 |  0.10 |    1.11 |  39.53
 5131 |    39 |  0.19 |    2.17 |  41.70
 5132 |     6 |  0.03 |    0.33 |  42.03
 5133 |    10 |  0.05 |    0.56 |  42.59
 5141 |    21 |  0.10 |    1.17 |  43.75
 5142 |     1 |  0.00 |    0.06 |  43.81
 5162 |    12 |  0.06 |    0.67 |  44.48
 5163 |     2 |  0.01 |    0.11 |  44.59
 5164 |     6 |  0.03 |    0.33 |  44.92
 5169 |     4 |  0.02 |    0.22 |  45.14
 5220 |   141 |  0.68 |    7.83 |  52.97
 5230 |    36 |  0.17 |    2.00 |  54.97
 6111 |     5 |  0.02 |    0.28 |  55.25
 6112 |    11 |  0.05 |    0.61 |  55.86
 6113 |    17 |  0.08 |    0.94 |  56.80
 6124 |     1 |  0.00 |    0.06 |  56.86
 6141 |     6 |  0.03 |    0.33 |  57.19
 6152 |     1 |  0.00 |    0.06 |  57.25
 7111 |     5 |  0.02 |    0.28 |  57.52
 7112 |     1 |  0.00 |    0.06 |  57.58
 7122 |    27 |  0.13 |    1.50 |  59.08
 7123 |     5 |  0.02 |    0.28 |  59.36
 7124 |    41 |  0.20 |    2.28 |  61.63
 7129 |    11 |  0.05 |    0.61 |  62.24
 7134 |     2 |  0.01 |    0.11 |  62.35
 7135 |     1 |  0.00 |    0.06 |  62.41
 7136 |    10 |  0.05 |    0.56 |  62.97
 7137 |    18 |  0.09 |    1.00 |  63.96
 7141 |    14 |  0.07 |    0.78 |  64.74
 7142 |     8 |  0.04 |    0.44 |  65.19
 7212 |    23 |  0.11 |    1.28 |  66.46
 7213 |    10 |  0.05 |    0.56 |  67.02
 7221 |     1 |  0.00 |    0.06 |  67.07
 7224 |     1 |  0.00 |    0.06 |  67.13
 7231 |    27 |  0.13 |    1.50 |  68.63
 7233 |    15 |  0.07 |    0.83 |  69.46
 7241 |     3 |  0.01 |    0.17 |  69.63
 7242 |     4 |  0.02 |    0.22 |  69.85
 7243 |     1 |  0.00 |    0.06 |  69.91
 7244 |     2 |  0.01 |    0.11 |  70.02
 7245 |     1 |  0.00 |    0.06 |  70.07
 7311 |     3 |  0.01 |    0.17 |  70.24
 7313 |     1 |  0.00 |    0.06 |  70.29
 7322 |     1 |  0.00 |    0.06 |  70.35
 7343 |     1 |  0.00 |    0.06 |  70.41
 7344 |     1 |  0.00 |    0.06 |  70.46
 7345 |     1 |  0.00 |    0.06 |  70.52
 7411 |    12 |  0.06 |    0.67 |  71.18
 7412 |    27 |  0.13 |    1.50 |  72.68
 7413 |     1 |  0.00 |    0.06 |  72.74
 7415 |     3 |  0.01 |    0.17 |  72.90
 7421 |     2 |  0.01 |    0.11 |  73.01
 7422 |    16 |  0.08 |    0.89 |  73.90
 7432 |     3 |  0.01 |    0.17 |  74.07
 7433 |    16 |  0.08 |    0.89 |  74.96
 7436 |    16 |  0.08 |    0.89 |  75.85
 7437 |     1 |  0.00 |    0.06 |  75.90
 7442 |     3 |  0.01 |    0.17 |  76.07
 8112 |     1 |  0.00 |    0.06 |  76.12
 8121 |     1 |  0.00 |    0.06 |  76.18
 8124 |     1 |  0.00 |    0.06 |  76.24
 8141 |     4 |  0.02 |    0.22 |  76.46
 8143 |     1 |  0.00 |    0.06 |  76.51
 8159 |     1 |  0.00 |    0.06 |  76.57
 8163 |     2 |  0.01 |    0.11 |  76.68
 8211 |     4 |  0.02 |    0.22 |  76.90
 8221 |     2 |  0.01 |    0.11 |  77.01
 8232 |     4 |  0.02 |    0.22 |  77.23
 8240 |     1 |  0.00 |    0.06 |  77.29
 8251 |     3 |  0.01 |    0.17 |  77.46
 8264 |     1 |  0.00 |    0.06 |  77.51
 8272 |     1 |  0.00 |    0.06 |  77.57
 8275 |     1 |  0.00 |    0.06 |  77.62
 8276 |     1 |  0.00 |    0.06 |  77.68
 8311 |     2 |  0.01 |    0.11 |  77.79
 8322 |    35 |  0.17 |    1.94 |  79.73
 8323 |    23 |  0.11 |    1.28 |  81.01
 8324 |    26 |  0.13 |    1.44 |  82.45
 8331 |     9 |  0.04 |    0.50 |  82.95
 8332 |    10 |  0.05 |    0.56 |  83.51
 8333 |     1 |  0.00 |    0.06 |  83.56
 8334 |     5 |  0.02 |    0.28 |  83.84
 8340 |     3 |  0.01 |    0.17 |  84.01
 9111 |     3 |  0.01 |    0.17 |  84.18
 9112 |    14 |  0.07 |    0.78 |  84.95
 9131 |    80 |  0.39 |    4.44 |  89.39
 9132 |    71 |  0.34 |    3.94 |  93.34
 9133 |     2 |  0.01 |    0.11 |  93.45
 9141 |     8 |  0.04 |    0.44 |  93.89
 9142 |     1 |  0.00 |    0.06 |  93.95
 9151 |     4 |  0.02 |    0.22 |  94.17
 9152 |    47 |  0.23 |    2.61 |  96.78
 9153 |     3 |  0.01 |    0.17 |  96.95
 9161 |     1 |  0.00 |    0.06 |  97.00
 9162 |     2 |  0.01 |    0.11 |  97.11
 9211 |    15 |  0.07 |    0.83 |  97.95
 9312 |     1 |  0.00 |    0.06 |  98.00
 9313 |    14 |  0.07 |    0.78 |  98.78
 9322 |     3 |  0.01 |    0.17 |  98.95
 9333 |     9 |  0.04 |    0.50 |  99.44
 9955 |     1 |  0.00 |    0.06 |  99.50
 9988 |     1 |  0.00 |    0.06 |  99.56
 9999 |     8 |  0.04 |    0.44 | 100.00
 <NA> | 18960 | 91.33 |    <NA> |   <NA>
elsoc_long_2016_2023 %>%
  group_by(ola) %>%
  summarise(
    solo_NA = all(is.na(ciuo88_m03))
  ) # only wave 2016
# A tibble: 7 × 2
    ola solo_NA
  <dbl> <lgl>  
1     1 FALSE  
2     2 TRUE   
3     3 TRUE   
4     4 TRUE   
5     5 TRUE   
6     6 TRUE   
7     7 TRUE   
frq(elsoc_long_2016_2023$ciuo08_m03)
CIUO (2008) del entrevistado (x) <numeric> 
# total N=20761 valid N=5530 mean=5745.24 sd=2469.60

Value |     N | Raw % | Valid % | Cum. %
----------------------------------------
  110 |     9 |  0.04 |    0.16 |   0.16
  210 |     9 |  0.04 |    0.16 |   0.33
  310 |     6 |  0.03 |    0.11 |   0.43
 1112 |     6 |  0.03 |    0.11 |   0.54
 1113 |     1 |  0.00 |    0.02 |   0.56
 1114 |     4 |  0.02 |    0.07 |   0.63
 1120 |     6 |  0.03 |    0.11 |   0.74
 1211 |     3 |  0.01 |    0.05 |   0.80
 1212 |     9 |  0.04 |    0.16 |   0.96
 1213 |     1 |  0.00 |    0.02 |   0.98
 1219 |     1 |  0.00 |    0.02 |   0.99
 1221 |     4 |  0.02 |    0.07 |   1.07
 1222 |     2 |  0.01 |    0.04 |   1.10
 1311 |     2 |  0.01 |    0.04 |   1.14
 1321 |     5 |  0.02 |    0.09 |   1.23
 1322 |     1 |  0.00 |    0.02 |   1.25
 1323 |     3 |  0.01 |    0.05 |   1.30
 1324 |     9 |  0.04 |    0.16 |   1.46
 1330 |     1 |  0.00 |    0.02 |   1.48
 1341 |     1 |  0.00 |    0.02 |   1.50
 1342 |     3 |  0.01 |    0.05 |   1.56
 1344 |     1 |  0.00 |    0.02 |   1.57
 1345 |     4 |  0.02 |    0.07 |   1.65
 1346 |     4 |  0.02 |    0.07 |   1.72
 1349 |     3 |  0.01 |    0.05 |   1.77
 1411 |     4 |  0.02 |    0.07 |   1.84
 1412 |    20 |  0.10 |    0.36 |   2.21
 1420 |    27 |  0.13 |    0.49 |   2.69
 1431 |     3 |  0.01 |    0.05 |   2.75
 1439 |     8 |  0.04 |    0.14 |   2.89
 2113 |     4 |  0.02 |    0.07 |   2.97
 2114 |     3 |  0.01 |    0.05 |   3.02
 2131 |     7 |  0.03 |    0.13 |   3.15
 2132 |     8 |  0.04 |    0.14 |   3.29
 2133 |     4 |  0.02 |    0.07 |   3.36
 2139 |     1 |  0.00 |    0.02 |   3.38
 2141 |     4 |  0.02 |    0.07 |   3.45
 2142 |    15 |  0.07 |    0.27 |   3.73
 2143 |     3 |  0.01 |    0.05 |   3.78
 2144 |     7 |  0.03 |    0.13 |   3.91
 2145 |     4 |  0.02 |    0.07 |   3.98
 2146 |    10 |  0.05 |    0.18 |   4.16
 2149 |    28 |  0.13 |    0.51 |   4.67
 2151 |     5 |  0.02 |    0.09 |   4.76
 2152 |     3 |  0.01 |    0.05 |   4.81
 2153 |     2 |  0.01 |    0.04 |   4.85
 2161 |    15 |  0.07 |    0.27 |   5.12
 2162 |     1 |  0.00 |    0.02 |   5.14
 2163 |     2 |  0.01 |    0.04 |   5.17
 2164 |     2 |  0.01 |    0.04 |   5.21
 2165 |     1 |  0.00 |    0.02 |   5.23
 2166 |     4 |  0.02 |    0.07 |   5.30
 2211 |     2 |  0.01 |    0.04 |   5.33
 2212 |    11 |  0.05 |    0.20 |   5.53
 2213 |     1 |  0.00 |    0.02 |   5.55
 2221 |    26 |  0.13 |    0.47 |   6.02
 2222 |     1 |  0.00 |    0.02 |   6.04
 2230 |     4 |  0.02 |    0.07 |   6.11
 2240 |     4 |  0.02 |    0.07 |   6.18
 2241 |     4 |  0.02 |    0.07 |   6.26
 2242 |     2 |  0.01 |    0.04 |   6.29
 2243 |     8 |  0.04 |    0.14 |   6.44
 2244 |     6 |  0.03 |    0.11 |   6.55
 2245 |     3 |  0.01 |    0.05 |   6.60
 2250 |     3 |  0.01 |    0.05 |   6.65
 2261 |     7 |  0.03 |    0.13 |   6.78
 2262 |     1 |  0.00 |    0.02 |   6.80
 2263 |     4 |  0.02 |    0.07 |   6.87
 2264 |     4 |  0.02 |    0.07 |   6.94
 2265 |     5 |  0.02 |    0.09 |   7.03
 2266 |     5 |  0.02 |    0.09 |   7.12
 2269 |     1 |  0.00 |    0.02 |   7.14
 2300 |     1 |  0.00 |    0.02 |   7.16
 2310 |    25 |  0.12 |    0.45 |   7.61
 2320 |     6 |  0.03 |    0.11 |   7.72
 2330 |    59 |  0.28 |    1.07 |   8.79
 2341 |    78 |  0.38 |    1.41 |  10.20
 2342 |    41 |  0.20 |    0.74 |  10.94
 2351 |     7 |  0.03 |    0.13 |  11.07
 2352 |    22 |  0.11 |    0.40 |  11.46
 2353 |     1 |  0.00 |    0.02 |  11.48
 2356 |     2 |  0.01 |    0.04 |  11.52
 2359 |    33 |  0.16 |    0.60 |  12.12
 2411 |    44 |  0.21 |    0.80 |  12.91
 2412 |     3 |  0.01 |    0.05 |  12.97
 2413 |     8 |  0.04 |    0.14 |  13.11
 2421 |     7 |  0.03 |    0.13 |  13.24
 2422 |     9 |  0.04 |    0.16 |  13.40
 2423 |    11 |  0.05 |    0.20 |  13.60
 2424 |     1 |  0.00 |    0.02 |  13.62
 2431 |     9 |  0.04 |    0.16 |  13.78
 2433 |     8 |  0.04 |    0.14 |  13.92
 2434 |     6 |  0.03 |    0.11 |  14.03
 2511 |     3 |  0.01 |    0.05 |  14.09
 2512 |    12 |  0.06 |    0.22 |  14.30
 2513 |     4 |  0.02 |    0.07 |  14.38
 2514 |     1 |  0.00 |    0.02 |  14.39
 2519 |     3 |  0.01 |    0.05 |  14.45
 2521 |     3 |  0.01 |    0.05 |  14.50
 2522 |     3 |  0.01 |    0.05 |  14.56
 2523 |     3 |  0.01 |    0.05 |  14.61
 2529 |     7 |  0.03 |    0.13 |  14.74
 2611 |    22 |  0.11 |    0.40 |  15.14
 2619 |     3 |  0.01 |    0.05 |  15.19
 2621 |     1 |  0.00 |    0.02 |  15.21
 2622 |     5 |  0.02 |    0.09 |  15.30
 2630 |     1 |  0.00 |    0.02 |  15.32
 2631 |     4 |  0.02 |    0.07 |  15.39
 2632 |     6 |  0.03 |    0.11 |  15.50
 2634 |    35 |  0.17 |    0.63 |  16.13
 2635 |    23 |  0.11 |    0.42 |  16.55
 2636 |     1 |  0.00 |    0.02 |  16.56
 2641 |     2 |  0.01 |    0.04 |  16.60
 2642 |    12 |  0.06 |    0.22 |  16.82
 2652 |     6 |  0.03 |    0.11 |  16.93
 2654 |     1 |  0.00 |    0.02 |  16.94
 2655 |     2 |  0.01 |    0.04 |  16.98
 2656 |     1 |  0.00 |    0.02 |  17.00
 2659 |     3 |  0.01 |    0.05 |  17.05
 3111 |     5 |  0.02 |    0.09 |  17.14
 3112 |    10 |  0.05 |    0.18 |  17.32
 3113 |     2 |  0.01 |    0.04 |  17.36
 3114 |     9 |  0.04 |    0.16 |  17.52
 3116 |     2 |  0.01 |    0.04 |  17.56
 3117 |     2 |  0.01 |    0.04 |  17.59
 3118 |     4 |  0.02 |    0.07 |  17.67
 3119 |     3 |  0.01 |    0.05 |  17.72
 3121 |     6 |  0.03 |    0.11 |  17.83
 3122 |     8 |  0.04 |    0.14 |  17.97
 3123 |    30 |  0.14 |    0.54 |  18.52
 3132 |     8 |  0.04 |    0.14 |  18.66
 3133 |     1 |  0.00 |    0.02 |  18.68
 3134 |     2 |  0.01 |    0.04 |  18.72
 3135 |     1 |  0.00 |    0.02 |  18.73
 3139 |     3 |  0.01 |    0.05 |  18.79
 3141 |     1 |  0.00 |    0.02 |  18.81
 3142 |     3 |  0.01 |    0.05 |  18.86
 3143 |     3 |  0.01 |    0.05 |  18.92
 3144 |     1 |  0.00 |    0.02 |  18.93
 3152 |     1 |  0.00 |    0.02 |  18.95
 3154 |     3 |  0.01 |    0.05 |  19.01
 3155 |     1 |  0.00 |    0.02 |  19.02
 3211 |    12 |  0.06 |    0.22 |  19.24
 3212 |     2 |  0.01 |    0.04 |  19.28
 3213 |     5 |  0.02 |    0.09 |  19.37
 3214 |     1 |  0.00 |    0.02 |  19.39
 3215 |     2 |  0.01 |    0.04 |  19.42
 3221 |    63 |  0.30 |    1.14 |  20.56
 3231 |     1 |  0.00 |    0.02 |  20.58
 3251 |    16 |  0.08 |    0.29 |  20.87
 3252 |     1 |  0.00 |    0.02 |  20.89
 3253 |     5 |  0.02 |    0.09 |  20.98
 3254 |     1 |  0.00 |    0.02 |  20.99
 3255 |     2 |  0.01 |    0.04 |  21.03
 3256 |     4 |  0.02 |    0.07 |  21.10
 3257 |    10 |  0.05 |    0.18 |  21.28
 3259 |     7 |  0.03 |    0.13 |  21.41
 3311 |     7 |  0.03 |    0.13 |  21.54
 3312 |     6 |  0.03 |    0.11 |  21.65
 3313 |    10 |  0.05 |    0.18 |  21.83
 3314 |     5 |  0.02 |    0.09 |  21.92
 3315 |     3 |  0.01 |    0.05 |  21.97
 3321 |    16 |  0.08 |    0.29 |  22.26
 3322 |    11 |  0.05 |    0.20 |  22.46
 3323 |     5 |  0.02 |    0.09 |  22.55
 3324 |     1 |  0.00 |    0.02 |  22.57
 3331 |     3 |  0.01 |    0.05 |  22.62
 3332 |     7 |  0.03 |    0.13 |  22.75
 3333 |     9 |  0.04 |    0.16 |  22.91
 3334 |    19 |  0.09 |    0.34 |  23.25
 3339 |     3 |  0.01 |    0.05 |  23.31
 3341 |     7 |  0.03 |    0.13 |  23.44
 3342 |     4 |  0.02 |    0.07 |  23.51
 3343 |    41 |  0.20 |    0.74 |  24.25
 3344 |     8 |  0.04 |    0.14 |  24.39
 3352 |     7 |  0.03 |    0.13 |  24.52
 3353 |     3 |  0.01 |    0.05 |  24.58
 3354 |     4 |  0.02 |    0.07 |  24.65
 3359 |     8 |  0.04 |    0.14 |  24.79
 3411 |     8 |  0.04 |    0.14 |  24.94
 3412 |     5 |  0.02 |    0.09 |  25.03
 3422 |     9 |  0.04 |    0.16 |  25.19
 3423 |     2 |  0.01 |    0.04 |  25.23
 3431 |     6 |  0.03 |    0.11 |  25.33
 3432 |     5 |  0.02 |    0.09 |  25.42
 3434 |     7 |  0.03 |    0.13 |  25.55
 3435 |     3 |  0.01 |    0.05 |  25.61
 3511 |     1 |  0.00 |    0.02 |  25.62
 3512 |     5 |  0.02 |    0.09 |  25.71
 3513 |    10 |  0.05 |    0.18 |  25.90
 3521 |     1 |  0.00 |    0.02 |  25.91
 3522 |     2 |  0.01 |    0.04 |  25.95
 3611 |    22 |  0.11 |    0.40 |  26.35
 3612 |     1 |  0.00 |    0.02 |  26.37
 4110 |    64 |  0.31 |    1.16 |  27.52
 4120 |    42 |  0.20 |    0.76 |  28.28
 4121 |     1 |  0.00 |    0.02 |  28.30
 4131 |     2 |  0.01 |    0.04 |  28.34
 4132 |     2 |  0.01 |    0.04 |  28.37
 4190 |     1 |  0.00 |    0.02 |  28.39
 4211 |    18 |  0.09 |    0.33 |  28.72
 4212 |     1 |  0.00 |    0.02 |  28.73
 4214 |     8 |  0.04 |    0.14 |  28.88
 4221 |     1 |  0.00 |    0.02 |  28.90
 4222 |     2 |  0.01 |    0.04 |  28.93
 4223 |    16 |  0.08 |    0.29 |  29.22
 4224 |     3 |  0.01 |    0.05 |  29.28
 4225 |     2 |  0.01 |    0.04 |  29.31
 4226 |    18 |  0.09 |    0.33 |  29.64
 4227 |     6 |  0.03 |    0.11 |  29.75
 4229 |     6 |  0.03 |    0.11 |  29.86
 4310 |     1 |  0.00 |    0.02 |  29.87
 4311 |    45 |  0.22 |    0.81 |  30.69
 4312 |     6 |  0.03 |    0.11 |  30.80
 4313 |     5 |  0.02 |    0.09 |  30.89
 4321 |    69 |  0.33 |    1.25 |  32.13
 4322 |     6 |  0.03 |    0.11 |  32.24
 4323 |    19 |  0.09 |    0.34 |  32.59
 4411 |     2 |  0.01 |    0.04 |  32.62
 4412 |     3 |  0.01 |    0.05 |  32.68
 4415 |     2 |  0.01 |    0.04 |  32.71
 4416 |    13 |  0.06 |    0.24 |  32.95
 4419 |    41 |  0.20 |    0.74 |  33.69
 4791 |     1 |  0.00 |    0.02 |  33.71
 5112 |     3 |  0.01 |    0.05 |  33.76
 5120 |   123 |  0.59 |    2.22 |  35.99
 5131 |    48 |  0.23 |    0.87 |  36.85
 5132 |     4 |  0.02 |    0.07 |  36.93
 5141 |    49 |  0.24 |    0.89 |  37.81
 5142 |    20 |  0.10 |    0.36 |  38.17
 5151 |     5 |  0.02 |    0.09 |  38.26
 5152 |     4 |  0.02 |    0.07 |  38.34
 5153 |    29 |  0.14 |    0.52 |  38.86
 5161 |     2 |  0.01 |    0.04 |  38.90
 5163 |     3 |  0.01 |    0.05 |  38.95
 5164 |     2 |  0.01 |    0.04 |  38.99
 5211 |    98 |  0.47 |    1.77 |  40.76
 5212 |    31 |  0.15 |    0.56 |  41.32
 5221 |   192 |  0.92 |    3.47 |  44.79
 5222 |    23 |  0.11 |    0.42 |  45.21
 5223 |   202 |  0.97 |    3.65 |  48.86
 5230 |    67 |  0.32 |    1.21 |  50.07
 5242 |    12 |  0.06 |    0.22 |  50.29
 5243 |     7 |  0.03 |    0.13 |  50.42
 5244 |    16 |  0.08 |    0.29 |  50.71
 5245 |     6 |  0.03 |    0.11 |  50.81
 5246 |     5 |  0.02 |    0.09 |  50.90
 5249 |    16 |  0.08 |    0.29 |  51.19
 5311 |    35 |  0.17 |    0.63 |  51.83
 5312 |    84 |  0.40 |    1.52 |  53.35
 5321 |    13 |  0.06 |    0.24 |  53.58
 5322 |    44 |  0.21 |    0.80 |  54.38
 5329 |     6 |  0.03 |    0.11 |  54.48
 5411 |     6 |  0.03 |    0.11 |  54.59
 5412 |    14 |  0.07 |    0.25 |  54.85
 5413 |     5 |  0.02 |    0.09 |  54.94
 5414 |   127 |  0.61 |    2.30 |  57.23
 5419 |     5 |  0.02 |    0.09 |  57.32
 6110 |     1 |  0.00 |    0.02 |  57.34
 6111 |    10 |  0.05 |    0.18 |  57.52
 6112 |     5 |  0.02 |    0.09 |  57.61
 6113 |    33 |  0.16 |    0.60 |  58.21
 6122 |     2 |  0.01 |    0.04 |  58.25
 6123 |     1 |  0.00 |    0.02 |  58.26
 6129 |     1 |  0.00 |    0.02 |  58.28
 6151 |     1 |  0.00 |    0.02 |  58.30
 6152 |     1 |  0.00 |    0.02 |  58.32
 6210 |     6 |  0.03 |    0.11 |  58.43
 6221 |     5 |  0.02 |    0.09 |  58.52
 6222 |     4 |  0.02 |    0.07 |  58.59
 6223 |     1 |  0.00 |    0.02 |  58.61
 6310 |     4 |  0.02 |    0.07 |  58.68
 6340 |     1 |  0.00 |    0.02 |  58.70
 7111 |    35 |  0.17 |    0.63 |  59.33
 7112 |    52 |  0.25 |    0.94 |  60.27
 7113 |     3 |  0.01 |    0.05 |  60.33
 7114 |     9 |  0.04 |    0.16 |  60.49
 7115 |    82 |  0.39 |    1.48 |  61.97
 7119 |     8 |  0.04 |    0.14 |  62.12
 7121 |     1 |  0.00 |    0.02 |  62.13
 7122 |     5 |  0.02 |    0.09 |  62.22
 7123 |     4 |  0.02 |    0.07 |  62.30
 7124 |     1 |  0.00 |    0.02 |  62.31
 7125 |     1 |  0.00 |    0.02 |  62.33
 7126 |    36 |  0.17 |    0.65 |  62.98
 7127 |     3 |  0.01 |    0.05 |  63.04
 7130 |     1 |  0.00 |    0.02 |  63.06
 7131 |    23 |  0.11 |    0.42 |  63.47
 7132 |    11 |  0.05 |    0.20 |  63.67
 7211 |     1 |  0.00 |    0.02 |  63.69
 7212 |    60 |  0.29 |    1.08 |  64.77
 7213 |    20 |  0.10 |    0.36 |  65.14
 7214 |     9 |  0.04 |    0.16 |  65.30
 7215 |     1 |  0.00 |    0.02 |  65.32
 7221 |     1 |  0.00 |    0.02 |  65.33
 7222 |     1 |  0.00 |    0.02 |  65.35
 7223 |     3 |  0.01 |    0.05 |  65.41
 7224 |     1 |  0.00 |    0.02 |  65.42
 7231 |    59 |  0.28 |    1.07 |  66.49
 7232 |     2 |  0.01 |    0.04 |  66.53
 7233 |    27 |  0.13 |    0.49 |  67.02
 7234 |     1 |  0.00 |    0.02 |  67.03
 7311 |     1 |  0.00 |    0.02 |  67.05
 7313 |     1 |  0.00 |    0.02 |  67.07
 7316 |     1 |  0.00 |    0.02 |  67.09
 7317 |     3 |  0.01 |    0.05 |  67.14
 7318 |     7 |  0.03 |    0.13 |  67.27
 7319 |     9 |  0.04 |    0.16 |  67.43
 7322 |    14 |  0.07 |    0.25 |  67.69
 7323 |     2 |  0.01 |    0.04 |  67.72
 7411 |    52 |  0.25 |    0.94 |  68.66
 7412 |     8 |  0.04 |    0.14 |  68.81
 7413 |     8 |  0.04 |    0.14 |  68.95
 7421 |     5 |  0.02 |    0.09 |  69.04
 7422 |    12 |  0.06 |    0.22 |  69.26
 7511 |    25 |  0.12 |    0.45 |  69.71
 7512 |    93 |  0.45 |    1.68 |  71.39
 7513 |     6 |  0.03 |    0.11 |  71.50
 7514 |     8 |  0.04 |    0.14 |  71.65
 7515 |     2 |  0.01 |    0.04 |  71.68
 7521 |     6 |  0.03 |    0.11 |  71.79
 7522 |    40 |  0.19 |    0.72 |  72.51
 7523 |     1 |  0.00 |    0.02 |  72.53
 7531 |    35 |  0.17 |    0.63 |  73.16
 7533 |    53 |  0.26 |    0.96 |  74.12
 7534 |     7 |  0.03 |    0.13 |  74.25
 7536 |     4 |  0.02 |    0.07 |  74.32
 7542 |     3 |  0.01 |    0.05 |  74.38
 7543 |     2 |  0.01 |    0.04 |  74.41
 7544 |     5 |  0.02 |    0.09 |  74.50
 8111 |    10 |  0.05 |    0.18 |  74.68
 8112 |     5 |  0.02 |    0.09 |  74.77
 8113 |     4 |  0.02 |    0.07 |  74.85
 8114 |     2 |  0.01 |    0.04 |  74.88
 8121 |     2 |  0.01 |    0.04 |  74.92
 8122 |     3 |  0.01 |    0.05 |  74.97
 8131 |     1 |  0.00 |    0.02 |  74.99
 8141 |     3 |  0.01 |    0.05 |  75.05
 8142 |    13 |  0.06 |    0.24 |  75.28
 8143 |     2 |  0.01 |    0.04 |  75.32
 8151 |     1 |  0.00 |    0.02 |  75.33
 8152 |     1 |  0.00 |    0.02 |  75.35
 8153 |     3 |  0.01 |    0.05 |  75.41
 8156 |     1 |  0.00 |    0.02 |  75.42
 8157 |     5 |  0.02 |    0.09 |  75.52
 8160 |    25 |  0.12 |    0.45 |  75.97
 8171 |     4 |  0.02 |    0.07 |  76.04
 8172 |    15 |  0.07 |    0.27 |  76.31
 8182 |     5 |  0.02 |    0.09 |  76.40
 8183 |     7 |  0.03 |    0.13 |  76.53
 8189 |     1 |  0.00 |    0.02 |  76.55
 8219 |     2 |  0.01 |    0.04 |  76.58
 8312 |     1 |  0.00 |    0.02 |  76.60
 8321 |     1 |  0.00 |    0.02 |  76.62
 8322 |   132 |  0.64 |    2.39 |  79.01
 8331 |    40 |  0.19 |    0.72 |  79.73
 8332 |    82 |  0.39 |    1.48 |  81.21
 8341 |    14 |  0.07 |    0.25 |  81.46
 8342 |    30 |  0.14 |    0.54 |  82.01
 8343 |    16 |  0.08 |    0.29 |  82.30
 8344 |    11 |  0.05 |    0.20 |  82.50
 8350 |     7 |  0.03 |    0.13 |  82.62
 9111 |   304 |  1.46 |    5.50 |  88.12
 9112 |   221 |  1.06 |    4.00 |  92.12
 9121 |     2 |  0.01 |    0.04 |  92.15
 9129 |     2 |  0.01 |    0.04 |  92.19
 9211 |    64 |  0.31 |    1.16 |  93.35
 9212 |     5 |  0.02 |    0.09 |  93.44
 9213 |     1 |  0.00 |    0.02 |  93.45
 9214 |    18 |  0.09 |    0.33 |  93.78
 9215 |    14 |  0.07 |    0.25 |  94.03
 9216 |     3 |  0.01 |    0.05 |  94.09
 9311 |     1 |  0.00 |    0.02 |  94.10
 9312 |     6 |  0.03 |    0.11 |  94.21
 9313 |    46 |  0.22 |    0.83 |  95.05
 9321 |    11 |  0.05 |    0.20 |  95.24
 9329 |     6 |  0.03 |    0.11 |  95.35
 9333 |    23 |  0.11 |    0.42 |  95.77
 9334 |    58 |  0.28 |    1.05 |  96.82
 9411 |    13 |  0.06 |    0.24 |  97.05
 9412 |    30 |  0.14 |    0.54 |  97.59
 9510 |     2 |  0.01 |    0.04 |  97.63
 9520 |    43 |  0.21 |    0.78 |  98.41
 9529 |     1 |  0.00 |    0.02 |  98.43
 9611 |     4 |  0.02 |    0.07 |  98.50
 9612 |     4 |  0.02 |    0.07 |  98.57
 9613 |     6 |  0.03 |    0.11 |  98.68
 9621 |    12 |  0.06 |    0.22 |  98.90
 9622 |     1 |  0.00 |    0.02 |  98.92
 9623 |     3 |  0.01 |    0.05 |  98.97
 9629 |     3 |  0.01 |    0.05 |  99.02
 9999 |    54 |  0.26 |    0.98 | 100.00
 <NA> | 15231 | 73.36 |    <NA> |   <NA>
elsoc_long_2016_2023 %>%
  group_by(ola) %>%
  summarise(
    solo_NA = all(is.na(ciuo08_m03))
  ) # only wave 2018, 2021 and 2023
# A tibble: 7 × 2
    ola solo_NA
  <dbl> <lgl>  
1     1 TRUE   
2     2 TRUE   
3     3 FALSE  
4     4 TRUE   
5     5 FALSE  
6     6 TRUE   
7     7 FALSE  
elsoc_long_2016_2023$isco88 <- NA
elsoc_long_2016_2023$ciuo88_m03 <- as.character(elsoc_long_2016_2023$ciuo88_m03)
elsoc_long_2016_2023$ciuo08_m03 <- as.character(elsoc_long_2016_2023$ciuo08_m03)


elsoc_long_2016_2023$isco88[elsoc_long_2016_2023$ola %in% c(1)] <- elsoc_long_2016_2023$ciuo88_m03[elsoc_long_2016_2023$ola %in% c(1)]

elsoc_long_2016_2023$isco88[elsoc_long_2016_2023$ola %in% c(3,5,7)] <- DIGCLASS::isco08_to_isco88(elsoc_long_2016_2023$ciuo08_m03[elsoc_long_2016_2023$ola %in% c(3,5,7)]
)


elsoc_long_2016_2023 %>%
  group_by(ola) %>%
  summarise(
    solo_NA = all(is.na(isco88))
  )
# A tibble: 7 × 2
    ola solo_NA
  <dbl> <lgl>  
1     1 FALSE  
2     2 TRUE   
3     3 FALSE  
4     4 TRUE   
5     5 FALSE  
6     6 TRUE   
7     7 FALSE  
# Crear una columna con la variable "isco08" adelantada una ola
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  group_by(idencuesta) %>%        # Agrupa por id para trabajar en cada individuo
  mutate(isco88_lagged=lag(isco88,n=1)) %>%  # Desplaza isco08 a la siguiente ola
  ungroup()

# Rellenar los valores NA en la variable original
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  mutate(isco88=ifelse(!is.na(isco88),isco88,isco88_lagged)) %>%  # Si isco08 es NA, sustituir con el valor de la ola anterior 
  select(-isco88_lagged)                 # Elimina la columna temporal

elsoc_long_2016_2023 %>%
  group_by(ola) %>%
  summarise(
    solo_NA = all(is.na(isco88))
  )
# A tibble: 7 × 2
    ola solo_NA
  <dbl> <lgl>  
1     1 FALSE  
2     2 FALSE  
3     3 FALSE  
4     4 FALSE  
5     5 FALSE  
6     6 FALSE  
7     7 FALSE  
# SELF EMPLOYMENT -- EMPLOYMENT RELATION

frq(elsoc_long_2016_2023$m07)
Relacion de empleo (x) <numeric> 
# total N=20761 valid N=7288 mean=2.35 sd=1.90

Value
-----
    1
    2
    3
    4
    5
    6
    7
 <NA>

                                                                              Label
-----------------------------------------------------------------------------------
                                               Empleado u obrero en empresa privada
     Empleado u obrero del sector publico (incluso empresa publica o municipalidad)
                                          Miembro de las Fuerzas Armadas y de Orden
Patron/a o empleador/a (contrata o paga a honorarios a uno/o o mas trabajadores/as)
                                                Trabaja solo, no tiene empleados/as
                                                             Familiar no remunerado
                                                                 Servicio domestico
                                                                               <NA>

    N | Raw % | Valid % | Cum. %
--------------------------------
 4160 | 20.04 |   57.08 |  57.08
  964 |  4.64 |   13.23 |  70.31
   80 |  0.39 |    1.10 |  71.41
  329 |  1.58 |    4.51 |  75.92
 1379 |  6.64 |   18.92 |  94.84
   15 |  0.07 |    0.21 |  95.05
  361 |  1.74 |    4.95 | 100.00
13473 | 64.90 |    <NA> |   <NA>
labs_sj <- c(
  `1` = "Empleado u obrero en empresa privada",
  `2` = "Empleado u obrero del sector público",
  `3` = "Miembro de las Fuerzas Armadas y de Orden",
  `4` = "Patrón/a o empleador/a",
  `5` = "Trabaja solo, no tiene empleados",
  `6` = "Familiar no remunerado",
  `7` = "Servicio doméstico"
)

elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  mutate(m07 = suppressWarnings(as.integer(m07)),
         m07 = if_else(m07 %in% c(1,2,4,5,7), m07, NA_integer_)) %>%
  group_by(idencuesta) %>%
  arrange(idencuesta, ola, .by_group = TRUE) %>%
  mutate(rel_empleo = coalesce(m07, lag(m07))) %>%
  ungroup() %>%
  mutate(
    rel_empleo = set_labels(rel_empleo, labels = labs_sj),
    rel_empleo = set_label(rel_empleo, label = "Relación de empleo (1–7)")
  )

frq(elsoc_long_2016_2023$rel_empleo)
Relación de empleo (1–7) (x) <integer> 
# total N=20761 valid N=12067 mean=2.35 sd=1.91

Value |                                     Label |    N | Raw % | Valid % | Cum. %
-----------------------------------------------------------------------------------
    1 |      Empleado u obrero en empresa privada | 6979 | 33.62 |   57.84 |  57.84
    2 |      Empleado u obrero del sector público | 1583 |  7.62 |   13.12 |  70.95
    3 | Miembro de las Fuerzas Armadas y de Orden |    0 |  0.00 |    0.00 |  70.95
    4 |                    Patrón/a o empleador/a |  566 |  2.73 |    4.69 |  75.64
    5 |          Trabaja solo, no tiene empleados | 2330 | 11.22 |   19.31 |  94.95
    6 |                    Familiar no remunerado |    0 |  0.00 |    0.00 |  94.95
    7 |                        Servicio doméstico |  609 |  2.93 |    5.05 | 100.00
 <NA> |                                      <NA> | 8694 | 41.88 |    <NA> |   <NA>
sjt.xtab(elsoc_long_2016_2023$rel_empleo,elsoc_long_2016_2023$ola,
         show.col.prc=TRUE,
         var.labels=c("Relación de empleo","Ola"),
         show.summary=FALSE,         title=NULL)
Relación de empleo Ola Total
2016 2017 2018 2019 2021 2022 2023
Empleado u obrero en
empresa privada
1091
62.1 %
898
61.1 %
1349
59.1 %
1147
58.5 %
897
54.8 %
731
53.3 %
866
54.5 %
6979
57.8 %
Empleado u obrero
del sector público
186
10.6 %
155
10.6 %
291
12.8 %
262
13.4 %
230
14 %
195
14.2 %
264
16.6 %
1583
13.1 %
Patrón/a o
empleador/a
85
4.8 %
72
4.9 %
109
4.8 %
92
4.7 %
86
5.3 %
67
4.9 %
55
3.5 %
566
4.7 %
Trabaja solo, no
tiene empleados
321
18.3 %
277
18.9 %
415
18.2 %
354
18.1 %
347
21.2 %
307
22.4 %
309
19.5 %
2330
19.3 %
Servicio doméstico 75
4.3 %
67
4.6 %
118
5.2 %
106
5.4 %
78
4.8 %
71
5.2 %
94
5.9 %
609
5 %
Total 1758
100 %
1469
100 %
2282
100 %
1961
100 %
1638
100 %
1371
100 %
1588
100 %
12067
100 %
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  rowwise() %>% 
  mutate(self_employed = case_when(rel_empleo %in% c(4:5) ~ 1,
                                 rel_empleo %in% c(1,2,7) ~ 0,
                                 TRUE ~ NA)) %>% 
  ungroup()

frq(elsoc_long_2016_2023$self_employed)
x <numeric> 
# total N=20761 valid N=12067 mean=0.24 sd=0.43

Value |    N | Raw % | Valid % | Cum. %
---------------------------------------
    0 | 9171 | 44.17 |      76 |     76
    1 | 2896 | 13.95 |      24 |    100
 <NA> | 8694 | 41.88 |    <NA> |   <NA>
# SUPERVISION

frq(elsoc_long_2016_2023$m06)
Cantidad de personas supervisadas (x) <numeric> 
# total N=20761 valid N=6858 mean=6.00 sd=123.49

Value |     N | Raw % | Valid % | Cum. %
----------------------------------------
    0 |  4952 | 23.85 |   72.21 |  72.21
    1 |   267 |  1.29 |    3.89 |  76.10
    2 |   299 |  1.44 |    4.36 |  80.46
    3 |   225 |  1.08 |    3.28 |  83.74
    4 |   161 |  0.78 |    2.35 |  86.09
    5 |   133 |  0.64 |    1.94 |  88.03
    6 |    90 |  0.43 |    1.31 |  89.34
    7 |    60 |  0.29 |    0.87 |  90.22
    8 |    76 |  0.37 |    1.11 |  91.32
    9 |    20 |  0.10 |    0.29 |  91.62
   10 |   109 |  0.53 |    1.59 |  93.21
   11 |    14 |  0.07 |    0.20 |  93.41
   12 |    35 |  0.17 |    0.51 |  93.92
   13 |    11 |  0.05 |    0.16 |  94.08
   14 |     7 |  0.03 |    0.10 |  94.18
   15 |    40 |  0.19 |    0.58 |  94.77
   16 |     8 |  0.04 |    0.12 |  94.88
   17 |     2 |  0.01 |    0.03 |  94.91
   18 |     8 |  0.04 |    0.12 |  95.03
   19 |     2 |  0.01 |    0.03 |  95.06
   20 |    65 |  0.31 |    0.95 |  96.00
   21 |     3 |  0.01 |    0.04 |  96.05
   22 |     6 |  0.03 |    0.09 |  96.14
   23 |     3 |  0.01 |    0.04 |  96.18
   24 |     3 |  0.01 |    0.04 |  96.22
   25 |    22 |  0.11 |    0.32 |  96.54
   26 |     1 |  0.00 |    0.01 |  96.56
   27 |     3 |  0.01 |    0.04 |  96.60
   28 |     4 |  0.02 |    0.06 |  96.66
   29 |     1 |  0.00 |    0.01 |  96.68
   30 |    40 |  0.19 |    0.58 |  97.26
   31 |     2 |  0.01 |    0.03 |  97.29
   32 |     3 |  0.01 |    0.04 |  97.33
   35 |    10 |  0.05 |    0.15 |  97.48
   38 |     1 |  0.00 |    0.01 |  97.49
   40 |    29 |  0.14 |    0.42 |  97.91
   41 |     1 |  0.00 |    0.01 |  97.93
   44 |     1 |  0.00 |    0.01 |  97.94
   45 |     8 |  0.04 |    0.12 |  98.06
   47 |     1 |  0.00 |    0.01 |  98.08
   48 |     2 |  0.01 |    0.03 |  98.10
   49 |     1 |  0.00 |    0.01 |  98.12
   50 |    33 |  0.16 |    0.48 |  98.60
   52 |     1 |  0.00 |    0.01 |  98.61
   53 |     1 |  0.00 |    0.01 |  98.63
   55 |     2 |  0.01 |    0.03 |  98.66
   60 |    10 |  0.05 |    0.15 |  98.80
   68 |     1 |  0.00 |    0.01 |  98.82
   70 |     6 |  0.03 |    0.09 |  98.91
   75 |     1 |  0.00 |    0.01 |  98.92
   80 |     5 |  0.02 |    0.07 |  98.99
   85 |     1 |  0.00 |    0.01 |  99.01
   90 |     2 |  0.01 |    0.03 |  99.04
  100 |    16 |  0.08 |    0.23 |  99.27
  102 |     1 |  0.00 |    0.01 |  99.29
  104 |     1 |  0.00 |    0.01 |  99.30
  105 |     1 |  0.00 |    0.01 |  99.31
  120 |     3 |  0.01 |    0.04 |  99.36
  130 |     1 |  0.00 |    0.01 |  99.37
  135 |     1 |  0.00 |    0.01 |  99.39
  150 |     4 |  0.02 |    0.06 |  99.45
  155 |     1 |  0.00 |    0.01 |  99.46
  160 |     1 |  0.00 |    0.01 |  99.48
  180 |     2 |  0.01 |    0.03 |  99.50
  195 |     1 |  0.00 |    0.01 |  99.52
  200 |    13 |  0.06 |    0.19 |  99.71
  238 |     1 |  0.00 |    0.01 |  99.72
  250 |     2 |  0.01 |    0.03 |  99.75
  270 |     1 |  0.00 |    0.01 |  99.77
  300 |     5 |  0.02 |    0.07 |  99.84
  340 |     2 |  0.01 |    0.03 |  99.87
  350 |     1 |  0.00 |    0.01 |  99.88
  500 |     5 |  0.02 |    0.07 |  99.96
  700 |     1 |  0.00 |    0.01 |  99.97
  720 |     1 |  0.00 |    0.01 |  99.99
10000 |     1 |  0.00 |    0.01 | 100.00
 <NA> | 13903 | 66.97 |    <NA> |   <NA>
elsoc_long_2016_2023$is_supervisor <- if_else(elsoc_long_2016_2023$m06 >= 1, 1, 0)

frq(elsoc_long_2016_2023$is_supervisor)
x <numeric> 
# total N=20761 valid N=6858 mean=0.28 sd=0.45

Value |     N | Raw % | Valid % | Cum. %
----------------------------------------
    0 |  4952 | 23.85 |   72.21 |  72.21
    1 |  1906 |  9.18 |   27.79 | 100.00
 <NA> | 13903 | 66.97 |    <NA> |   <NA>
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  group_by(idencuesta) %>%        
  mutate(is_supervisor_lagged=lag(is_supervisor,n=1)) %>%  
  ungroup()

elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  mutate(is_supervisor=ifelse(!is.na(is_supervisor),is_supervisor,is_supervisor_lagged)) %>% 
  select(-is_supervisor_lagged)                

sjt.xtab(elsoc_long_2016_2023$is_supervisor,elsoc_long_2016_2023$ola,
         show.col.prc=TRUE,
         var.labels=c("Supervisor","Ola"),
         show.summary=FALSE,         title=NULL)
Supervisor Ola Total
2016 2017 2018 2019 2021 2022 2023
0 1339
74.3 %
1124
74.8 %
1788
77 %
1532
76.9 %
778
62.2 %
643
62.7 %
1112
71.1 %
8316
72.6 %
1 463
25.7 %
378
25.2 %
534
23 %
461
23.1 %
473
37.8 %
383
37.3 %
452
28.9 %
3144
27.4 %
Total 1802
100 %
1502
100 %
2322
100 %
1993
100 %
1251
100 %
1026
100 %
1564
100 %
11460
100 %
# N EMPLOYEES

frq(elsoc_long_2016_2023$m06)
Cantidad de personas supervisadas (x) <numeric> 
# total N=20761 valid N=6858 mean=6.00 sd=123.49

Value |     N | Raw % | Valid % | Cum. %
----------------------------------------
    0 |  4952 | 23.85 |   72.21 |  72.21
    1 |   267 |  1.29 |    3.89 |  76.10
    2 |   299 |  1.44 |    4.36 |  80.46
    3 |   225 |  1.08 |    3.28 |  83.74
    4 |   161 |  0.78 |    2.35 |  86.09
    5 |   133 |  0.64 |    1.94 |  88.03
    6 |    90 |  0.43 |    1.31 |  89.34
    7 |    60 |  0.29 |    0.87 |  90.22
    8 |    76 |  0.37 |    1.11 |  91.32
    9 |    20 |  0.10 |    0.29 |  91.62
   10 |   109 |  0.53 |    1.59 |  93.21
   11 |    14 |  0.07 |    0.20 |  93.41
   12 |    35 |  0.17 |    0.51 |  93.92
   13 |    11 |  0.05 |    0.16 |  94.08
   14 |     7 |  0.03 |    0.10 |  94.18
   15 |    40 |  0.19 |    0.58 |  94.77
   16 |     8 |  0.04 |    0.12 |  94.88
   17 |     2 |  0.01 |    0.03 |  94.91
   18 |     8 |  0.04 |    0.12 |  95.03
   19 |     2 |  0.01 |    0.03 |  95.06
   20 |    65 |  0.31 |    0.95 |  96.00
   21 |     3 |  0.01 |    0.04 |  96.05
   22 |     6 |  0.03 |    0.09 |  96.14
   23 |     3 |  0.01 |    0.04 |  96.18
   24 |     3 |  0.01 |    0.04 |  96.22
   25 |    22 |  0.11 |    0.32 |  96.54
   26 |     1 |  0.00 |    0.01 |  96.56
   27 |     3 |  0.01 |    0.04 |  96.60
   28 |     4 |  0.02 |    0.06 |  96.66
   29 |     1 |  0.00 |    0.01 |  96.68
   30 |    40 |  0.19 |    0.58 |  97.26
   31 |     2 |  0.01 |    0.03 |  97.29
   32 |     3 |  0.01 |    0.04 |  97.33
   35 |    10 |  0.05 |    0.15 |  97.48
   38 |     1 |  0.00 |    0.01 |  97.49
   40 |    29 |  0.14 |    0.42 |  97.91
   41 |     1 |  0.00 |    0.01 |  97.93
   44 |     1 |  0.00 |    0.01 |  97.94
   45 |     8 |  0.04 |    0.12 |  98.06
   47 |     1 |  0.00 |    0.01 |  98.08
   48 |     2 |  0.01 |    0.03 |  98.10
   49 |     1 |  0.00 |    0.01 |  98.12
   50 |    33 |  0.16 |    0.48 |  98.60
   52 |     1 |  0.00 |    0.01 |  98.61
   53 |     1 |  0.00 |    0.01 |  98.63
   55 |     2 |  0.01 |    0.03 |  98.66
   60 |    10 |  0.05 |    0.15 |  98.80
   68 |     1 |  0.00 |    0.01 |  98.82
   70 |     6 |  0.03 |    0.09 |  98.91
   75 |     1 |  0.00 |    0.01 |  98.92
   80 |     5 |  0.02 |    0.07 |  98.99
   85 |     1 |  0.00 |    0.01 |  99.01
   90 |     2 |  0.01 |    0.03 |  99.04
  100 |    16 |  0.08 |    0.23 |  99.27
  102 |     1 |  0.00 |    0.01 |  99.29
  104 |     1 |  0.00 |    0.01 |  99.30
  105 |     1 |  0.00 |    0.01 |  99.31
  120 |     3 |  0.01 |    0.04 |  99.36
  130 |     1 |  0.00 |    0.01 |  99.37
  135 |     1 |  0.00 |    0.01 |  99.39
  150 |     4 |  0.02 |    0.06 |  99.45
  155 |     1 |  0.00 |    0.01 |  99.46
  160 |     1 |  0.00 |    0.01 |  99.48
  180 |     2 |  0.01 |    0.03 |  99.50
  195 |     1 |  0.00 |    0.01 |  99.52
  200 |    13 |  0.06 |    0.19 |  99.71
  238 |     1 |  0.00 |    0.01 |  99.72
  250 |     2 |  0.01 |    0.03 |  99.75
  270 |     1 |  0.00 |    0.01 |  99.77
  300 |     5 |  0.02 |    0.07 |  99.84
  340 |     2 |  0.01 |    0.03 |  99.87
  350 |     1 |  0.00 |    0.01 |  99.88
  500 |     5 |  0.02 |    0.07 |  99.96
  700 |     1 |  0.00 |    0.01 |  99.97
  720 |     1 |  0.00 |    0.01 |  99.99
10000 |     1 |  0.00 |    0.01 | 100.00
 <NA> | 13903 | 66.97 |    <NA> |   <NA>
elsoc_long_2016_2023$n_employees <- if_else(elsoc_long_2016_2023$is_supervisor == 0, 0, elsoc_long_2016_2023$m06) 
 
frq(elsoc_long_2016_2023$n_employees)
x <numeric> 
# total N=20761 valid N=10222 mean=4.03 sd=101.19

Value |     N | Raw % | Valid % | Cum. %
----------------------------------------
    0 |  8316 | 40.06 |   81.35 |  81.35
    1 |   267 |  1.29 |    2.61 |  83.97
    2 |   299 |  1.44 |    2.93 |  86.89
    3 |   225 |  1.08 |    2.20 |  89.09
    4 |   161 |  0.78 |    1.58 |  90.67
    5 |   133 |  0.64 |    1.30 |  91.97
    6 |    90 |  0.43 |    0.88 |  92.85
    7 |    60 |  0.29 |    0.59 |  93.44
    8 |    76 |  0.37 |    0.74 |  94.18
    9 |    20 |  0.10 |    0.20 |  94.37
   10 |   109 |  0.53 |    1.07 |  95.44
   11 |    14 |  0.07 |    0.14 |  95.58
   12 |    35 |  0.17 |    0.34 |  95.92
   13 |    11 |  0.05 |    0.11 |  96.03
   14 |     7 |  0.03 |    0.07 |  96.10
   15 |    40 |  0.19 |    0.39 |  96.49
   16 |     8 |  0.04 |    0.08 |  96.57
   17 |     2 |  0.01 |    0.02 |  96.59
   18 |     8 |  0.04 |    0.08 |  96.66
   19 |     2 |  0.01 |    0.02 |  96.68
   20 |    65 |  0.31 |    0.64 |  97.32
   21 |     3 |  0.01 |    0.03 |  97.35
   22 |     6 |  0.03 |    0.06 |  97.41
   23 |     3 |  0.01 |    0.03 |  97.44
   24 |     3 |  0.01 |    0.03 |  97.47
   25 |    22 |  0.11 |    0.22 |  97.68
   26 |     1 |  0.00 |    0.01 |  97.69
   27 |     3 |  0.01 |    0.03 |  97.72
   28 |     4 |  0.02 |    0.04 |  97.76
   29 |     1 |  0.00 |    0.01 |  97.77
   30 |    40 |  0.19 |    0.39 |  98.16
   31 |     2 |  0.01 |    0.02 |  98.18
   32 |     3 |  0.01 |    0.03 |  98.21
   35 |    10 |  0.05 |    0.10 |  98.31
   38 |     1 |  0.00 |    0.01 |  98.32
   40 |    29 |  0.14 |    0.28 |  98.60
   41 |     1 |  0.00 |    0.01 |  98.61
   44 |     1 |  0.00 |    0.01 |  98.62
   45 |     8 |  0.04 |    0.08 |  98.70
   47 |     1 |  0.00 |    0.01 |  98.71
   48 |     2 |  0.01 |    0.02 |  98.73
   49 |     1 |  0.00 |    0.01 |  98.74
   50 |    33 |  0.16 |    0.32 |  99.06
   52 |     1 |  0.00 |    0.01 |  99.07
   53 |     1 |  0.00 |    0.01 |  99.08
   55 |     2 |  0.01 |    0.02 |  99.10
   60 |    10 |  0.05 |    0.10 |  99.20
   68 |     1 |  0.00 |    0.01 |  99.21
   70 |     6 |  0.03 |    0.06 |  99.27
   75 |     1 |  0.00 |    0.01 |  99.28
   80 |     5 |  0.02 |    0.05 |  99.32
   85 |     1 |  0.00 |    0.01 |  99.33
   90 |     2 |  0.01 |    0.02 |  99.35
  100 |    16 |  0.08 |    0.16 |  99.51
  102 |     1 |  0.00 |    0.01 |  99.52
  104 |     1 |  0.00 |    0.01 |  99.53
  105 |     1 |  0.00 |    0.01 |  99.54
  120 |     3 |  0.01 |    0.03 |  99.57
  130 |     1 |  0.00 |    0.01 |  99.58
  135 |     1 |  0.00 |    0.01 |  99.59
  150 |     4 |  0.02 |    0.04 |  99.63
  155 |     1 |  0.00 |    0.01 |  99.64
  160 |     1 |  0.00 |    0.01 |  99.65
  180 |     2 |  0.01 |    0.02 |  99.67
  195 |     1 |  0.00 |    0.01 |  99.68
  200 |    13 |  0.06 |    0.13 |  99.80
  238 |     1 |  0.00 |    0.01 |  99.81
  250 |     2 |  0.01 |    0.02 |  99.83
  270 |     1 |  0.00 |    0.01 |  99.84
  300 |     5 |  0.02 |    0.05 |  99.89
  340 |     2 |  0.01 |    0.02 |  99.91
  350 |     1 |  0.00 |    0.01 |  99.92
  500 |     5 |  0.02 |    0.05 |  99.97
  700 |     1 |  0.00 |    0.01 |  99.98
  720 |     1 |  0.00 |    0.01 |  99.99
10000 |     1 |  0.00 |    0.01 | 100.00
 <NA> | 10539 | 50.76 |    <NA> |   <NA>
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  group_by(idencuesta) %>%        
  mutate(n_employees_lagged=lag(n_employees,n=1)) %>% 
  ungroup()

elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>%
  mutate(n_employees=ifelse(!is.na(n_employees),n_employees,n_employees_lagged)) %>%  
  select(-n_employees_lagged)                

sjt.xtab(elsoc_long_2016_2023$n_employees,elsoc_long_2016_2023$ola,
         show.col.prc=TRUE,
         var.labels=c("N employees","Ola"),
         show.summary=FALSE,         title=NULL)
N employees Ola Total
2016 2017 2018 2019 2021 2022 2023
0 1339
74.3 %
1124
74.8 %
1962
78.6 %
1608
77.7 %
1332
73.8 %
829
68.4 %
1231
73.1 %
9425
75 %
1 62
3.4 %
54
3.6 %
66
2.6 %
55
2.7 %
77
4.3 %
68
5.6 %
66
3.9 %
448
3.6 %
2 72
4 %
61
4.1 %
71
2.8 %
62
3 %
80
4.4 %
60
5 %
76
4.5 %
482
3.8 %
3 49
2.7 %
39
2.6 %
66
2.6 %
62
3 %
59
3.3 %
50
4.1 %
52
3.1 %
377
3 %
4 40
2.2 %
32
2.1 %
51
2 %
45
2.2 %
43
2.4 %
35
2.9 %
31
1.8 %
277
2.2 %
5 39
2.2 %
30
2 %
35
1.4 %
30
1.4 %
26
1.4 %
22
1.8 %
33
2 %
215
1.7 %
6 22
1.2 %
18
1.2 %
28
1.1 %
26
1.3 %
15
0.8 %
11
0.9 %
26
1.5 %
146
1.2 %
7 13
0.7 %
9
0.6 %
19
0.8 %
18
0.9 %
14
0.8 %
13
1.1 %
14
0.8 %
100
0.8 %
8 17
0.9 %
12
0.8 %
29
1.2 %
24
1.2 %
15
0.8 %
13
1.1 %
16
1 %
126
1 %
9 3
0.2 %
3
0.2 %
6
0.2 %
4
0.2 %
2
0.1 %
2
0.2 %
9
0.5 %
29
0.2 %
10 27
1.5 %
19
1.3 %
29
1.2 %
21
1 %
31
1.7 %
24
2 %
25
1.5 %
176
1.4 %
11 3
0.2 %
3
0.2 %
3
0.1 %
2
0.1 %
4
0.2 %
3
0.2 %
4
0.2 %
22
0.2 %
12 11
0.6 %
8
0.5 %
7
0.3 %
7
0.3 %
7
0.4 %
7
0.6 %
10
0.6 %
57
0.5 %
13 5
0.3 %
5
0.3 %
4
0.2 %
2
0.1 %
2
0.1 %
1
0.1 %
0
0 %
19
0.2 %
14 1
0.1 %
1
0.1 %
1
0 %
1
0 %
4
0.2 %
2
0.2 %
2
0.1 %
12
0.1 %
15 12
0.7 %
9
0.6 %
10
0.4 %
10
0.5 %
15
0.8 %
13
1.1 %
3
0.2 %
72
0.6 %
16 3
0.2 %
3
0.2 %
1
0 %
1
0 %
1
0.1 %
0
0 %
3
0.2 %
12
0.1 %
17 2
0.1 %
2
0.1 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
4
0 %
18 3
0.2 %
2
0.1 %
4
0.2 %
4
0.2 %
0
0 %
0
0 %
1
0.1 %
14
0.1 %
19 1
0.1 %
1
0.1 %
0
0 %
0
0 %
1
0.1 %
0
0 %
0
0 %
3
0 %
20 12
0.7 %
8
0.5 %
26
1 %
23
1.1 %
10
0.6 %
9
0.7 %
17
1 %
105
0.8 %
21 1
0.1 %
1
0.1 %
0
0 %
0
0 %
2
0.1 %
1
0.1 %
0
0 %
5
0 %
22 1
0.1 %
1
0.1 %
1
0 %
0
0 %
2
0.1 %
1
0.1 %
2
0.1 %
8
0.1 %
23 1
0.1 %
1
0.1 %
1
0 %
1
0 %
0
0 %
0
0 %
1
0.1 %
5
0 %
24 1
0.1 %
1
0.1 %
1
0 %
1
0 %
0
0 %
0
0 %
1
0.1 %
5
0 %
25 4
0.2 %
3
0.2 %
4
0.2 %
4
0.2 %
9
0.5 %
7
0.6 %
5
0.3 %
36
0.3 %
26 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0.1 %
0
0 %
2
0 %
27 0
0 %
0
0 %
1
0 %
1
0 %
2
0.1 %
1
0.1 %
0
0 %
5
0 %
28 1
0.1 %
1
0.1 %
1
0 %
0
0 %
1
0.1 %
1
0.1 %
1
0.1 %
6
0 %
29 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
30 10
0.6 %
8
0.5 %
12
0.5 %
7
0.3 %
8
0.4 %
6
0.5 %
11
0.7 %
62
0.5 %
31 1
0.1 %
1
0.1 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
4
0 %
32 0
0 %
0
0 %
1
0 %
0
0 %
1
0.1 %
1
0.1 %
1
0.1 %
4
0 %
35 2
0.1 %
1
0.1 %
4
0.2 %
3
0.1 %
1
0.1 %
1
0.1 %
3
0.2 %
15
0.1 %
38 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
0
0 %
0
0 %
1
0 %
40 12
0.7 %
12
0.8 %
6
0.2 %
6
0.3 %
7
0.4 %
7
0.6 %
4
0.2 %
54
0.4 %
41 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
0
0 %
0
0 %
1
0 %
44 1
0.1 %
1
0.1 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
2
0 %
45 4
0.2 %
4
0.3 %
0
0 %
0
0 %
2
0.1 %
2
0.2 %
2
0.1 %
14
0.1 %
47 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0.1 %
0
0 %
2
0 %
48 1
0.1 %
1
0.1 %
1
0 %
0
0 %
0
0 %
0
0 %
0
0 %
3
0 %
49 0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0 %
50 5
0.3 %
3
0.2 %
9
0.4 %
7
0.3 %
6
0.3 %
4
0.3 %
13
0.8 %
47
0.4 %
52 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
53 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0.1 %
0
0 %
2
0 %
55 0
0 %
0
0 %
1
0 %
1
0 %
1
0.1 %
0
0 %
0
0 %
3
0 %
60 4
0.2 %
4
0.3 %
2
0.1 %
2
0.1 %
3
0.2 %
3
0.2 %
1
0.1 %
19
0.2 %
68 0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0 %
70 3
0.2 %
3
0.2 %
1
0 %
1
0 %
2
0.1 %
2
0.2 %
0
0 %
12
0.1 %
75 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
80 1
0.1 %
1
0.1 %
2
0.1 %
2
0.1 %
1
0.1 %
1
0.1 %
1
0.1 %
9
0.1 %
85 1
0.1 %
1
0.1 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
2
0 %
90 1
0.1 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
3
0 %
100 4
0.2 %
4
0.3 %
7
0.3 %
7
0.3 %
4
0.2 %
3
0.2 %
1
0.1 %
30
0.2 %
102 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0.1 %
0
0 %
2
0 %
104 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0.1 %
0
0 %
2
0 %
105 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
120 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
2
0.1 %
4
0 %
130 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
0
0 %
0
0 %
1
0 %
135 0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0 %
150 1
0.1 %
1
0.1 %
2
0.1 %
2
0.1 %
0
0 %
0
0 %
1
0.1 %
7
0.1 %
155 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
160 0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0 %
180 1
0.1 %
1
0.1 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
4
0 %
195 0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
1
0 %
200 2
0.1 %
2
0.1 %
3
0.1 %
3
0.1 %
5
0.3 %
4
0.3 %
3
0.2 %
22
0.2 %
238 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
250 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
1
0.1 %
3
0 %
270 0
0 %
0
0 %
0
0 %
0
0 %
1
0.1 %
0
0 %
0
0 %
1
0 %
300 1
0.1 %
1
0.1 %
1
0 %
0
0 %
0
0 %
0
0 %
3
0.2 %
6
0 %
340 1
0.1 %
1
0.1 %
0
0 %
0
0 %
1
0.1 %
0
0 %
0
0 %
3
0 %
350 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
500 1
0.1 %
1
0.1 %
2
0.1 %
1
0 %
0
0 %
0
0 %
2
0.1 %
7
0.1 %
700 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
720 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
10000 0
0 %
0
0 %
1
0 %
1
0 %
0
0 %
0
0 %
0
0 %
2
0 %
Total 1802
100 %
1502
100 %
2496
100 %
2069
100 %
1805
100 %
1212
100 %
1683
100 %
12569
100 %
## EGP SCHEME

elsoc_long_2016_2023 %>% 
  select(isco88, self_employed, n_employees, is_supervisor) %>% 
  na.omit()
# A tibble: 11,098 × 4
   isco88 self_employed n_employees is_supervisor
   <chr>          <dbl>       <dbl>         <dbl>
 1 9112               1           0             0
 2 9112               1           0             0
 3 7231               0           1             1
 4 7231               0           1             1
 5 7231               0           0             0
 6 7231               0           0             0
 7 8232               0           5             1
 8 7422               1           0             0
 9 7422               1           0             0
10 7422               0           0             0
# ℹ 11,088 more rows
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
    mutate(
    isco88 = repair_isco(isco88))

elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(
    egp11 = isco88_to_egp(isco88, self_employed, n_employees, n_classes = 11, label = T),
    egp11_mp =  isco88_to_egp_mp(isco88, is_supervisor, self_employed, n_employees, label = TRUE),
    oesch5 = isco88_to_oesch(isco88, self_employed, n_employees, n_classes = 5, label = T))

frq(elsoc_long_2016_2023$egp11)
x <character> 
# total N=20761 valid N=11364 mean=5.74 sd=3.67

Value                                  |    N | Raw % | Valid % | Cum. %
------------------------------------------------------------------------
'I: Higher Controllers'                | 1626 |  7.83 |   14.31 |  14.31
'II: Lower Controllers'                | 2285 | 11.01 |   20.11 |  34.42
'IIIa: Routine Nonmanual'              |  583 |  2.81 |    5.13 |  39.55
'IIIb: Lower Sales-Service'            | 1095 |  5.27 |    9.64 |  49.18
'IVa: Self-employed with employees'    |   31 |  0.15 |    0.27 |  49.45
'IVb: Self-employed with no employees' |  358 |  1.72 |    3.15 |  52.60
'IVc: Self-employed Farmer'            |  111 |  0.53 |    0.98 |  53.58
'V: Manual Supervisors'                | 1104 |  5.32 |    9.71 |  63.30
'VI: Skilled Worker'                   | 1073 |  5.17 |    9.44 |  72.74
'VIIa: Unskilled Worker'               | 2777 | 13.38 |   24.44 |  97.18
'VIIb: Farm Labor'                     |  321 |  1.55 |    2.82 | 100.00
<NA>                                   | 9397 | 45.26 |    <NA> |   <NA>
frq(elsoc_long_2016_2023$egp11_mp)
x <character> 
# total N=20761 valid N=11364 mean=7.35 sd=4.16

Value                               |    N | Raw % | Valid % | Cum. %
---------------------------------------------------------------------
Ia Higher Managers                  | 1355 |  6.53 |   11.92 |  11.92
Ib Lower Managers                   |  271 |  1.31 |    2.38 |  14.31
IIa Higher Professionals            | 1436 |  6.92 |   12.64 |  26.94
IIb Lower Professionals             |  849 |  4.09 |    7.47 |  34.42
IIIa Routine Nonmanual              |  583 |  2.81 |    5.13 |  39.55
IIIb Lower Sales-Service            | 1095 |  5.27 |    9.64 |  49.18
IVa Self-employed with employees    |   31 |  0.15 |    0.27 |  49.45
IVb Self-employed with no employees |  358 |  1.72 |    3.15 |  52.60
IVc Self-employed Farmer            |  111 |  0.53 |    0.98 |  53.58
V Manual Supervisors                | 1104 |  5.32 |    9.71 |  63.30
VI Skilled Worker                   | 1073 |  5.17 |    9.44 |  72.74
VIIa Unskilled Worker               | 2777 | 13.38 |   24.44 |  97.18
VIIb Farm Labor                     |  321 |  1.55 |    2.82 | 100.00
<NA>                                | 9397 | 45.26 |    <NA> |   <NA>
frq(elsoc_long_2016_2023$oesch5)
x <character> 
# total N=20761 valid N=11531 mean=3.34 sd=1.26

Value                        |    N | Raw % | Valid % | Cum. %
--------------------------------------------------------------
'Higher-grade service class' | 1284 |  6.18 |   11.14 |  11.14
'Lower-grade service class'  | 1289 |  6.21 |   11.18 |  22.31
'Skilled workers'            | 3938 | 18.97 |   34.15 |  56.47
'Small business owners'      | 2288 | 11.02 |   19.84 |  76.31
'Unskilled workers'          | 2732 | 13.16 |   23.69 | 100.00
<NA>                         | 9230 | 44.46 |    <NA> |   <NA>
sjt.xtab(elsoc_long_2016_2023$egp11_mp,elsoc_long_2016_2023$ola,
         show.col.prc=TRUE,
         show.na=TRUE,
         var.labels=c("EGP","Ola"),
         show.summary=FALSE,         title=NULL)
EGP Ola Total
2016 2017 2018 2019 2021 2022 2023 NA
Ia Higher Managers 194
6.6 %
164
6.6 %
299
8 %
249
7.3 %
162
5.9 %
75
2.7 %
212
7.8 %
0
0 %
1355
6.5 %
Ib Lower Managers 36
1.2 %
29
1.2 %
48
1.3 %
41
1.2 %
40
1.5 %
33
1.2 %
44
1.6 %
0
0 %
271
1.3 %
IIa Higher
Professionals
211
7.2 %
168
6.8 %
244
6.5 %
209
6.1 %
221
8.1 %
176
6.4 %
207
7.6 %
0
0 %
1436
6.9 %
IIb Lower
Professionals
119
4.1 %
89
3.6 %
173
4.6 %
145
4.2 %
116
4.2 %
90
3.3 %
117
4.3 %
0
0 %
849
4.1 %
IIIa Routine
Nonmanual
100
3.4 %
84
3.4 %
123
3.3 %
104
3 %
57
2.1 %
45
1.6 %
70
2.6 %
0
0 %
583
2.8 %
IIIb Lower
Sales-Service
185
6.3 %
144
5.8 %
218
5.8 %
191
5.6 %
137
5 %
114
4.2 %
106
3.9 %
0
0 %
1095
5.3 %
IVa Self-employed
with employees
9
0.3 %
5
0.2 %
5
0.1 %
4
0.1 %
3
0.1 %
3
0.1 %
2
0.1 %
0
0 %
31
0.1 %
IVb Self-employed
with no employees
57
1.9 %
51
2.1 %
54
1.4 %
49
1.4 %
61
2.2 %
47
1.7 %
39
1.4 %
0
0 %
358
1.7 %
IVc Self-employed
Farmer
16
0.5 %
15
0.6 %
21
0.6 %
17
0.5 %
19
0.7 %
11
0.4 %
12
0.4 %
0
0 %
111
0.5 %
V Manual Supervisors 183
6.3 %
160
6.5 %
192
5.1 %
175
5.1 %
155
5.7 %
67
2.5 %
172
6.3 %
0
0 %
1104
5.3 %
VI Skilled Worker 188
6.4 %
163
6.6 %
206
5.5 %
177
5.2 %
124
4.5 %
101
3.7 %
114
4.2 %
0
0 %
1073
5.2 %
VIIa Unskilled
Worker
401
13.7 %
348
14.1 %
590
15.7 %
503
14.7 %
348
12.7 %
208
7.6 %
379
13.9 %
0
0 %
2777
13.4 %
VIIb Farm Labor 49
1.7 %
41
1.7 %
54
1.4 %
47
1.4 %
47
1.7 %
41
1.5 %
42
1.5 %
0
0 %
321
1.5 %
NA 1179
40.3 %
1012
40.9 %
1521
40.6 %
1506
44.1 %
1250
45.6 %
1719
63 %
1210
44.4 %
0
0 %
9397
45.3 %
Total 2927
100 %
2473
100 %
3748
100 %
3417
100 %
2740
100 %
2730
100 %
2726
100 %
0
100 %
20761
100 %
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(egp3_mp = case_when(egp11_mp %in% c("Ia Higher Managers", 
                                    "Ib Lower Managers",
                                    "IIa Higher Professionals",
                                    "IIb Lower Professionals") ~ "Service class (I+II)",
                         egp11_mp %in% c("IIIa Routine Nonmanual",
                                    "IIIb Lower Sales-Service",
                                    "IVa Self-employed with employees",
                                    "IVb Self-employed with no employees",
                                    "IVc Self-employed Farmer") ~ "Intermediate class (III+IV)",
                         egp11_mp %in% c("V Manual Supervisors",
                                    "VI Skilled Worker",
                                    "VIIa Unskilled Worker",
                                    "VIIb Farm Labor") ~ "Working class (V+VI+VII)"),
         egp3_mp = factor(egp3_mp, levels = c("Service class (I+II)",
                                      "Intermediate class (III+IV)",
                                      "Working class (V+VI+VII)")),

         egp3 = case_when(egp11 %in% c("'I: Higher Controllers'", 
                                    "'II: Lower Controllers'") ~ "Service class (I+II)",
                         egp11 %in% c("'IIIa: Routine Nonmanual'",
                                    "'IIIb: Lower Sales-Service'",
                                    "'IVa: Self-employed with employees'",
                                    "'IVb: Self-employed with no employees'",
                                    "'IVc: Self-employed Farmer'") ~ "Intermediate class (III+IV)",
                         egp11 %in% c("'V: Manual Supervisors'",
                                    "'VI: Skilled Worker'",
                                    "'VIIa: Unskilled Worker'",
                                    "'VIIb: Farm Labor'") ~ "Working class (V+VI+VII)"),
         egp3 = factor(egp3, levels = c("Service class (I+II)",
                                      "Intermediate class (III+IV)",
                                      "Working class (V+VI+VII)")),
         
         )


frq(elsoc_long_2016_2023$egp3)
x <categorical> 
# total N=20761 valid N=11364 mean=2.12 sd=0.89

Value                       |    N | Raw % | Valid % | Cum. %
-------------------------------------------------------------
Service class (I+II)        | 3911 | 18.84 |   34.42 |  34.42
Intermediate class (III+IV) | 2178 | 10.49 |   19.17 |  53.58
Working class (V+VI+VII)    | 5275 | 25.41 |   46.42 | 100.00
<NA>                        | 9397 | 45.26 |    <NA> |   <NA>
frq(elsoc_long_2016_2023$egp3_mp)
x <categorical> 
# total N=20761 valid N=11364 mean=2.12 sd=0.89

Value                       |    N | Raw % | Valid % | Cum. %
-------------------------------------------------------------
Service class (I+II)        | 3911 | 18.84 |   34.42 |  34.42
Intermediate class (III+IV) | 2178 | 10.49 |   19.17 |  53.58
Working class (V+VI+VII)    | 5275 | 25.41 |   46.42 | 100.00
<NA>                        | 9397 | 45.26 |    <NA> |   <NA>
frq(elsoc_long_2016_2023$oesch5)
x <character> 
# total N=20761 valid N=11531 mean=3.34 sd=1.26

Value                        |    N | Raw % | Valid % | Cum. %
--------------------------------------------------------------
'Higher-grade service class' | 1284 |  6.18 |   11.14 |  11.14
'Lower-grade service class'  | 1289 |  6.21 |   11.18 |  22.31
'Skilled workers'            | 3938 | 18.97 |   34.15 |  56.47
'Small business owners'      | 2288 | 11.02 |   19.84 |  76.31
'Unskilled workers'          | 2732 | 13.16 |   23.69 | 100.00
<NA>                         | 9230 | 44.46 |    <NA> |   <NA>
sjt.xtab(elsoc_long_2016_2023$egp3_mp,elsoc_long_2016_2023$ola,
         show.col.prc=TRUE,
         var.labels=c("EGP","Ola"),
         show.summary=FALSE,         title=NULL)
EGP Ola Total
2016 2017 2018 2019 2021 2022 2023
Service class (I+II) 560
32 %
450
30.8 %
764
34.3 %
644
33.7 %
539
36.2 %
374
37 %
580
38.3 %
3911
34.4 %
Intermediate class
(III+IV)
367
21 %
299
20.5 %
421
18.9 %
365
19.1 %
277
18.6 %
220
21.8 %
229
15.1 %
2178
19.2 %
Working class
(V+VI+VII)
821
47 %
712
48.7 %
1042
46.8 %
902
47.2 %
674
45.2 %
417
41.2 %
707
46.6 %
5275
46.4 %
Total 1748
100 %
1461
100 %
2227
100 %
1911
100 %
1490
100 %
1011
100 %
1516
100 %
11364
100 %
sjt.xtab(elsoc_long_2016_2023$oesch5,elsoc_long_2016_2023$ola,
         show.col.prc=TRUE,
         var.labels=c("Oesch","Ola"),
         show.summary=FALSE,         title=NULL)
Oesch Ola Total
2016 2017 2018 2019 2021 2022 2023
'Higher-grade
service class'
144
8.2 %
115
7.9 %
248
11.1 %
205
10.7 %
205
13.4 %
157
14.2 %
210
13.7 %
1284
11.1 %
'Lower-grade service
class'
199
11.4 %
150
10.3 %
233
10.4 %
194
10.1 %
186
12.2 %
139
12.5 %
188
12.2 %
1289
11.2 %
'Skilled workers' 677
38.7 %
562
38.5 %
714
32 %
626
32.6 %
492
32.2 %
412
37.2 %
455
29.6 %
3938
34.2 %
'Small business
owners'
365
20.9 %
321
22 %
472
21.1 %
405
21.1 %
295
19.3 %
104
9.4 %
326
21.2 %
2288
19.8 %
'Unskilled workers' 363
20.8 %
313
21.4 %
567
25.4 %
488
25.4 %
348
22.8 %
297
26.8 %
356
23.2 %
2732
23.7 %
Total 1748
100 %
1461
100 %
2234
100 %
1918
100 %
1526
100 %
1109
100 %
1535
100 %
11531
100 %
# Exploración de NA en EGP y OESCH

# Distribución general de NA en EGP por ola
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(egp_na = is.na(egp3_mp))

sjt.xtab(elsoc_long_2016_2023$egp_na, elsoc_long_2016_2023$ola,
         show.col.prc = TRUE,
         var.labels = c("EGP es NA", "Ola"),
         show.summary = FALSE,
         title = NULL) # ok
EGP es NA Ola Total
2016 2017 2018 2019 2021 2022 2023
FALSE 1748
59.7 %
1461
59.1 %
2227
59.4 %
1911
55.9 %
1490
54.4 %
1011
37 %
1516
55.6 %
11364
54.7 %
TRUE 1179
40.3 %
1012
40.9 %
1521
40.6 %
1506
44.1 %
1250
45.6 %
1719
63 %
1210
44.4 %
9397
45.3 %
Total 2927
100 %
2473
100 %
3748
100 %
3417
100 %
2740
100 %
2730
100 %
2726
100 %
20761
100 %
# Análisis de componentes ocupacionales en casos NA
elsoc_long_2016_2023 %>% 
  filter(is.na(egp3_mp)) %>% 
  summarise(
    total_na = n(),
    con_isco88 = sum(!is.na(isco88)),
    pct_con_isco88 = round(100 * con_isco88 / total_na, 2),
    con_rel_empleo = sum(!is.na(rel_empleo)),
    pct_con_rel_empleo = round(100 * con_rel_empleo / total_na, 2)
  ) %>% 
  print()
# A tibble: 1 × 5
  total_na con_isco88 pct_con_isco88 con_rel_empleo pct_con_rel_empleo
     <int>      <int>          <dbl>          <int>              <dbl>
1     9397        771            8.2            703               7.48
# Situación laboral (m02) en casos NA de EGP
frq(elsoc_long_2016_2023$m02)
Actividad principal (x) <numeric> 
# total N=20761 valid N=20713 mean=3.15 sd=2.48

Value
-----
    1
    2
    3
    4
    5
    6
    7
    8
    9
 <NA>

                                                                                 Label
--------------------------------------------------------------------------------------
                                     Trabaja de manera remunerada con jornada completa
             Trabaja de manera remunerada a tiempo parcial o hace trabajos ocasionales
                                                                     Estudia y trabaja
                                                                          Solo estudia
                                                                 Jubilado o pensionado
                                                         Desempleado, buscando trabajo
Realiza tareas no remuneradas (quehaceres del hogar, cuidando ninnos u otras personas)
                                                 Esta enfermo o tiene una discapacidad
                                             No estudia, no trabaja y no busca trabajo
                                                                                  <NA>

   N | Raw % | Valid % | Cum. %
-------------------------------
9094 | 43.80 |   43.90 |  43.90
3125 | 15.05 |   15.09 |  58.99
 434 |  2.09 |    2.10 |  61.09
 475 |  2.29 |    2.29 |  63.38
3303 | 15.91 |   15.95 |  79.33
1038 |  5.00 |    5.01 |  84.34
2486 | 11.97 |   12.00 |  96.34
 198 |  0.95 |    0.96 |  97.30
 560 |  2.70 |    2.70 | 100.00
  48 |  0.23 |    <NA> |   <NA>
na_summary <- elsoc_long_2016_2023 %>% 
  filter(is.na(egp3_mp)) %>% 
  count(m02) %>% 
  mutate(
    situacion = case_when( 
      m02 == 4 ~ "Solo estudia",
      m02 == 5 ~ "Jubilado o pensionado",
      m02 == 6 ~ "Desempleado, buscando trabajo",
      m02 == 7 ~ "Realiza tareas no remuneradas",
      m02 == 8 ~ "Enfermo o con discapacidad",
      m02 == 9 ~ "No estudia, no trabaja, no busca trabajo",
      m02 %in% c(1, 2, 3) ~ "Otra situación laboral",
      is.na(m02) ~ "Sin respuesta en m02",
      TRUE ~ "Otro"
    ),
    porcentaje = round(100 * n / sum(n), 2)
  ) %>% 
  arrange(desc(n))

print(na_summary)
# A tibble: 10 × 4
     m02     n situacion                                porcentaje
   <dbl> <int> <chr>                                         <dbl>
 1     5  3142 Jubilado o pensionado                         33.4 
 2     7  2322 Realiza tareas no remuneradas                 24.7 
 3     1  1064 Otra situación laboral                        11.3 
 4     6   858 Desempleado, buscando trabajo                  9.13
 5     2   761 Otra situación laboral                         8.1 
 6     9   531 No estudia, no trabaja, no busca trabajo       5.65
 7     4   427 Solo estudia                                   4.54
 8     8   173 Enfermo o con discapacidad                     1.84
 9     3    88 Otra situación laboral                         0.94
10    NA    31 Sin respuesta en m02                           0.33
# Verificación: cobertura de m02 en casos NA de EGP
total_na_egp <- sum(is.na(elsoc_long_2016_2023$egp3_mp))
na_con_m02 <- elsoc_long_2016_2023 %>% 
  filter(is.na(egp3_mp) & !is.na(m02)) %>% 
  nrow()

cat(sprintf("Total NA en EGP: %d\n", total_na_egp))
Total NA en EGP: 9397
cat(sprintf("NA en EGP con respuesta en m02: %d (%.2f%%)\n", 
            na_con_m02, 100 * na_con_m02 / total_na_egp))
NA en EGP con respuesta en m02: 9366 (99.67%)
cat(sprintf("NA en EGP sin respuesta en m02: %d (%.2f%%)\n", 
            total_na_egp - na_con_m02, 100 * (total_na_egp - na_con_m02) / total_na_egp))
NA en EGP sin respuesta en m02: 31 (0.33%)
# 5. Categorización de casos NA según situación laboral
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(
    situacion_na_egp = case_when(
      !is.na(egp3_mp) ~ "Tiene EGP",
      is.na(egp3_mp) & m02 == 4 ~ "Solo estudia",
      is.na(egp3_mp) & m02 == 5 ~ "Jubilado o pensionado",
      is.na(egp3_mp) & m02 == 6 ~ "Desempleado, buscando trabajo",
      is.na(egp3_mp) & m02 == 7 ~ "Realiza tareas no remuneradas",
      is.na(egp3_mp) & m02 == 8 ~ "Enfermo o con discapacidad",
      is.na(egp3_mp) & m02 == 9 ~ "No estudia, no trabaja, no busca trabajo",
      is.na(egp3_mp) & m02 %in% c(1, 2, 3) ~ "Otra situación laboral",
      is.na(egp3_mp) & is.na(m02) ~ "Sin respuesta",
      TRUE ~ "Otro"
    )
  )

# Tabla cruzada por ola
sjt.xtab(elsoc_long_2016_2023$situacion_na_egp, elsoc_long_2016_2023$ola,
         show.col.prc = TRUE,
         var.labels = c("Situación laboral (casos NA EGP)", "Ola"),
         show.summary = FALSE,
         title = NULL)
Situación laboral
(casos NA EGP)
Ola Total
2016 2017 2018 2019 2021 2022 2023
Desempleado,
buscando trabajo
166
5.7 %
33
1.3 %
190
5.1 %
73
2.1 %
164
6 %
87
3.2 %
145
5.3 %
858
4.1 %
Enfermo o con
discapacidad
24
0.8 %
12
0.5 %
29
0.8 %
24
0.7 %
43
1.6 %
18
0.7 %
23
0.8 %
173
0.8 %
Jubilado o
pensionado
371
12.7 %
305
12.3 %
474
12.6 %
432
12.6 %
431
15.7 %
507
18.6 %
622
22.8 %
3142
15.1 %
No estudia, no
trabaja, no busca
trabajo
90
3.1 %
65
2.6 %
150
4 %
59
1.7 %
33
1.2 %
52
1.9 %
82
3 %
531
2.6 %
Otra situación
laboral
54
1.8 %
263
10.6 %
110
2.9 %
485
14.2 %
169
6.2 %
749
27.4 %
83
3 %
1913
9.2 %
Realiza tareas no
remuneradas
367
12.5 %
276
11.2 %
439
11.7 %
374
10.9 %
360
13.1 %
273
10 %
233
8.5 %
2322
11.2 %
Sin respuesta 6
0.2 %
1
0 %
14
0.4 %
1
0 %
0
0 %
5
0.2 %
4
0.1 %
31
0.1 %
Solo estudia 101
3.5 %
57
2.3 %
115
3.1 %
58
1.7 %
50
1.8 %
28
1 %
18
0.7 %
427
2.1 %
Tiene EGP 1748
59.7 %
1461
59.1 %
2227
59.4 %
1911
55.9 %
1490
54.4 %
1011
37 %
1516
55.6 %
11364
54.7 %
Total 2927
100 %
2473
100 %
3748
100 %
3417
100 %
2740
100 %
2730
100 %
2726
100 %
20761
100 %
# Esquema de clase ampliado: EGP + Outside the workforce

# Crear variable egp4 que incluye categoría residual
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(
    egp4 = case_when(
      # Mantener categorías EGP existentes
      !is.na(egp3_mp) ~ as.character(egp3_mp),
      # Categoría residual para quienes están fuera de la fuerza de trabajo
      is.na(egp3_mp) & m02 == 5 ~ "Retired or pensioner",
      is.na(egp3_mp) & m02 == 6 ~ "Unemployed",
      is.na(egp3_mp) & m02 == 7 ~ "Performs unpaid tasks",
      # NA para casos sin información
      TRUE ~ NA_character_
    ),
    egp4 = factor(egp4, 
                  levels = c("Service class (I+II)",
                            "Intermediate class (III+IV)",
                            "Working class (V+VI+VII)", 
                            "Retired or pensioner",
                            "Unemployed",
                            "Performs unpaid tasks"))
  )

# Verificar distribución
frq(elsoc_long_2016_2023$egp4)
x <categorical> 
# total N=20761 valid N=17686 mean=3.10 sd=1.60

Value                       |    N | Raw % | Valid % | Cum. %
-------------------------------------------------------------
Service class (I+II)        | 3911 | 18.84 |   22.11 |  22.11
Intermediate class (III+IV) | 2178 | 10.49 |   12.31 |  34.43
Working class (V+VI+VII)    | 5275 | 25.41 |   29.83 |  64.25
Retired or pensioner        | 3142 | 15.13 |   17.77 |  82.02
Unemployed                  |  858 |  4.13 |    4.85 |  86.87
Performs unpaid tasks       | 2322 | 11.18 |   13.13 | 100.00
<NA>                        | 3075 | 14.81 |    <NA> |   <NA>
# Tabla cruzada por ola
sjt.xtab(elsoc_long_2016_2023$egp4, elsoc_long_2016_2023$ola,
         show.col.prc = TRUE,
         var.labels = c("EGP Extended (with Out of labor force people)", "Wave"),
         show.summary = FALSE,
         title = NULL)
EGP Extended (with
Out of labor force
people)
Wave Total
2016 2017 2018 2019 2021 2022 2023
Service class (I+II) 560
21.1 %
450
21.7 %
764
22.9 %
644
23.1 %
539
22 %
374
19.9 %
580
23.1 %
3911
22.1 %
Intermediate class
(III+IV)
367
13.8 %
299
14.4 %
421
12.6 %
365
13.1 %
277
11.3 %
220
11.7 %
229
9.1 %
2178
12.3 %
Working class
(V+VI+VII)
821
31 %
712
34.3 %
1042
31.3 %
902
32.3 %
674
27.6 %
417
22.2 %
707
28.1 %
5275
29.8 %
Retired or pensioner 371
14 %
305
14.7 %
474
14.2 %
432
15.5 %
431
17.6 %
507
27 %
622
24.7 %
3142
17.8 %
Unemployed 166
6.3 %
33
1.6 %
190
5.7 %
73
2.6 %
164
6.7 %
87
4.6 %
145
5.8 %
858
4.9 %
Performs unpaid
tasks
367
13.8 %
276
13.3 %
439
13.2 %
374
13.4 %
360
14.7 %
273
14.5 %
233
9.3 %
2322
13.1 %
Total 2652
100 %
2075
100 %
3330
100 %
2790
100 %
2445
100 %
1878
100 %
2516
100 %
17686
100 %
# Comparación entre egp3 y egp4
comparison_table <- elsoc_long_2016_2023 %>% 
  count(egp3_mp, egp4) %>% 
  arrange(desc(n))

print(comparison_table)
# A tibble: 7 × 3
  egp3_mp                     egp4                            n
  <fct>                       <fct>                       <int>
1 Working class (V+VI+VII)    Working class (V+VI+VII)     5275
2 Service class (I+II)        Service class (I+II)         3911
3 <NA>                        Retired or pensioner         3142
4 <NA>                        <NA>                         3075
5 <NA>                        Performs unpaid tasks        2322
6 Intermediate class (III+IV) Intermediate class (III+IV)  2178
7 <NA>                        Unemployed                    858
# Esquema de clase ampliado: OESCH + Outside the workforce

# Crear variable egp4 que incluye categoría residual
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(
    oesch5 = case_when(
      # Mantener categorías OESCH existentes
      !is.na(oesch5) ~ as.character(oesch5),
      # Categoría residual para quienes están fuera de la fuerza de trabajo
      is.na(oesch5) & m02 == 5 ~ "'Retired or pensioner'",
      is.na(oesch5) & m02 == 6 ~ "'Unemployed'",
      is.na(oesch5) & m02 == 7 ~ "'Performs unpaid tasks'",
      # NA para casos sin información
      TRUE ~ NA_character_
    ),
    oesch5 = factor(oesch5, 
                  levels = c("'Higher-grade service class'",
                            "'Lower-grade service class'",
                            "'Skilled workers'", 
                            "'Small business owners'",
                            "'Unskilled workers'",
                            "'Retired or pensioner'",
                            "'Unemployed'",
                            "'Performs unpaid tasks'"))
  )

# Verificar distribución
frq(elsoc_long_2016_2023$oesch5)
x <categorical> 
# total N=20761 valid N=17830 mean=4.59 sd=2.04

Value                        |    N | Raw % | Valid % | Cum. %
--------------------------------------------------------------
'Higher-grade service class' | 1284 |  6.18 |    7.20 |   7.20
'Lower-grade service class'  | 1289 |  6.21 |    7.23 |  14.43
'Skilled workers'            | 3938 | 18.97 |   22.09 |  36.52
'Small business owners'      | 2288 | 11.02 |   12.83 |  49.35
'Unskilled workers'          | 2732 | 13.16 |   15.32 |  64.67
'Retired or pensioner'       | 3134 | 15.10 |   17.58 |  82.25
'Unemployed'                 |  854 |  4.11 |    4.79 |  87.04
'Performs unpaid tasks'      | 2311 | 11.13 |   12.96 | 100.00
<NA>                         | 2931 | 14.12 |    <NA> |   <NA>
# Meritocracy

frq(elsoc_long_2016_2023$merit_effort)
Grado de acuerdo: Las personas son recompensadas por sus esfuerzos (x) <numeric> 
# total N=20761 valid N=20629 mean=2.60 sd=1.02

Value |                          Label |    N | Raw % | Valid % | Cum. %
------------------------------------------------------------------------
    1 |       Totalmente en desacuerdo | 2173 | 10.47 |   10.53 |  10.53
    2 |                  En desacuerdo | 9442 | 45.48 |   45.77 |  56.30
    3 | Ni en desacuerdo ni de acuerdo | 4037 | 19.45 |   19.57 |  75.87
    4 |                     De acuerdo | 4379 | 21.09 |   21.23 |  97.10
    5 |          Totalmente de acuerdo |  598 |  2.88 |    2.90 | 100.00
 <NA> |                           <NA> |  132 |  0.64 |    <NA> |   <NA>
frq(elsoc_long_2016_2023$merit_talent)
Grado de acuerdo: Las personas son recompensada por su inteligencia (x) <numeric> 
# total N=20761 valid N=20631 mean=2.77 sd=1.03

Value |                          Label |    N | Raw % | Valid % | Cum. %
------------------------------------------------------------------------
    1 |       Totalmente en desacuerdo | 1766 |  8.51 |    8.56 |   8.56
    2 |                  En desacuerdo | 8108 | 39.05 |   39.30 |  47.86
    3 | Ni en desacuerdo ni de acuerdo | 4571 | 22.02 |   22.16 |  70.02
    4 |                     De acuerdo | 5577 | 26.86 |   27.03 |  97.05
    5 |          Totalmente de acuerdo |  609 |  2.93 |    2.95 | 100.00
 <NA> |                           <NA> |  130 |  0.63 |    <NA> |   <NA>
elsoc_long_2016_2023 <- elsoc_long_2016_2023 %>% 
  mutate(
    across(
      .cols = c(merit_effort, merit_talent),
      .fns = ~ car::recode(., recodes = c("1='Strongly disagree'; 2='Disagree';
                                          3='Neither agree nor disagree'; 4='Agree';
                                          5='Strongly agree'"), 
                           levels = c("Strongly disagree", "Disagree", "Neither agree nor disagree", "Agree", "Strongly agree"),
                           as.factor = T)
    )
  )


elsoc_long_2016_2023$merit_effort <- sjlabelled::set_label(elsoc_long_2016_2023$merit_effort, 
                        label = "People are rewarded for their efforts")

elsoc_long_2016_2023$merit_talent <- sjlabelled::set_label(elsoc_long_2016_2023$merit_talent, 
                        label = "People are rewarded for their intelligence")
# Controls

# sex
elsoc_long_2016_2023$sex <- car::recode(elsoc_long_2016_2023$sex, 
                           recodes = c("1='Male'; 2='Female'"), 
                           levels = c("Male", "Female"),
                           as.factor = T)

elsoc_long_2016_2023$sex <- sjlabelled::set_label(elsoc_long_2016_2023$sex, 
                        label = "Gender")

# age
frq(elsoc_long_2016_2023$age)
Edad del entrevistado (x) <numeric> 
# total N=20761 valid N=20761 mean=48.84 sd=15.43

Value |   N | Raw % | Valid % | Cum. %
--------------------------------------
   18 |  34 |  0.16 |    0.16 |   0.16
   19 |  72 |  0.35 |    0.35 |   0.51
   20 | 113 |  0.54 |    0.54 |   1.05
   21 | 156 |  0.75 |    0.75 |   1.81
   22 | 187 |  0.90 |    0.90 |   2.71
   23 | 231 |  1.11 |    1.11 |   3.82
   24 | 262 |  1.26 |    1.26 |   5.08
   25 | 324 |  1.56 |    1.56 |   6.64
   26 | 318 |  1.53 |    1.53 |   8.17
   27 | 312 |  1.50 |    1.50 |   9.68
   28 | 361 |  1.74 |    1.74 |  11.42
   29 | 345 |  1.66 |    1.66 |  13.08
   30 | 365 |  1.76 |    1.76 |  14.84
   31 | 364 |  1.75 |    1.75 |  16.59
   32 | 369 |  1.78 |    1.78 |  18.37
   33 | 377 |  1.82 |    1.82 |  20.18
   34 | 384 |  1.85 |    1.85 |  22.03
   35 | 373 |  1.80 |    1.80 |  23.83
   36 | 444 |  2.14 |    2.14 |  25.97
   37 | 373 |  1.80 |    1.80 |  27.76
   38 | 411 |  1.98 |    1.98 |  29.74
   39 | 365 |  1.76 |    1.76 |  31.50
   40 | 386 |  1.86 |    1.86 |  33.36
   41 | 391 |  1.88 |    1.88 |  35.24
   42 | 395 |  1.90 |    1.90 |  37.15
   43 | 379 |  1.83 |    1.83 |  38.97
   44 | 361 |  1.74 |    1.74 |  40.71
   45 | 370 |  1.78 |    1.78 |  42.49
   46 | 410 |  1.97 |    1.97 |  44.47
   47 | 411 |  1.98 |    1.98 |  46.45
   48 | 405 |  1.95 |    1.95 |  48.40
   49 | 403 |  1.94 |    1.94 |  50.34
   50 | 451 |  2.17 |    2.17 |  52.51
   51 | 417 |  2.01 |    2.01 |  54.52
   52 | 462 |  2.23 |    2.23 |  56.75
   53 | 413 |  1.99 |    1.99 |  58.74
   54 | 463 |  2.23 |    2.23 |  60.97
   55 | 495 |  2.38 |    2.38 |  63.35
   56 | 498 |  2.40 |    2.40 |  65.75
   57 | 449 |  2.16 |    2.16 |  67.91
   58 | 468 |  2.25 |    2.25 |  70.17
   59 | 461 |  2.22 |    2.22 |  72.39
   60 | 481 |  2.32 |    2.32 |  74.70
   61 | 397 |  1.91 |    1.91 |  76.61
   62 | 393 |  1.89 |    1.89 |  78.51
   63 | 386 |  1.86 |    1.86 |  80.37
   64 | 355 |  1.71 |    1.71 |  82.08
   65 | 362 |  1.74 |    1.74 |  83.82
   66 | 316 |  1.52 |    1.52 |  85.34
   67 | 335 |  1.61 |    1.61 |  86.96
   68 | 253 |  1.22 |    1.22 |  88.17
   69 | 260 |  1.25 |    1.25 |  89.43
   70 | 282 |  1.36 |    1.36 |  90.79
   71 | 268 |  1.29 |    1.29 |  92.08
   72 | 230 |  1.11 |    1.11 |  93.18
   73 | 235 |  1.13 |    1.13 |  94.32
   74 | 241 |  1.16 |    1.16 |  95.48
   75 | 245 |  1.18 |    1.18 |  96.66
   76 | 180 |  0.87 |    0.87 |  97.52
   77 | 152 |  0.73 |    0.73 |  98.26
   78 | 105 |  0.51 |    0.51 |  98.76
   79 |  98 |  0.47 |    0.47 |  99.23
   80 |  62 |  0.30 |    0.30 |  99.53
   81 |  40 |  0.19 |    0.19 |  99.73
   82 |  19 |  0.09 |    0.09 |  99.82
   83 |   9 |  0.04 |    0.04 |  99.86
   84 |  11 |  0.05 |    0.05 |  99.91
   85 |   4 |  0.02 |    0.02 |  99.93
   86 |   2 |  0.01 |    0.01 |  99.94
   87 |   2 |  0.01 |    0.01 |  99.95
   88 |   3 |  0.01 |    0.01 |  99.97
   89 |   3 |  0.01 |    0.01 |  99.98
   90 |   2 |  0.01 |    0.01 |  99.99
   91 |   1 |  0.00 |    0.00 | 100.00
   92 |   1 |  0.00 |    0.00 | 100.00
 <NA> |   0 |  0.00 |    <NA> |   <NA>
elsoc_long_2016_2023$aget <- 
  factor(car::recode(elsoc_long_2016_2023$age, 
                     "18:29=1;30:49=2;50:64=3;65:150=4"),
         labels = c('18-29', '30-49', '50-64', '65 or more'))
elsoc_long_2016_2023$aget <-
  sjlabelled::set_label(elsoc_long_2016_2023$aget, 
                        label = c("Age groups")) 


# political indentification

frq(elsoc_long_2016_2023$ideo)
Autoubicacion escala izquierda-derecha (x) <numeric> 
# total N=20761 valid N=20443 mean=7.39 sd=3.96

Value |            Label |    N | Raw % | Valid % | Cum. %
----------------------------------------------------------
    0 |      0 Izquierda | 1146 |  5.52 |    5.61 |   5.61
    1 |                1 |  386 |  1.86 |    1.89 |   7.49
    2 |                2 |  625 |  3.01 |    3.06 |  10.55
    3 |                3 | 1007 |  4.85 |    4.93 |  15.48
    4 |                4 | 1193 |  5.75 |    5.84 |  21.31
    5 |         5 Centro | 5360 | 25.82 |   26.22 |  47.53
    6 |                6 |  749 |  3.61 |    3.66 |  51.20
    7 |                7 |  707 |  3.41 |    3.46 |  54.65
    8 |                8 |  601 |  2.89 |    2.94 |  57.59
    9 |                9 |  177 |  0.85 |    0.87 |  58.46
   10 |       10 Derecha | 1135 |  5.47 |    5.55 |  64.01
   11 | 11 Independiente |  727 |  3.50 |    3.56 |  67.57
   12 |       12 Ninguno | 6630 | 31.93 |   32.43 | 100.00
 <NA> |             <NA> |  318 |  1.53 |    <NA> |   <NA>
elsoc_long_2016_2023$ideo<-
factor(
  car::recode(
    elsoc_long_2016_2023$ideo,
    "c(11,12,-888,-999)='Does not identify';c(0,1,2,3,4)='Left';
     c(5)='Center';c(6,7,8,9,10)='Right'"
  ),
  levels = c('Left', 'Center', 'Right', 'Does not identify')
)

elsoc_long_2016_2023$ideo<- factor(elsoc_long_2016_2023$ideo,levels = levels(elsoc_long_2016_2023$ideo))

elsoc_long_2016_2023$ideo <- 
sjlabelled::set_label(x = elsoc_long_2016_2023$ideo, 
                      label = "Political identification") 

frq(elsoc_long_2016_2023$ideo)
Political identification (x) <categorical> 
# total N=20761 valid N=20443 mean=2.67 sd=1.17

Value             |    N | Raw % | Valid % | Cum. %
---------------------------------------------------
Left              | 4357 | 20.99 |   21.31 |  21.31
Center            | 5360 | 25.82 |   26.22 |  47.53
Right             | 3369 | 16.23 |   16.48 |  64.01
Does not identify | 7357 | 35.44 |   35.99 | 100.00
<NA>              |  318 |  1.53 |    <NA> |   <NA>
# Socioeconomic_________________________________________________________________

# Education_______________________________________
elsoc_long_2016_2023$educ <- 
  car::recode(elsoc_long_2016_2023$m01,
              "c(1,2,3,4,5,6,7)=1;c(8,9,10)=2; c(-888,-999)=NA")
elsoc_long_2016_2023$educ <-
  factor(elsoc_long_2016_2023$educ,
         labels = c("Less than Universitary","Universitary"))

#reverse education, reference level is the highest level
#elsoc_long_2016_2023$educ <- forcats::fct_rev(elsoc_long_2016_2023$educ)

elsoc_long_2016_2023$educ <- 
sjlabelled::set_label(x = elsoc_long_2016_2023$educ,
                      label = "Education")
sjmisc::frq(elsoc_long_2016_2023$educ)
Education (x) <categorical> 
# total N=20761 valid N=20746 mean=1.19 sd=0.39

Value                  |     N | Raw % | Valid % | Cum. %
---------------------------------------------------------
Less than Universitary | 16786 | 80.85 |   80.91 |  80.91
Universitary           |  3960 | 19.07 |   19.09 | 100.00
<NA>                   |    15 |  0.07 |    <NA> |   <NA>
#Recoding of education to years based on casen 2017.
elsoc_long_2016_2023$educyear<- as.numeric(
  car::recode(elsoc_long_2016_2023$m01, 
              "1=0;2=4.3;3=7.5;4=9.8;5=12.02;6=13.9;
               7=14.8;8=14.9;9=16.9;10=19.07;c(-888,-999)=NA", 
              as.numeric = T))

elsoc_long_2016_2023$educyear <- 
sjlabelled::set_label(x = elsoc_long_2016_2023$educyear,
                      label = "Education in years")

class(elsoc_long_2016_2023$educyear)
[1] "numeric"
sjmisc::frq(elsoc_long_2016_2023$educyear)
Education in years (x) <numeric> 
# total N=20761 valid N=20746 mean=11.56 sd=3.99

Value |    N | Raw % | Valid % | Cum. %
---------------------------------------
 0.00 |  200 |  0.96 |    0.96 |   0.96
 4.30 | 2412 | 11.62 |   11.63 |  12.59
 7.50 | 1992 |  9.59 |    9.60 |  22.19
 9.80 | 2692 | 12.97 |   12.98 |  35.17
12.02 | 6122 | 29.49 |   29.51 |  64.68
13.90 |  749 |  3.61 |    3.61 |  68.29
14.80 | 2619 | 12.61 |   12.62 |  80.91
14.90 | 1197 |  5.77 |    5.77 |  86.68
16.90 | 2413 | 11.62 |   11.63 |  98.31
19.07 |  350 |  1.69 |    1.69 | 100.00
 <NA> |   15 |  0.07 |    <NA> |   <NA>
# Reshape long to wide

df_study1_long <- elsoc_long_2016_2023 %>% 
  select(idencuesta,
         ola,
         muestra,
         ponderador_long_total, 
         segmento, 
         estrato,
         just_pension,
         egp = egp4,
         oesch = oesch5,
         merit_effort,
         merit_talent,
         educ,
         educyear,
         sex,
         age,
         aget,
         ideo)

vars_invariantes <- c("egp", "oesch",
                      "age", "aget",
                      "sex",
                      "educ", "educyear",
                      "ideo")

df_study1_long_fix <- df_study1_long %>% 
  arrange(idencuesta, muestra, ola) %>%         
  group_by(idencuesta, muestra) %>%
  mutate(
    across(
      all_of(vars_invariantes),
      ~ {
        v1 <- .x[ola == 1 & !is.na(.x)]
        if (length(v1) > 0) v1[1] else .x
      }
    )
  ) %>%
  ungroup()

frq(df_study1_long_fix$ola) # ok
Identificador de ola de encuesta (x) <numeric> 
# total N=20761 valid N=20761 mean=3.95 sd=1.94

Value | Label |    N | Raw % | Valid % | Cum. %
-----------------------------------------------
    1 |  2016 | 2927 | 14.10 |   14.10 |  14.10
    2 |  2017 | 2473 | 11.91 |   11.91 |  26.01
    3 |  2018 | 3748 | 18.05 |   18.05 |  44.06
    4 |  2019 | 3417 | 16.46 |   16.46 |  60.52
    5 |  2021 | 2740 | 13.20 |   13.20 |  73.72
    6 |  2022 | 2730 | 13.15 |   13.15 |  86.87
    7 |  2023 | 2726 | 13.13 |   13.13 | 100.00
 <NA> |  <NA> |    0 |  0.00 |    <NA> |   <NA>
waves_use <- c(1,2,3,4,6,7)

df_study1_long_fix <- df_study1_long_fix %>% 
  filter(ola %in% waves_use)
df_unbalanced <- df_study1_long_fix

ids_t7 <- df_study1_long_fix %>%
  filter(ola == 7) %>%
  distinct(idencuesta) %>%
  pull(idencuesta)

df_t7 <- df_study1_long_fix %>%
  filter(idencuesta %in% ids_t7)

df_ids_balanced <- df_t7 %>%
  group_by(idencuesta) %>%
  summarise(
    n_olas_distintas = n_distinct(ola),
    .groups = "drop"
  ) %>%
  filter(n_olas_distintas == length(waves_use)) %>%   # tiene las 6 olas
  pull(idencuesta)

df_balanced <- df_t7 %>%
  filter(idencuesta %in% df_ids_balanced)

# Número de individuos
n_distinct(df_unbalanced$idencuesta)
[1] 4447
n_distinct(df_balanced$idencuesta)
[1] 1328
# Distribución por ola
df_unbalanced %>% count(ola)
# A tibble: 6 × 2
    ola     n
  <dbl> <int>
1     1  2927
2     2  2473
3     3  3748
4     4  3417
5     6  2730
6     7  2726
df_balanced   %>% count(ola)
# A tibble: 6 × 2
    ola     n
  <dbl> <int>
1     1  1328
2     2  1328
3     3  1328
4     4  1328
5     6  1328
6     7  1328

5 Save and export

save(df_study1_long,file = here::here("input/data/proc/df_study1_long_vf.RData")) # original

save(df_study1_long_fix,file = here::here("input/data/proc/df_study1_long_fix_vf.RData")) # fix orginal

save(df_unbalanced,file = here::here("input/data/proc/df_unbalanced.RData")) # Filter data by the idencuesta of t7
save(df_balanced,file = here::here("input/data/proc/df_balanced.RData"))