Instalación de los paquetes necesarios
install.packages("tidyverse")
install.packages("labelled")
install.packages("sjmisc")
install.packages("readxl")
install.packages("foreign")
install.packages("sjPlot")
install.packages("ggplot2")
install.packages("ggpubr")
install.packages("RColorBrewer")
install.packages("tseries")
install.packages("car")
install.packages("lmtest")
install.packages("DT")
Carga de bibliotecas
library(tidyverse)
library(labelled)
library(sjmisc)
library(readxl)
library(foreign)
library(sjPlot)
library(ggplot2)
library(ggpubr)
library(RColorBrewer)
library(tseries)
library(car)
library(lmtest)
library(DT)
Creación de los objetos con los enlaces a los ficheros
bbddBR1985 <- c("https://www.ine.es/ftp/microdatos/fecun/diseno_fecun_85.zip",
"https://www.ine.es/ftp/microdatos/fecun/datos_fecun_85.zip")
bbddBR1999 <- c("https://www.ine.es/ftp/microdatos/fecun/diseno_fecun_99.zip",
"https://www.ine.es/ftp/microdatos/fecun/datos_fecun_99.zip")
bbddBR2018 <- c("https://www.ine.es/ftp/microdatos/fecun/Mujeres_Individual.zip",
"https://www.ine.es/ftp/microdatos/fecun/dr_EFindividual_2018.xlsx")
Descarga de ficheros
dir.create("BBDD")
dir.create(file.path("BBDD", "1985"), recursive = T)
dir.create(file.path("BBDD", "1999"), recursive = T)
dir.create(file.path("BBDD", "2018"), recursive = T)
walk(bbddBR1985, ~download.file(.x,destfile=paste0("BBDD/1985/",basename(.x)), mode="wb"))
walk(bbddBR1999, ~download.file(.x,destfile=paste0("BBDD/1999/",basename(.x)), mode="wb"))
walk(bbddBR2018, ~download.file(.x,destfile=paste0("BBDD/2018/",basename(.x)), mode="wb"))
1985: formato ASCII
temp <- tempfile()
dir("BBDD/1985",pattern="zip") %>% paste0("BBDD/1985/",.) %>%
walk(unzip,exdir=temp)
bbdd1985 <- c("/FECUND85.TXT",
"/FECUND.A85DISE.TXT",
"/FECUND.A85VARI.TXT")
file.copy(paste0(temp,bbdd1985),"BBDD/")
## [1] TRUE TRUE TRUE
1999: formato ASCII
temp <- tempfile()
dir("BBDD/1999",pattern="zip") %>% paste0("BBDD/1999/",.) %>%
walk(unzip,exdir=temp)
bbdd1999 <- c("/ffecuano.txt",
"/fhoganon.txt",
"/fmayanon.txt",
"/fmiemano.txt",
"/varfecun.doc",
"/Anonimiz1.xls")
file.copy(paste0(temp,bbdd1999),"BBDD/")
## [1] TRUE TRUE TRUE TRUE TRUE TRUE
2018: varios formatos, se elige SPSS
temp <- tempfile()
dir("BBDD/2018",pattern="zip") %>% paste0("BBDD/2018/",.) %>%
walk(unzip,exdir=temp)
file.copy (paste0(temp, "/SPSS/", dir(paste0(temp,"/SPSS"))),
"BBDD")
## [1] TRUE
file.copy(paste0(temp), "BBDD/")
## [1] FALSE
file.copy(paste0("BBDD/2018/dr_EFindividual_2018.xlsx"), "BBDD/")
## [1] TRUE
Libro_1985_br <- read_lines("BBDD/FECUND.A85DISE.TXT",
locale = locale(encoding = "iso8859-1"))
# Limpieza del archivo: se identifican los elementos que son encabezados para quitarlos
LL_1 <- str_which(Libro_1985_br, "1 I.N.E.")
LL_2 <- str_which(Libro_1985_br,
"SID ===================================")
LL_3 <- str_which(Libro_1985_br,
"0 ESTADISTICA : CODIGO = 280")
LL_4 <- str_which(Libro_1985_br,
"FICHERO LOGICO :")
LL_5 <- str_which(Libro_1985_br,
"REGISTRO : TIPO = 0")
LL_6 <- str_which(Libro_1985_br,
"CONTENIDO = FICHERO FINAL.- ANONIMIZADO PARA PETICIONES EXTERNAS")
LL_8 <- str_which(Libro_1985_br,
"----------------------------------------------------------------------------------------------------------")
LL_9 <- str_which(Libro_1985_br,
"NIVEL CAMPO REPET COMIENZO")
Libro_1985_br <- Libro_1985_br[-c(LL_1, LL_2, LL_3, LL_4, LL_5, LL_6, LL_8, LL_9)]
Libro_1985_br <- trimws(Libro_1985_br, which = "left")
rm(LL_1, LL_2, LL_3, LL_4, LL_5, LL_6, LL_8, LL_9) # se borran objetos ya no necesarios
Libro_1985_br <- as.data.frame(Libro_1985_br) # Se prepara el libro como data.frame
Libro_1985_br <- Libro_1985_br %>%
separate(Libro_1985_br,c("Todo", "DESCRIPCION"), sep = "' ") # se aprovecha formato para dividir en columnas: cuando existe termina en 9' seguido de espacios
Libro_1985_br_NA <- which(is.na(Libro_1985_br$DESCRIPCION)) # de este modo los NA corresponden a los "títulos" de bloque de encuesta que no tienen longitud, y a filas en blanco de la limpieza anterior
Libro_1985_br2 <- Libro_1985_br [- Libro_1985_br_NA, ]
# Desgregación de los campos acumulados en la primera variable
Libro_1985_br2 <- Libro_1985_br2 %>%
separate(Todo,c("NIVEL", "CAMPO"),
sep = " ", extra = "merge")
Libro_1985_br2 <- Libro_1985_br2 %>%
separate(CAMPO,
c("CAMPO", "REPETICION"),
sep = " ", remove = FALSE, extra = "merge")
Libro_1985_br2[ , 2] <- str_trim (Libro_1985_br2$DESCRIPCION, side= "left")
Libro_1985_br2[ , 4] <- str_trim (Libro_1985_br2$REPETICION, side= "left")
Libro_1985_br2 <- Libro_1985_br2 %>%
separate(REPETICION,
c("REPETICION", "COMIENZO"),
sep = " ", remove = FALSE, extra = "merge")
Libro_1985_br2[ , 5] <- str_trim (Libro_1985_br2$COMIENZO, side= "left")
Libro_1985_br2 <- Libro_1985_br2 %>%
separate(COMIENZO,
c("COMIENZO", "LONGITUD"),
sep = " ", remove = FALSE, extra = "merge")
Libro_1985_br2[ , 6] <- str_trim (Libro_1985_br2$LONGITUD, side= "left")
Libro_1985_br2 <- Libro_1985_br2 %>%
separate(LONGITUD,
c("LONGITUD", "TIPO"),
sep = " ", remove = FALSE, extra = "merge")
Libro_1985_br2$LONGITUD <- as.numeric(Libro_1985_br2$LONGITUD)
sum(Libro_1985_br2$LONGITUD) # da como resultado 361, y según el diseño son 926 (porque contiene matrices)
## [1] 361
# Se calcula nueva variable de longitud con los datos de COMIENZO
Libro_1985_br2$COMIENZO <- as.numeric(Libro_1985_br2$COMIENZO)
L_85_COM <- Libro_1985_br2$COMIENZO
L_85_calculo <- L_85_COM[-1]
length(L_85_COM)
## [1] 241
length(L_85_calculo)
## [1] 240
L_85_calculo <- c(L_85_calculo, 927) # último dato para hacer los cálculos
LONG_Cal <- L_85_calculo - L_85_COM
sum(LONG_Cal) # longitud calculada 926, ahora sí coincide con el diseño
## [1] 926
libro_1985 <- cbind(Libro_1985_br2, LONG_Cal)
str(libro_1985)
## 'data.frame': 241 obs. of 8 variables:
## $ NIVEL : chr "1" "1" "2" "2" ...
## $ DESCRIPCION: chr "NUMERO CORRELATIVO " "NUMERO CORRELATIVO DEL CUESTIONARIO " "PROVINCIA " "CAMPO A CEROS " ...
## $ CAMPO : chr "I0" "I1" "I2" "I3A" ...
## $ REPETICION : chr "1" "1" "1" "1" ...
## $ COMIENZO : num 1 9 14 16 19 21 24 25 27 29 ...
## $ LONGITUD : num 8 5 2 3 2 3 1 2 2 2 ...
## $ TIPO : chr " PIC'(8)9" " PIC'(5)9" " PIC'99" " PIC'999" ...
## $ LONG_Cal : num 8 5 2 3 2 3 1 2 2 2 ...
datos1985 <- read.fwf("BBDD/FECUND85.TXT", widths = libro_1985$LONG_Cal,
col.name = libro_1985$CAMPO, header = FALSE, sep = "\t")
# Se pone la etiqueta de nombre a las variables
labelled::var_label(datos1985) <- libro_1985$DESCRIPCION %>%
setNames(libro_1985$CAMPO)
# Se comprueba que se han leido bien los datos (comparando con txt.VARI:
datatable(as.matrix(sjmisc::frq(datos1985$P103))) # Nivel de estudios: ok valores de 1 a 7
datatable(as.matrix(sjmisc::frq(datos1985$P609))) # Sit laboral: valores de 1 a 7
datatable(as.matrix(sjmisc::frq(datos1985$P411))) #Tratamiento emabarazo: 1 o 6
datatable(as.matrix(sjmisc::frq(datos1985$P70A3))) # derivada 9 valores de 0 a 1
# Se eliminan objetos ya no necesarios
rm(L_85_calculo, L_85_COM, Libro_1985_br, Libro_1985_br_NA,
Libro_1985_br2, LONG_Cal)
libro1999_MIEM <- readxl::read_xls("BBDD/Anonimiz1.xls", sheet = "MIEMBROS",
range = "A5:F69",
col_names = TRUE)
libro1999_MIEM <- na.omit(libro1999_MIEM)
libro1999_MIEM$LONG. <- as.numeric(libro1999_MIEM$LONG.)
datatable(as.matrix(libro1999_MIEM))
sum(libro1999_MIEM$LONG.) # longitud de 109 posiciones, (coincide con instrucciones)
## [1] 109
# Se indica la longitud de las variables
datos_MIEM_1999 <- read.fwf("BBDD/fmiemano.txt",
widths = libro1999_MIEM$LONG.,
col.name = libro1999_MIEM$NOMBRE,
header = FALSE, sep = "\t")
# Se pone nombre a las variables
labelled::var_label(datos_MIEM_1999) <- libro1999_MIEM$CONTENIDO %>%
setNames(libro1999_MIEM$NOMBRE)
# Comprobación de datos (con xls Anonimiz1)
datatable(as.matrix(datos_MIEM_1999 %>% frq(CEREMONI, encoding = "iso8859-1"))) # variable que toma de 1 a 3 o en blanco
datatable(as.matrix(datos_MIEM_1999 %>% frq(TAMUN, encoding = "iso8859-1"))) # variable que toma de 1 a 4
libro1999_VIVIEN <- readxl::read_xls("BBDD/Anonimiz1.xls", sheet = "VIVIEN",
range = "A5:F40",
col_names = TRUE)
libro1999_VIVIEN <- na.omit(libro1999_VIVIEN)
libro1999_VIVIEN$LONG. <- as.numeric(libro1999_VIVIEN$LONG.)
datatable(as.matrix(libro1999_VIVIEN))
sum(libro1999_VIVIEN$LONG.) # longitud de 54 posiciones # (coincide con instrucciones)
## [1] 54
# Se indica la longitud de las variables
datos_VIVIEN_1999 <- read.fwf("BBDD/fhoganon.txt",
widths = libro1999_VIVIEN$LONG.,
col.name = libro1999_VIVIEN$NOMBRE,
header = FALSE, sep = "\t")
# Se añade nombre a las variables
labelled::var_label(datos_VIVIEN_1999) <- libro1999_VIVIEN$CONTENIDO %>%
setNames(libro1999_VIVIEN$NOMBRE)
# Comprobación de datos
datatable(as.matrix(datos_VIVIEN_1999 %>% frq(TITORES,encoding = "iso8859-1"))) # variable que toma de 1 o 2
datatable(as.matrix(datos_VIVIEN_1999 %>% frq(TAMUN, encoding = "iso8859-1"))) # variable que toma de 1 a 4
libro1999_MAYORES <- readxl::read_xls("BBDD/Anonimiz1.xls",
sheet = "MAYORES",
range = "A5:F33",
col_names = TRUE)
libro1999_MAYORES <- na.omit(libro1999_MAYORES)
libro1999_MAYORES$LONG. <- as.numeric(libro1999_MAYORES$LONG.)
sum(libro1999_MAYORES$LONG.) # longitud de 47 posiciones # (coincide con instrucciones)
## [1] 47
# Se indica la longitud de las variables
datos_MAYORES_1999 <- read.fwf("BBDD/fmayanon.txt",
widths = libro1999_MAYORES$LONG.,
col.name = libro1999_MAYORES$NOMBRE,
header = FALSE, sep = "\t")
# Se añade nombre a las variables
labelled::var_label(datos_MAYORES_1999) <- libro1999_MAYORES$CONTENIDO %>%
setNames(libro1999_MAYORES$NOMBRE)
# Comprobación de datos
datatable(as.matrix(datos_MAYORES_1999 %>% frq(SEXO, encoding = "iso8859-1"))) # variable que toma valor 6
datatable(as.matrix(datos_MAYORES_1999 %>% frq(TAMUN, encoding = "iso8859-1"))) # variable que toma de 1 a 4
# Variables
libro1999_FECUND <- readxl::read_xls("BBDD/Anonimiz1.xls", sheet = "FECUND",
range = "A5:F823",
col_names = TRUE)
# Hay que rellenar el NA de la columna "tipo" el caso/variable FECRELPA con CHAR (como correspondería, aunque en el xls está vacío), si no con el siguiente comando eliminaría la fila
libro1999_FECUND[199, 3] <- "CHAR"
libro1999_FECUND <- na.omit(libro1999_FECUND)
libro1999_FECUND$LONG. <- as.numeric(libro1999_FECUND$LONG.)
sum(libro1999_FECUND$LONG.) # longitud de 985 posiciones (coincide con instrucciones)
## [1] 985
# Se indica la longitud de las variables
datos_FECUND_1999 <- read.fwf("BBDD/ffecuano.txt",
widths = libro1999_FECUND$LONG.,
col.name = libro1999_FECUND$NOMBRE,
header = FALSE, sep = "\t")
# Se añade nombre a las variables
labelled::var_label(datos_FECUND_1999) <- libro1999_FECUND$CONTENIDO %>%
setNames(libro1999_FECUND$NOMBRE)
# Comprobación de datos
datatable(as.matrix(datos_FECUND_1999 %>% frq(SEXO, encoding = "iso8859-1"))) # variable que toma valor 1 o 6 (aunque todos deberían ser 6)
datatable(as.matrix(datos_FECUND_1999 %>% frq(EMBANT, encoding = "iso8859-1"))) # variable que toma valor 1 o 6
datatable(as.matrix(datos_FECUND_1999 %>% frq(NDOTAMUN, encoding = "iso8859-1"))) # variable que toma de 1 a 4
# Como hay nombres de variables que se repiten en los diferentes archivos, se añaden sufijos para evitar problemas en la fusión
datos_FECUND_1999 <- datos_FECUND_1999 %>%
rename_all(vars(str_c(., '_f')))
datos_MIEM_1999 <- datos_MIEM_1999 %>%
rename_all(vars(str_c(., '_mi')))
datos_MAYORES_1999 <- datos_MAYORES_1999 %>%
rename_all(vars(str_c(., '_ma')))
datos_VIVIEN_1999 <- datos_VIVIEN_1999 %>%
rename_all(vars(str_c(., '_v')))
# Para poder fusionar, se quita el sufijo añadido en NUMORD
names (datos_FECUND_1999) [1] = "NUMEORD"
names(datos_FECUND_1999)
## [1] "NUMEORD" "NIVEL3_f" "PROVINCI_f" "GRUPOSEM_f" "NUMVIVI_f"
## [6] "NORDEN_f" "FECHANAC_f" "EDAD_f" "SEXO_f" "ESTADOCI_f"
## [11] "FECHAMAT_f" "CEREMONI_f" "TIENEPAR_f" "FECHAREL_f" "NDOCODPR_f"
## [16] "NDOCODPA_f" "NLIDADNA_f" "NLIDADPA_f" "AÑORESI_f" "CODESTUF_f"
## [21] "AÑOESTUF_f" "ESTUACT_f" "CODESTUA_f" "INTERRUP_f" "CREENCIA_f"
## [26] "TRABAJA_f" "OFICIO_f" "ACTEMPRE_f" "SITACT_f" "TICONTRA_f"
## [31] "SEMAHORA_f" "FECHACT_f" "EMPLEANT_f" "FECHPRI_f" "NUMCAMB_f"
## [36] "DEDINTE1_f" "DEDINTE2_f" "DEDINTE3_f" "DEDINTE4_f" "DEDINTE5_f"
## [41] "DEDINTE6_f" "DEDINTE7_f" "DEJARTR1_f" "DEJARTR2_f" "DEJARTR3_f"
## [46] "DEJARTR4_f" "DEJARTR5_f" "DEJARTR6_f" "DEJARTR7_f" "DEJARTR8_f"
## [51] "DEJARTR9_f" "SEMAPAS_f" "CONCONYU_f" "NUMORDEN_f" "FECHNACO_f"
## [56] "EDADCON_f" "SEXOCON_f" "ESTACICO_f" "FECMATCO_f" "CEREMOCO_f"
## [61] "TIENPARE_f" "FECRELPA_f" "NDOPROCO_f" "NDOPAICO_f" "NLIDNACO_f"
## [66] "NLIDPACO_f" "AÑORESCO_f" "COESTFCO_f" "AÑESTFCO_f" "ESTACTCO_f"
## [71] "COESTACO_f" "CREENCCO_f" "TRABAJCO_f" "SEMAPACO_f" "OFICIOCO_f"
## [76] "ACEMPRCO_f" "SITACTCO_f" "TIPCONCO_f" "SEMAHOCO_f" "FECACTCO_f"
## [81] "CODSITMA_f" "MOTNOJU1_f" "MOTNOJU2_f" "MOTNOJU3_f" "MOTNOJU4_f"
## [86] "MOTNOJU5_f" "INTENCON_f" "INTENCAS_f" "CUANTOSM_f" "SUMAMATR_f"
## [91] "FECHAIN0_f" "FECHAFI0_f" "MOTIVOF0_f" "FECHAIN1_f" "FECHAFI1_f"
## [96] "MOTIVOF1_f" "FECHAIN2_f" "FECHAFI2_f" "MOTIVOF2_f" "FECHAIN3_f"
## [101] "FECHAFI3_f" "MOTIVOF3_f" "FECHAIN4_f" "FECHAFI4_f" "MOTIVOF4_f"
## [106] "FECHAIN5_f" "FECHAFI5_f" "MOTIVOF5_f" "FECHAIN6_f" "FECHAFI6_f"
## [111] "MOTIVOF6_f" "EMBARAZA_f" "FECHAPRO_f" "EMBANT_f" "NUMEMBAN_f"
## [116] "ABORTO_f" "NUMABORT_f" "FECHAIN0.1_f" "DURSEM0_f" "EMBMULT0_f"
## [121] "NUMEMBM0_f" "INTERRU0_f" "VISITAS0_f" "EMBFUE0_f" "FECHAIN1.1_f"
## [126] "DURSEM1_f" "EMBMULT1_f" "NUMEMBM1_f" "INTERRU1_f" "VISITAS1_f"
## [131] "EMBFUE1_f" "FECHAIN2.1_f" "DURSEM2_f" "EMBMULT2_f" "NUMEMBM2_f"
## [136] "INTERRU2_f" "VISITAS2_f" "EMBFUE2_f" "FECHAIN3.1_f" "DURSEM3_f"
## [141] "EMBMULT3_f" "NUMEMBM3_f" "INTERRU3_f" "VISITAS3_f" "EMBFUE3_f"
## [146] "FECHAIN4.1_f" "DURSEM4_f" "EMBMULT4_f" "NUMEMBM4_f" "INTERRU4_f"
## [151] "VISITAS4_f" "EMBFUE4_f" "FECHAIN5.1_f" "DURSEM5_f" "EMBMULT5_f"
## [156] "NUMEMBM5_f" "INTERRU5_f" "VISITAS5_f" "EMBFUE5_f" "FECHAIN6.1_f"
## [161] "DURSEM6_f" "EMBMULT6_f" "NUMEMBM6_f" "INTERRU6_f" "VISITAS6_f"
## [166] "EMBFUE6_f" "FECHAIN7_f" "DURSEM7_f" "EMBMULT7_f" "NUMEMBM7_f"
## [171] "INTERRU7_f" "VISITAS7_f" "EMBFUE7_f" "FECHAIN8_f" "DURSEM8_f"
## [176] "EMBMULT8_f" "NUMEMBM8_f" "INTERRU8_f" "VISITAS8_f" "EMBFUE8_f"
## [181] "FECHAIN9_f" "DURSEM9_f" "EMBMULT9_f" "NUMEMBM9_f" "INTERRU9_f"
## [186] "VISITAS9_f" "EMBFUE9_f" "NUMHIJOS_f" "FECHAPA0_f" "PARTOMU0_f"
## [191] "NUMFETO0_f" "DURMESE0_f" "EMBFUE20_f" "VISITA20_f" "PARTOFU0_f"
## [196] "ASISTEN0_f" "FECHAPA1_f" "PARTOMU1_f" "NUMFETO1_f" "DURMESE1_f"
## [201] "EMBFUE21_f" "VISITA21_f" "PARTOFU1_f" "ASISTEN1_f" "FECHAPA2_f"
## [206] "PARTOMU2_f" "NUMFETO2_f" "DURMESE2_f" "EMBFUE22_f" "VISITA22_f"
## [211] "PARTOFU2_f" "ASISTEN2_f" "FECHAPA3_f" "PARTOMU3_f" "NUMFETO3_f"
## [216] "DURMESE3_f" "EMBFUE23_f" "VISITA23_f" "PARTOFU3_f" "ASISTEN3_f"
## [221] "FECHAPA4_f" "PARTOMU4_f" "NUMFETO4_f" "DURMESE4_f" "EMBFUE24_f"
## [226] "VISITA24_f" "PARTOFU4_f" "ASISTEN4_f" "FECHAPA5_f" "PARTOMU5_f"
## [231] "NUMFETO5_f" "DURMESE5_f" "EMBFUE25_f" "VISITA25_f" "PARTOFU5_f"
## [236] "ASISTEN5_f" "FECHAPA6_f" "PARTOMU6_f" "NUMFETO6_f" "DURMESE6_f"
## [241] "EMBFUE26_f" "VISITA26_f" "PARTOFU6_f" "ASISTEN6_f" "FECHAPA7_f"
## [246] "PARTOMU7_f" "NUMFETO7_f" "DURMESE7_f" "EMBFUE27_f" "VISITA27_f"
## [251] "PARTOFU7_f" "ASISTEN7_f" "FECHAPA8_f" "PARTOMU8_f" "NUMFETO8_f"
## [256] "DURMESE8_f" "EMBFUE28_f" "VISITA28_f" "PARTOFU8_f" "ASISTEN8_f"
## [261] "FECHAPA9_f" "PARTOMU9_f" "NUMFETO9_f" "DURMESE9_f" "EMBFUE29_f"
## [266] "VISITA29_f" "PARTOFU9_f" "ASISTEN9_f" "FECHANA0_f" "SEXO0_f"
## [271] "VIVO0_f" "VIVEACT0_f" "FECHAFA0_f" "FECHANA1_f" "SEXO1_f"
## [276] "VIVO1_f" "VIVEACT1_f" "FECHAFA1_f" "FECHANA2_f" "SEXO2_f"
## [281] "VIVO2_f" "VIVEACT2_f" "FECHAFA2_f" "FECHANA3_f" "SEXO3_f"
## [286] "VIVO3_f" "VIVEACT3_f" "FECHAFA3_f" "FECHANA4_f" "SEXO4_f"
## [291] "VIVO4_f" "VIVEACT4_f" "FECHAFA4_f" "FECHANA5_f" "SEXO5_f"
## [296] "VIVO5_f" "VIVEACT5_f" "FECHAFA5_f" "FECHANA6_f" "SEXO6_f"
## [301] "VIVO6_f" "VIVEACT6_f" "FECHAFA6_f" "FECHANA7_f" "SEXO7_f"
## [306] "VIVO7_f" "VIVEACT7_f" "FECHAFA7_f" "FECHANA8_f" "SEXO8_f"
## [311] "VIVO8_f" "VIVEACT8_f" "FECHAFA8_f" "FECHANA9_f" "SEXO9_f"
## [316] "VIVO9_f" "VIVEACT9_f" "FECHAFA9_f" "FECHANA10_f" "SEXO10_f"
## [321] "VIVO10_f" "VIVEACT10_f" "FECHAFA10_f" "FECHANA11_f" "SEXO11_f"
## [326] "VIVO11_f" "VIVEACT11_f" "FECHAFA11_f" "FECHANA12_f" "SEXO12_f"
## [331] "VIVO12_f" "VIVEACT12_f" "FECHAFA12_f" "FECHANA13_f" "SEXO13_f"
## [336] "VIVO13_f" "VIVEACT13_f" "FECHAFA13_f" "FECHANA14_f" "SEXO14_f"
## [341] "VIVO14_f" "VIVEACT14_f" "FECHAFA14_f" "HIJOADOP_f" "NUMADOPT_f"
## [346] "HIJOACOG_f" "NUMACOGI_f" "TTOEMBAR_f" "NUMTTOS_f" "CONSEGUI_f"
## [351] "CONSEGCO_f" "CONTINUA_f" "METODO00_f" "METOAN00_f" "METOAC00_f"
## [356] "METODO01_f" "METOAN01_f" "METOAC01_f" "METODO02_f" "METOAN02_f"
## [361] "METOAC02_f" "METODO03_f" "METOAN03_f" "METOAC03_f" "METODO04_f"
## [366] "METOAN04_f" "METOAC04_f" "METODO05_f" "METOAN05_f" "METOAC05_f"
## [371] "METODO06_f" "METOAN06_f" "METOAC06_f" "METODO07_f" "METOAN07_f"
## [376] "METOAC07_f" "METODO08_f" "METOAN08_f" "METOAC08_f" "METODO09_f"
## [381] "METOAN09_f" "METOAC09_f" "METODO10_f" "METOAN10_f" "METOAC10_f"
## [386] "METODO11_f" "METOAN11_f" "METOAC11_f" "METODO12_f" "METOAN12_f"
## [391] "METOAC12_f" "METODO13_f" "METOAN13_f" "METOAC13_f" "METODO14_f"
## [396] "METOAN14_f" "METOAC14_f" "METODO15_f" "METOAN15_f" "METOAC15_f"
## [401] "NOCONOCE_f" "FECHAANT_f" "EDADANTI_f" "CESEANTI_f" "CAUSACES_f"
## [406] "ASESORAM_f" "DESEOHIJ_f" "NUMDESEO_f" "COINCIDE_f" "NUMDESE2_f"
## [411] "MOTNOCO1_f" "MOTNOCO2_f" "MOTNOCO3_f" "MOTNOCO4_f" "MOTNOCO5_f"
## [416] "MOTNOCO6_f" "MOTNOCO7_f" "MOTNOCO8_f" "MOTNOCO9_f" "MOTNOCO10_f"
## [421] "MOTNOCO11_f" "MOTNOCO12_f" "MOTNOCO13_f" "MOTNOCO14_f" "MOTNOCO15_f"
## [426] "MOTNOCO16_f" "MOTNOCO17_f" "MOTNOCO18_f" "MOTNOCO19_f" "HIJOSFUT_f"
## [431] "NUMFUTUR_f" "TAMUN_f" "EDADCOM_f" "DURACION_f" "FELEVACI_f"
## [436] "METINEFS_f" "METEFISI_f" "VIVO_f" "SIVIVEAC_f" "NOVIVEAC_f"
## [441] "METANTIN_f" "METANTEF_f" "METACTIN_f" "METACTEF_f" "PROTOCAS_f"
## [446] "PROTOSOL_f" "INTERGEN_f" "GENESICOCE_f" "GENESICOAB_f" "EDADMAT_f"
## [451] "EDADPR_f" "EDADSG_f" "EDADULT_f" "NUMHOGAR_f" "NDOTAMUN_f"
## [456] "NDOTAMUNCN_f"
names(datos_MIEM_1999) [1] = "NUMEORD"
names(datos_MIEM_1999)
## [1] "NUMEORD" "NIVEL1_mi" "PROVINCI_mi" "GRUPOSEM_mi" "NUMVIVI_mi"
## [6] "NUMMIEMB_mi" "NUMMUJ_mi" "NUMMAYOR_mi" "NORDEN_mi" "FECHANAC_mi"
## [11] "EDAD_mi" "SEXO_mi" "ESTADOCI_mi" "FECHAMAT_mi" "CEREMONI_mi"
## [16] "TIENEPAR_mi" "FECHAREL_mi" "RELACI01_mi" "PADRE_mi" "MADRE_mi"
## [21] "PAREJA_mi" "FECNACPA_mi" "EDADPA_mi" "SEXOPA_mi" "ESCIPA_mi"
## [26] "FECMAPA_mi" "CEREPA_mi" "FERELAPA_mi" "RELA01PA_mi" "FELEVACI_mi"
## [31] "TAMUN_mi" "NUMHOGAR_mi"
names(datos_VIVIEN_1999) [1] = "NUMEORD"
names(datos_VIVIEN_1999)
## [1] "NUMEORD" "NIVEL0_v" "PROVINCI_v" "GRUPOSEM_v" "NUMVIVI_v"
## [6] "TITORES_v" "NUORDEN_v" "NUMMIEMB_v" "NUMPERSO_v" "NUMSUSTI_v"
## [11] "NUMMUJ_v" "NUMMAYOR_v" "SOLODORM_v" "YOTROSFI_v" "NUMASEOS_v"
## [16] "INSTALA1_v" "INSTALA2_v" "INSTALA3_v" "TENENCIA_v" "FELEVACI_v"
## [21] "TAMUN_v" "HABITACI_v" "NUMHOGAR_v"
names(datos_MAYORES_1999) [1] = "NUMEORD"
names(datos_MAYORES_1999)
## [1] "NUMEORD" "NIVEL2_ma" "PROVINCI_ma" "GRUPOSEM_ma" "NUMVIVI_ma"
## [6] "NORDEN_ma" "EDAD_ma" "SEXO_ma" "ESTADOCI_ma" "RELACI01_ma"
## [11] "NUMHIJOS_ma" "MUERTOS_ma" "NUMMUERT_ma" "NUMDESEA_ma" "FELEVACI_ma"
## [16] "TAMUN_ma" "NUMHOGAR_ma"
# Las 4 bbdd de 1999 tienen un nº diferente de observaciones por la nota metodológica del INE son 7.749 mujeres que coincide con los datos de FECUND, así que se prioriza este fichero
datos1999_1 <- left_join(datos_FECUND_1999, datos_VIVIEN_1999, by = "NUMEORD")
datos1999_2 <- left_join(datos1999_1, datos_MIEM_1999, by = "NUMEORD")
datos1999 <- left_join(datos1999_2, datos_MAYORES_1999, by = "NUMEORD")
# Se guardan los libros por si son necesarios
libros1999 <- list(libro1999_FECUND, libro1999_MAYORES,
libro1999_MIEM, libro1999_VIVIEN)
# Se eliminan objetos ya no necesarios
rm(datos_FECUND_1999, datos_MAYORES_1999, datos_MIEM_1999, datos_VIVIEN_1999,
datos1999_2, datos1999_1,
libro1999_FECUND, libro1999_MAYORES, libro1999_MIEM, libro1999_VIVIEN)
datos2018 <- foreign::read.spss("BBDD/MUJERES_INDIVIDUAL.sav",
to.data.frame=TRUE,
encoding="iso8859-1")
# Comprobación
datatable(as.matrix(datos2018 %>% sjmisc::frq(SEXO)))
datatable(as.matrix(datos2018 %>% sjmisc::frq(V_PRIORIDADH)))
datatable(as.matrix(datos2018 %>% sjmisc::frq(NHIJOBIO)))
datatable(as.matrix(datos2018 %>% sjmisc::frq(TIPOFAMORIG)))
# Lectura de libro para etiquetas de variables
libro2018_br <- "BBDD/dr_EFindividual_2018.xlsx"
libro2018_br2 <- readxl::excel_sheets(libro2018_br)
libro2018 <- readxl::read_excel(libro2018_br, libro2018_br2[1], skip = 1) %>%
#leer la hoja 1, saltando la 1º fila (títulos)
dplyr::rename(Diccionario = 'Diccionario de la variable',
Bloque = 'Bloque del cuestionario') %>%
# cambiar el nombre de columnas del excel
tidyr::fill(Bloque) # las celdas combinadas en el excel ahora repiten los datos en las celdas
# Asignar etiquetas a las variables
labelled::var_label(datos2018) <- libro2018$Descripción %>%
setNames(libro2018$Variable) %>%
as.list %>% .[-486]
# Comprobación
datatable(as.matrix(datos2018 %>% frq(TIPOFAMORIG)))
datatable(as.matrix(datos2018 %>% frq(SITSENTI)))
datatable(as.matrix(datos2018 %>% frq(NHERM)))
# Copia de seguridad
SEGdatos <- list("datos1985", "datos1999", "datos2018",
"libro_1985", "libro2018", "libros1999")
# Objetos ya no necesarios
rm("bbdd1985", "bbdd1999", "bbddBR1985", "bbddBR1999", "bbddBR2018",
"libro2018_br", "libro2018_br2", "temp")
Se irá creando una tabla con la ref. a las var. con las que trabajar
COD_nom <- c("Variable", "N1985", "P1985", "N1999","P1999", "N2018", "P2018")
## Edad
datatable(as.matrix(datos2018 %>% frq(EDAD))) # entre 18 y 55, coincide con Nota metodolológica
datatable(as.matrix(datos1999 %>% frq(EDAD_f))) # entre 15 y 49, coincide con Nota metodolológica
datatable(as.matrix(datos1985 %>% frq(P1011)))
datatable(as.matrix(datos1985 %>% frq(P1012)))
# Solo se tienen en cuenta el mes y año de nacimiento en datos 1985.
# Se filtra el 1º y último año de nacimiento y se cruza por mes
datatable(as.matrix(datos1985 %>% filter(P1012 ==35) %>% frq(P1011)))
datatable(as.matrix(datos1985 %>% filter(P1012 == 67) %>% frq(P1011))) # los datos se debieron tomar en mayo (mes 5)
## 1985
# Se crea nueva variable aux con 0 si nacieron entre ene (1) y abril (4), y -1 entre may y dic
datos1985 = datos1985 %>% mutate(REdadaux =rec(as.numeric(P1011), rec="1:4 = 0;5:12 = - 1", as.num = T))
datos1985 %>% flat_table(P1011, REdadaux)
## REdadaux -1 0
## P1011
## 1 0 765
## 2 0 743
## 3 0 801
## 4 0 732
## 5 769 0
## 6 732 0
## 7 696 0
## 8 746 0
## 9 733 0
## 10 698 0
## 11 674 0
## 12 693 0
datos1985 %>% filter(P1012 ==35) %>% flat_table(P1011, REdadaux)
## REdadaux -1
## P1011
## 5 24
## 6 14
## 7 13
## 8 17
## 9 16
## 10 20
## 11 18
## 12 16
# Se resta 85 (datos de 1985) al año de nacimiento - la nueva variable aux de mes de nacimiento
datos1985 = datos1985 %>% mutate(rEdad = 85 - (P1012-REdadaux))
labelled::var_label(datos1985$rEdad) <- "Edad"
datatable(as.matrix(datos1985 %>% frq(rEdad)))
datos1985 %>% filter(P1012 ==35) %>% flat_table(rEdad, REdadaux)
## REdadaux -1
## rEdad
## 49 138
datos1985 %>% filter(P1012 == 67) %>% flat_table(rEdad, REdadaux) # Correctos el rango de edad, entre 15 y 49 con los datos disponibles (ref. en Metodología encuesta de fecundidad 2000)
## REdadaux 0
## rEdad
## 18 116
## 1999
datos1999$rEdad <- as.numeric(datos1999$EDAD_f)
labelled::var_label(datos1999$rEdad) <- "Edad"
datatable(as.matrix(datos1999 %>% frq(rEdad)))
## 2018
datos2018$rEdad <- datos2018$EDAD
labelled::var_label(datos2018$rEdad) <- "Edad"
datatable(as.matrix(datos2018 %>% frq(rEdad)))
## Vector para tabla
VAR_2018 <- names(datos2018)
VAR_2018[486]
## [1] "rEdad"
VAR_1999 <- names(datos1999)
VAR_1999[526]
## [1] "rEdad"
VAR_1985 <- names(datos1985)
VAR_1985[243]
## [1] "rEdad"
rEdad <- c("Edad", "rEdad", "243", "rEdad", "526", "rEdad", "486")
Como posteriormente se homogeneizarán los datos por edad, muestra de 18 a 49 años en las tres encuestas, la codificación de los tramos de edad partirá de los datos (15 a 18 o 49 a 55), pero se pondrán etiquetas definitivas
## 1985
datos1985 = datos1985 %>%
mutate(
rTrEdad=rec(as.numeric(rEdad),
rec="18:19 = 1;
20:24 = 2;
25:29 = 3;
30:34 = 4;
35:39 = 5;
40:44 = 6;
45:49 = 7",
as.num = F,
val.labels = c("De 18 a 19 años", "De 20 a 24 años",
"De 25 a 29 años", "De 30 a 34 años",
"De 35 a 39 años", "De 40 a 44 años",
"De 45 a 49 años"),
var.label = "Tramos de edad")
)
datatable(as.matrix(datos1985 %>% flat_table(rEdad, rTrEdad)))
## 1999
datos1999 = datos1999 %>%
mutate(
rTrEdad=rec(as.numeric(rEdad),
rec="15:19 = 1;
20:24 = 2;
25:29 = 3;
30:34 = 4;
35:39 = 5;
40:44 = 6;
45:49 = 7",
as.num = F,
val.labels = c("De 18 a 19 años", "De 20 a 24 años",
"De 25 a 29 años", "De 30 a 34 años",
"De 35 a 39 años", "De 40 a 44 años",
"De 45 a 49 años"),
var.label = "Tramos de edad")
)
datatable(as.matrix(datos1999 %>% flat_table(rEdad, rTrEdad)))
## 2018
datos2018 = datos2018 %>%
mutate(
rTrEdad=rec(as.numeric(rEdad),
rec="18:19 = 1;
20:24 = 2;
25:29 = 3;
30:34 = 4;
35:39 = 5;
40:44 = 6;
45:55 =7",
as.num = F,
val.labels = c("De 18 a 19 años", "De 20 a 24 años",
"De 25 a 29 años", "De 30 a 34 años",
"De 35 a 39 años", "De 40 a 44 años",
"De 45 a 49 años"),
var.label = "Tramos de edad")
)
datatable(as.matrix(datos2018 %>% flat_table(rEdad, rTrEdad)))
rTrEdad <- c("Tramos de edad", "rTrEdad", "244", "rTrEdad", "527", "rTrEdad", "487")
datatable(as.matrix(estudiosa <- datos2018 %>% frq(ESTUDIOSA)))
datatable(as.matrix(datos1999 %>% frq(CODESTUF_f)))
# "01 = ANALFABETOS", "02 = SIN ESTUDIOS",
# "03 = ESTUDIOS PRIMARIOS Y CICLO INICIAL Y MEDIO",
# "04 = BACHILLER ELEMENTAL O EQUIVALENTE",
# "05 = CERTIFICADO DE ESCOLARIDAD O SIMILAR",
# "06 = FORMACION PROFESIONAL DE PRIMER GRADO O EQUIVALENTE",
# "07 = OTRAS ENSEÑANZAS TECNICO-PROFESIONALES DE PRIMER GRADO",
# "08 = BACHILLERATO SUPERIOR, B.U.P Y BACHILLERATO (NUEVO SISTEMA)",
# "09 = MODULO 2 FORMACION PROFESIONAL",
# "10 = FORMACION PRFESIONAL DE SEGUNDO GRADO O EQUIVALENTES",
# "11 = ENSEÑANZAS DE ARTES PLASTICAS, MUSICA Y DANZA DE GRADO MEDIO",
# "12 = OTRAS ENSEÑANZAS REGLADAS EQUIVALENTES LABORALMENTE O SIMILARES A LA F.P II",
# "13 = MODULO 3 DE FORMACION PROFESIONAL",
# "15 = PRIMER CICLO DE ESTUDIOS SUPERIORES: AREA DE INGENIERIA Y TECNOLOGIA",
# "16 = PRIMER CICLO DE ESTUDIOS SUPERIORES: AREA DE CIENCIAS DE LA SALUD",
# "17 = PRIMER CICLO DE ESTUDIOS SUPERIORES: AREA DE HUMANIDADES",
# "18 = PRIMER CICLO DE ESTUDIOS SUPERIORES: AREA DE CIENCIAS SOCIALES Y JURIDICAS",
# "19 = PRIMER CICLO DE ESTUDIOS SUPERIORES: AREA DE CIENCIAS EXPERIMENTALES",
# "20 = PRIMER CICLO DE ESTUDIOS SUPERIORES:TRES CURSOS APROBADOS O PRIMER CICLO DE ESTUDIOS SUPERIORES DE DOS CICLOS",
# "21 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: AREA DE INGENIERIA Y TECNOLOGIA",
# "22 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: AREA DE CIENCIAS DE LA SALUD",
# "23 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: AREA DE HUMANIDADES",
# "24 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: AREA DE CIENCIAS SOCIALES Y JURIDICAS",
# "25 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: AREA DE CIENCIAS EXPERIMENTALES",
# "26 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: ESTUDIOS EQUIVALENTES A TODOS LOS EFECTOS A DIPLOMADO UNIVERSITARIO",
# "27 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: ESTUDIOS SUPERIORES DE DOS O TRES AÑOS DE DURACION NO EQUIVALENT. A DIPLOMADO UNIVERSIT.",
# "28 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: ESTUDIOS EQUIVALENTES A TODOS LOS EFECTOS A LICENCIADO UNIVERSITARIO",
# "29 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: ESTUDIOS SUPERIORES DE AL MENOS CUATRO AÑOS DE DURACION NO EQUIVALENTES A LICENCIADO UNIVERSIT.",
# "30 = DOCTORES EN INGENIERIA, TECNOLOGIA, ARQUITECTURA, CIENCIAS DE LA SALUD Y EXPERIMENTALES",
# "31 = ESTUDIOS SUPERIORES, LICENCIADOS Y DOCTORADOS: DOCTORES EN HUMANIDADES Y EN CIENCIAS SOCIALES",
# "32 = ESTUDIOS DE POSTGRADO O MASTER EN CENTROS UNIVERSITARIOS",
# "33 = ESTUDIOS DE POSTGRADO O MASTER EN CENTROS NO UNIVERSITARIOS",
# "34 = ESTUDIOS OFICIALES DE ESPECIALIZACION",
# "35 = OTROS CURSOS DE POSTGRADO",
# "37 = TAQUIMECANOGRAFIA, CONTABILIDAD Y OTRAS ENSEÑANZAS DE LA RAMA ADMINISTRATIVA",
# "38 = INFORMATICA", "39 = IDIOMAS (EXCEPTO LA ESCUELA OFICIAL DE IDIOMAS QUE VA AL CODIGO 12)",
# "40 = OTROS ESTUDIOS NO REGLADOS")
datatable(as.matrix(datos1985 %>% frq(P103)))
# 1 = ANALFABETO, 2 = SIN ESTUDIOS
# 3 = ESTUDIOS PRIMARIOS, 4 = BACHILLER ELEMENTAL
# 5 = BACHILLER SUPERIOR, 6 = NIVEL ANTERIOR AL SUPERIOR
# 7 = SUPERIOR
ET_Estudios <- c("Analfabeta o sin estudios/menos que primaria",
"Primaria",
"Secundaria 1º etapa",
"Secundaria 2º et., post. y otros",
"Educ. universitaria")
## 1985
datos1985 = datos1985 %>%
mutate(
rEstudios=rec(as.numeric(P103),
rec="1:2 = 1;
3 = 2;
4 = 3;
5:6 = 4;
7 = 5",
as.num = F,
val.labels = ET_Estudios,
var.label = "Nivel de estudios alcanzado")
)
datatable(as.matrix(datos1985 %>% frq(rEstudios)))
datatable(as.matrix(datos1985 %>% flat_table(rEstudios, P103)))
## 1999
datos1999 = datos1999 %>%
mutate(
rEstudios=rec(as.numeric(CODESTUF_f),
rec="1:2 = 1;
3 = 2;
4: 7 = 3;
8:14 = 4;
15: 35 = 5;
36: 40 = 4",
as.num = F,
val.labels = ET_Estudios,
var.label = "Nivel de estudios alcanzado")
)
## One or more of the old values are recoded into identical new values.
## Please check if you correctly specified the recode-pattern,
## else separate multiple values with comma, e.g. rec="a,b,c=1; d,e,f=2".
datatable(as.matrix(datos1999 %>% frq(rEstudios)))
datatable(as.matrix(datos1999 %>% flat_table(CODESTUF_f, rEstudios)))
## 2018
datos2018 = datos2018 %>%
mutate(
rEstudios=rec(as.numeric(ESTUDIOSA),
rec="1 = 1;
2 = 2;
3 = 3;
4:6 = 4;
7:9 = 5",
as.num = F,
val.labels = ET_Estudios,
var.label = "Nivel de estudios alcanzado")
)
datatable(as.matrix(datos2018 %>% frq(rEstudios)))
datatable(as.matrix(datos2018 %>% flat_table(ESTUDIOSA, rEstudios)))
rEstudios <- c("Nivel de estudios alcanzado", "rEstudios", "245", "rEstudios", "528", "rEstudios", "488")
datatable(as.matrix(datos1985 %>% frq(P202)))
# "1 = SOLTERO", "2 = CASADO", "3 = VIUDO", "4 = SEPARADO", "5 = DIVORCIADO"
datatable(as.matrix(datos1999 %>% frq(ESTADOCI_f)))
# "1 = SOLTERO", "2 = CASADO", "3 = VIUDO", "4 = DIVORCIADO, SEPARADO"
datatable(as.matrix(datos2018 %>% frq(EC)))
# Para homogenizar etiquetas se recodifican en 4 categorias (uniendo divorciada y separada como en 1999)
## 1985
datos1985 = datos1985 %>%
mutate(
rEstCiv=rec(as.numeric(P202),
rec="1 = 1;
2 = 2;
3 = 3;
4:5 = 4",
as.num = F,
val.labels = c("Soltera", "Casada",
"Viuda", "Separada / Divorciada"),
var.label = "Estado civil")
)
datatable(as.matrix(datos1985 %>% flat_table(P202, rEstCiv)))
## 1999
datos1999 = datos1999 %>%
mutate(
rEstCiv=rec(as.numeric(ESTADOCI_f),
rec="1 = 1;
2 = 2;
3 = 3;
4:5 = 4",
as.num = F,
val.labels = c("Soltera", "Casada",
"Viuda", "Separada / Divorciada"),
var.label = "Estado civil")
)
datatable(as.matrix(datos1999 %>% flat_table(ESTADOCI_f, rEstCiv)))
## 2018
datos2018 = datos2018 %>%
mutate(
rEstCiv=rec(as.numeric(EC),
rec="1 = 1;
2 = 2;
3 = 3;
4:5 = 4",
as.num = F,
val.labels = c("Soltera", "Casada",
"Viuda", "Separada / Divorciada"),
var.label = "Estado civil")
)
datatable(as.matrix(datos2018 %>% flat_table(EC, rEstCiv)))
rEstCiv <- c("Estado civil", "rEstCiv", "246", "rEstCiv", "529", "rEstCiv", "489")
datatable(as.matrix(datos1985 %>% frq(P609)))
# "1 = TRABAJA AL MENOS 1/3 DE LA JORNADA LABORAL NORMAL",
# "2 = TRABAJA MENOS DE 1/3 DE LA JORNADA LABORAL NORMAL",
# "3 = PARADA, QUE BUSCA EMPLEO, HABIENDO TRABAJADO ANTES",
# "4 = PARADA, QUE BUSCA SU PRIMER EMPLEO",
# "5 = ESTUDIANTE O ESCOLAR",
# "6 = DEDICADA PRINCIPALMENTE A LAS LABORES DEL HOGAR",
# "7 = OTROS"
datatable(as.matrix(datos1999 %>% frq(TRABAJA_f)))
# ("1=SI", "6=NO")
datatable(as.matrix(datos1999 %>% frq(SEMAPAS_f)))
# "1 = PARADA BUSCANDO EMPLEO",
# "2 = ESTUDIANTE",
# "3 = LABORES DEL HOGAR",
# "4 = JUBILADA O PENSIONISTA",
# "5 = OTRA SITUACION")
xtabs(~SEMAPAS_f+TRABAJA_f, data = datos1999, addNA = T)
## TRABAJA_f
## SEMAPAS_f 1 6
## 1 0 843
## 2 1 939
## 3 0 2298
## 4 0 49
## 5 0 132
## <NA> 3487 0
# Hay un caso que trabaja y es estudiante, se quedará como estudiante
datatable(as.matrix(datos1999 %>% frq(EMPLEANT_f)))
# ("1=SI", "6=NO")
xtabs(~SEMAPAS_f+EMPLEANT_f, data = datos1999)
## EMPLEANT_f
## SEMAPAS_f 1 2
## 1 653 190
## 2 222 718
## 3 1565 733
## 4 43 6
## 5 102 30
datatable(as.matrix(datos1999 %>% frq(SEMAHORA_f)))
datatable(as.matrix(datos2018 %>% frq(TRABAJAACT)))
datatable(as.matrix(datos2018 %>% frq(SITUACIONACT)))
datatable(as.matrix(datos2018 %>% frq(EMPLEOANT)))
xtabs(~SITUACIONACT+EMPLEOANT, data = datos2018)
## EMPLEOANT
## SITUACIONACT Si No
## Parado/a buscando empleo 1612 245
## Estudiante 426 977
## Dedicado a las labores de mi hogar 1052 512
## Incapacitado para trabajar 161 33
## Jubilado/a, prejubilado/a, pensionista, retirado de una acti 99 16
## Otro tipo de inactividad 163 78
datatable(as.matrix(datos2018 %>% frq(JORNADA)))
datatable(as.data.frame(datos2018$JORNADA))
# No merece la pena diferenciar entre sit. de desempleo con o sin empleo anterior confuso incluir trabajo a tiempo completo o parcial. Se dejará en trabaja
ET_SitLab <- c("Estudiante", "Otras, jubilada o pensionista", "Labores del hogar", "En sit. de desempleo", "Trabajando")
#1985
datos1985 = datos1985 %>%
mutate(
rSitLab=rec(as.numeric(P609),
rec="1:2 = 5;
3 : 4 = 4;
5 = 1;
6 = 3;
7 = 2",
as.num = F,
val.labels = ET_SitLab,
var.label = "Situación laboral")
)
datatable(as.matrix(datos1985 %>% frq(rSitLab)))
datatable(as.matrix(datos1985 %>% flat_table(P609, rSitLab)))
#1999
datos1999 = datos1999 %>%
mutate(
rSitLab=rec(as.numeric(SEMAPAS_f),
rec="NA=5;
1 = 4;
2 = 1;
3 = 3;
4:5 = 2",
as.num = F,
val.labels = ET_SitLab,
var.label = "Situación laboral")
)
datatable(as.matrix(datos1999 %>% frq(rSitLab)))
sjPlot::sjt.xtab(datos1999$rSitLab, datos1999$SEMAPAS_f, show.na = T)
| Situación laboral |
SITUACION EN LA SEMANA DE REFERENCIA |
Total | |||||
|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | NA | ||
| Estudiante | 0 | 940 | 0 | 0 | 0 | 0 | 940 |
|
Otras, jubilada o pensionista |
0 | 0 | 0 | 49 | 132 | 0 | 181 |
| Labores del hogar | 0 | 0 | 2298 | 0 | 0 | 0 | 2298 |
| En sit. de desempleo | 843 | 0 | 0 | 0 | 0 | 0 | 843 |
| Trabajando | 0 | 0 | 0 | 0 | 0 | 3487 | 3487 |
| NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 843 | 940 | 2298 | 49 | 132 | 3487 | 7749 | χ2=NaN · df=16 · Cramer’s V=NaN · Fisher’s p=0.000 |
sjPlot::sjt.xtab(datos1999$rSitLab, datos1999$TRABAJA_f, show.na = T)
| Situación laboral |
TRABAJA EN LA SEMANA DE REFERENCIA |
Total | ||
|---|---|---|---|---|
| 1 | 6 | NA | ||
| Estudiante | 1 | 939 | 0 | 940 |
|
Otras, jubilada o pensionista |
0 | 181 | 0 | 181 |
| Labores del hogar | 0 | 2298 | 0 | 2298 |
| En sit. de desempleo | 0 | 843 | 0 | 843 |
| Trabajando | 3487 | 0 | 0 | 3487 |
| NA | 0 | 0 | 0 | 0 |
| Total | 3488 | 4261 | 0 | 7749 | χ2=7744.964 · df=4 · Cramer’s V=1.000 · p=0.000 |
#2018
datos2018 = datos2018 %>%
mutate(
rSitLab=rec(as.numeric(SITUACIONACT),
rec="NA=5;
1 = 4;
2 = 1;
3 = 3;
4:6 = 2",
as.num = F,
val.labels = ET_SitLab,
var.label = "Situación laboral")
)
datatable(as.matrix(datos2018 %>% frq(rSitLab)))
sjPlot::sjt.xtab(datos2018$rSitLab, datos2018$SITUACIONACT, show.na = T)
| Situación laboral |
Si no trabaja, cuál es su sitiación actual |
Total | ||||||
|---|---|---|---|---|---|---|---|---|
|
Parado/a buscando empleo |
Estudiante |
Dedicado a las labores de mi hogar |
Incapacitado para trabajar |
Jubilado/a, prejubilado/a, pensionista, retirado de una acti |
Otro tipo de inactividad |
NA | ||
| Estudiante | 0 | 1403 | 0 | 0 | 0 | 0 | 0 | 1403 |
|
Otras, jubilada o pensionista |
0 | 0 | 0 | 194 | 115 | 241 | 0 | 550 |
| Labores del hogar | 0 | 0 | 1564 | 0 | 0 | 0 | 0 | 1564 |
| En sit. de desempleo | 1857 | 0 | 0 | 0 | 0 | 0 | 0 | 1857 |
| Trabajando | 0 | 0 | 0 | 0 | 0 | 0 | 9182 | 9182 |
| NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 1857 | 1403 | 1564 | 194 | 115 | 241 | 9182 | 14556 | χ2=NaN · df=20 · Cramer’s V=NaN · Fisher’s p=0.000 |
sjPlot::sjt.xtab(datos2018$rSitLab, datos2018$TRABAJAACT, show.na = T)
| Situación laboral |
Tiene en estos momentos un trabajo remunerado |
Total | ||
|---|---|---|---|---|
| Si | No | NA | ||
| Estudiante | 0 | 1403 | 0 | 1403 |
|
Otras, jubilada o pensionista |
0 | 550 | 0 | 550 |
| Labores del hogar | 0 | 1564 | 0 | 1564 |
| En sit. de desempleo | 0 | 1857 | 0 | 1857 |
| Trabajando | 9182 | 0 | 0 | 9182 |
| NA | 0 | 0 | 0 | 0 |
| Total | 9182 | 5374 | 0 | 14556 | χ2=14556.000 · df=4 · Cramer’s V=1.000 · p=0.000 |
rSitLab <- c("Situación laboral", "rSitLab", "247", "rSitLab", "530", "rSitLab", "490")
datatable(as.matrix(datos1985 %>% frq(P106)))
# "1 = VIVE CON SU MARIDO O COMPAÑERO", "2 = VIVE CON SUS PADRES", "3 = OTRA SITUACION"
datatable(as.matrix(datos1985 %>% frq(P201)))
# "1 = CASADA Y VIVE CON SU MARIDO", "2 = OTRO TIPO DE UNION ESTABLE", "3 = MUJER SIN UNION ESTABLE"
xtabs(~P201+P106, data = datos1985, addNA = T)
## P106
## P201 1 2 3
## 1 5687 0 0
## 2 69 0 0
## 3 0 2595 431
datatable(as.matrix(datos1999 %>% frq(CONCONYU_f)))
# "1 = CON CONYUGE O PAREJA ESTABLE", "6 = SIN CONYUGE NI PAREJA ESTABLE"
datatable(as.matrix(datos1999 %>% frq(TIENPARE_f)))
# "1=SI", "6=NO"
datatable(as.matrix(datos1999 %>% frq(NUMORDEN_f)))
# 0 = SI EL CONYUGE O PAREJA ESTABLE NO ES MIEMBRO DEL HOGAR
xtabs(~CONCONYU_f+TIENPARE_f, data = datos1999, addNA = T)
## TIENPARE_f
## CONCONYU_f 1 6 <NA>
## 1 307 968 4614
## 6 0 0 1860
# Hay un caso que trabaja y es estudiante, se quedará como estudiante
xtabs(~NUMORDEN_f+CONCONYU_f, data = datos1999,addNA = T)
## CONCONYU_f
## NUMORDEN_f 1 6
## 0 968 0
## 1 2316 0
## 2 2407 0
## 3 106 0
## 4 63 0
## 5 22 0
## 6 5 0
## 8 1 0
## 9 1 0
## <NA> 0 1860
datatable(as.matrix(datos2018 %>% frq(SITSENTI)))
datatable(as.matrix(datos2018 %>% frq(PARNOCONVI)))
xtabs(~SITSENTI+PARNOCONVI, data = datos2018, addNA = T)
## PARNOCONVI
## SITSENTI Si No <NA>
## Sin pareja 0 3839 0
## Pareja con la que convive 0 0 8808
## Pareja con la que no convive 1909 0 0
# Para homogenizar etiquetas se recodifican, aunque la situación de Pareja con la que no se convive no se puede extraer de 1985
## 1985
datos1985 = datos1985 %>%
mutate(
rConvPar=rec(as.numeric(P106),
rec="1 = 3;
2:3 =1",
as.num = F,
val.labels = c("Sin unión estable","Convive con pareja"),
var.label = "Situación sentimental y convivencia")
)
datatable(as.matrix(datos1985%>% frq(rConvPar)))
xtabs(~P106+rConvPar, data = datos1985, addNA = T)
## rConvPar
## P106 1 3
## 1 0 5756
## 2 2595 0
## 3 431 0
xtabs(~P201+rConvPar, data = datos1985, addNA = T)
## rConvPar
## P201 1 3
## 1 0 5687
## 2 0 69
## 3 3026 0
## 1999
datos1999 = datos1999 %>%
mutate(
rConvPar=rec(as.numeric(NUMORDEN_f),
rec="NA=1;
0 = 2;
1:9 = 3",
as.num = F,
val.labels = c("Sin pareja","Pareja con la que no convive", "Convive con pareja"),
var.label = "Situación sentimental y convivencia")
)
datatable(as.matrix(datos1999 %>% frq(rConvPar)))
xtabs(~NUMORDEN_f+rConvPar, data = datos1999, addNA = T)
## rConvPar
## NUMORDEN_f 1 2 3
## 0 0 968 0
## 1 0 0 2316
## 2 0 0 2407
## 3 0 0 106
## 4 0 0 63
## 5 0 0 22
## 6 0 0 5
## 8 0 0 1
## 9 0 0 1
## <NA> 1860 0 0
xtabs(~CONCONYU_f+rConvPar, data = datos1999, addNA = T)
## rConvPar
## CONCONYU_f 1 2 3
## 1 0 968 4921
## 6 1860 0 0
## 2018
datos2018 = datos2018 %>%
mutate(
rConvPar=rec(as.numeric(SITSENTI),
rec="1 = 1;
2 = 3;
3 = 2",
as.num = F,
val.labels = c("Sin pareja","Pareja con la que no convive", "Convive con pareja"),
var.label = "Situación sentimental y convivencia")
)
datatable(as.matrix(datos2018 %>% frq(rConvPar)))
datatable(as.matrix(datos2018 %>% flat_table(SITSENTI, rConvPar)))
rConvPar <- c("Situación sentimental y convivencia",
"rConvPar", "248", "rConvPar", "531", "rConvPar", "491")
datatable(as.matrix(datos1985 %>% frq(P414)))
# Et1985_P414 <- c("1 = NO ESTA EMBARAZADA, NI DECLARO TENER HIJOS", "6 = SI ESTA EMBARAZADA Y/O DECLARO TENER HIJOS")
datatable(as.matrix(datos1985 %>% frq(P410, out = "v")))
# TOTAL DE HIJOS NACIDOS VIVOS 1-20
datatable(as.matrix(datos1985 %>% frq(Q424)))
# NUMERO TOTAL DE HIJOS NACIDOS MUERTOS.00 = NO HAY DATO;01 - 20, 88 = SIGNIFICA 0 AÑOS
datatable(as.matrix(datos1985 %>% frq(Q422)))
# NUMERO TOTAL DE HIJOS ACTUALMENTE VIVOS. 00 = NO HAY DATO;01 - 20, 88 = SIGNIFICA 0 AÑOS
datatable(as.matrix(datos1985 %>% frq(P401)))
# Embarazada actualmente. Etiq.: "1 = SI", "6 = NO, NO SABE")
datatable(as.data.frame(datos1985 [, c(125, 146, 145)]))
datatable(as.matrix(datos1985 %>% filter(P401 == 1) %>% flat_table(P410, P414))) # embarazadas
# Pocos datos de mujeres con primer embarazo (0 hijos/as), 93 casos
datatable(as.matrix(datos1985 %>% filter(P401 == 6) %>% flat_table(P410, P414))) # NO embarazadas
# Entre no embarazadas, 37 no tienen hijos nacidos vivos, pero declararon tener hijos/as, se toma como referencia las frecuencias la P410, independientemente de Q422
datatable(as.matrix(datos1985 %>% frq(P5012)))
datatable(as.matrix(datos1985 %>% frq(P5014)))
datatable(as.matrix(datos1985 %>% frq(P502))) # donde 6 es nunca emabarazada
datatable(as.matrix(datos1985 %>% flat_table(P414, P502)))
# a) 35 casos de mujeres que nunca emabarazadas, pero declaran tener hijos/as
# b) 69 casos de mujeres embarazadas, que declaran no tener hijos/as
datatable(as.matrix(datos1985 %>% filter(P502 == 6 & P414 == 6) %>% flat_table(Q424, Q422)))
# a) no se tienen datos sobre el nº de hijos/as (pueden ser adoptados/as, de la pareja...)
datatable(as.matrix(datos1985 %>% filter(P502 == 1 & P414 == 1) %>% flat_table(Q424, Q422)))
# b) 59 corresponde a que no hay dato (0 - seguramente por ser pregunta filtrada)
datatable(as.matrix(datos1985 %>% flat_table(P5012, P410)))
datatable(as.matrix(datos1999 %>% frq(EMBARAZA_f)))
# "1 = SI","2 = NO, NO TIENE PAREJA NI RELACIONES OCASIONALES",
# "3 = NO, TIENE UN IMPEDIMETO FISICO QUE LE IMPIDE TENER HIJOS",
# "4 = NO, POR OTROS MOTIVOS", "5 = NO LO SABE")
datatable(as.matrix(datos1999 %>% frq(VIVO_f)))
datatable(as.matrix(datos1999 %>% frq(NUMHIJOS_f)))
datatable(as.matrix(datos1999 %>% frq(EMBANT_f)))
# Embarazada anteriormente 1 sí, 6 no
datatable(as.matrix(datos1999 %>% filter(EMBARAZA_f != 1 & EMBANT_f == 6) %>% frq(NUMHIJOS_f)))
datatable(as.matrix(datos1999 %>% frq(HIJOADOP_f)))
## Algún hijo/a adoptado. 1=sí, 6 = no
xtabs(~NUMHIJOS_f+HIJOADOP_f, data = datos1999, addNA = T)
## HIJOADOP_f
## NUMHIJOS_f 1 6
## 1 3 1445
## 2 1 2325
## 3 0 705
## 4 0 157
## 5 0 57
## 6 0 17
## 7 0 6
## 8 0 2
## 9 0 2
## <NA> 17 3012
# los datos de 1999 de nº de hijos/as incluyen todos/as
datatable(as.matrix(datos2018 %>% frq(NHIJOBIO)))
datatable(as.matrix(datos2018 %>% frq(NHIJOS)))
datatable(as.matrix(datos2018 %>% frq(NHBIOADOP)))
datatable(as.matrix(datos2018 %>% frq(TIPOHIJO)))
datatable(as.matrix(datos2018 %>% frq(HIJOSNOHOGAR)))
datatable(as.matrix(datos2018 %>% frq(HIJOSPAR)))
datatable(as.matrix(datos2018 %>% filter(HIJOSPAR == "No") %>% flat_table(NHIJOBIO,HIJOSNOHOGAR)))
## 1985
datos1985 = datos1985 %>%
mutate(
rNumHij= rec(as.numeric(P410),
rec = "else=copy",
as.num = T,
var.label = "Número de hijos/as")
)
datatable(as.matrix(datos1985 %>% frq(rNumHij)))
datatable(as.matrix(datos1985 %>% flat_table(rNumHij, P410)))
## 1999
datos1999 = datos1999 %>%
mutate(
rNumHij=rec(as.numeric(NUMHIJOS_f),
rec="NA=0;
else=copy",
as.num = T,
var.label = "Número de hijos/as")
)
datatable(as.matrix(datos1999 %>% frq(rNumHij)))
xtabs(~rNumHij+NUMHIJOS_f, data = datos1999, addNA = T)
## NUMHIJOS_f
## rNumHij 1 2 3 4 5 6 7 8 9 <NA>
## 0 0 0 0 0 0 0 0 0 0 3029
## 1 1448 0 0 0 0 0 0 0 0 0
## 2 0 2326 0 0 0 0 0 0 0 0
## 3 0 0 705 0 0 0 0 0 0 0
## 4 0 0 0 157 0 0 0 0 0 0
## 5 0 0 0 0 57 0 0 0 0 0
## 6 0 0 0 0 0 17 0 0 0 0
## 7 0 0 0 0 0 0 6 0 0 0
## 8 0 0 0 0 0 0 0 2 0 0
## 9 0 0 0 0 0 0 0 0 2 0
## 2018
datos2018 = datos2018 %>%
mutate(
rNumHij= rec(as.numeric(NHIJOS),
rec = "else=copy",
as.num = T,
var.label = "Número de hijos/as")
)
datatable(as.matrix(datos2018 %>% frq(rNumHij)))
datatable(as.matrix(datos2018 %>% flat_table(rNumHij, NHIJOS)))
rNumHij <- c("Número de hijos/as",
"rNumHij", "249", "rNumHij", "532", "rNumHij", "492")
Et_rTrNumHij <- c("Ningún hijo/a","Un hijo/a", "Dos hijos/as", "Tres o más hijos/as")
## 1985
datos1985 = datos1985 %>%
mutate(
rTrNumHij=rec(as.numeric(rNumHij),
rec="0 = 0;
1 = 1;
2 = 2;
3:13 = 3",
as.num = F,
val.labels = Et_rTrNumHij,
var.label = "Número de hijos/as (agregada)")
)
datatable(as.matrix(datos1985%>% frq(rTrNumHij)))
xtabs(~rNumHij+rTrNumHij, data = datos1985, addNA = T)
## rTrNumHij
## rNumHij 0 1 2 3
## 0 3306 0 0 0
## 1 0 1185 0 0
## 2 0 0 2155 0
## 3 0 0 0 1244
## 4 0 0 0 513
## 5 0 0 0 209
## 6 0 0 0 89
## 7 0 0 0 38
## 8 0 0 0 24
## 9 0 0 0 8
## 10 0 0 0 7
## 11 0 0 0 1
## 12 0 0 0 2
## 13 0 0 0 1
## 1999
datos1999 = datos1999 %>%
mutate(
rTrNumHij=rec(as.numeric(rNumHij),
rec="0 = 0;
1 = 1;
2 = 2;
3:13 = 3",
as.num = F,
val.labels = Et_rTrNumHij,
var.label = "Número de hijos/as (agregada)")
)
datatable(as.matrix(datos1999 %>% frq(rTrNumHij)))
xtabs(~rNumHij+rTrNumHij, data = datos1999, addNA = T)
## rTrNumHij
## rNumHij 0 1 2 3
## 0 3029 0 0 0
## 1 0 1448 0 0
## 2 0 0 2326 0
## 3 0 0 0 705
## 4 0 0 0 157
## 5 0 0 0 57
## 6 0 0 0 17
## 7 0 0 0 6
## 8 0 0 0 2
## 9 0 0 0 2
### 2018
datos2018 = datos2018 %>%
mutate(
rTrNumHij=rec(as.numeric(rNumHij),
rec="0 = 0;
1 = 1;
2 = 2;
3:13 = 3",
as.num = F,
val.labels = Et_rTrNumHij,
var.label = "Número de hijos/as(agregada)")
)
datatable(as.matrix(datos2018 %>% frq(rTrNumHij)))
xtabs(~rNumHij+rTrNumHij, data = datos2018, addNA = T)
## rTrNumHij
## rNumHij 0 1 2 3
## 0 5730 0 0 0
## 1 0 3124 0 0
## 2 0 0 4460 0
## 3 0 0 0 968
## 4 0 0 0 184
## 5 0 0 0 62
## 6 0 0 0 13
## 7 0 0 0 13
## 8 0 0 0 1
## 9 0 0 0 1
rTrNumHij <- c("Número de hijos/as (catego.)",
"rTrNumHij", "250", "rTrNumHij", "533", "rTrNumHij", "493")
datatable(as.matrix(datos1985 %>% frq(PAXX1)))
datatable(as.matrix(datos1985 %>% frq(PAXX2)))
xtabs(~PAXX2+P414, data = datos1985, addNA = T)
## P414
## PAXX2 1 6
## 0 3107 120
## 52 0 1
## 53 0 1
## 54 0 7
## 55 0 14
## 56 0 13
## 57 0 29
## 58 0 50
## 59 0 70
## 60 0 127
## 61 0 138
## 62 0 154
## 63 0 185
## 64 1 161
## 65 0 186
## 66 0 178
## 67 1 212
## 68 1 201
## 69 1 250
## 70 2 240
## 71 3 265
## 72 2 243
## 73 1 255
## 74 0 275
## 75 1 275
## 76 4 243
## 77 5 257
## 78 2 241
## 79 6 239
## 80 4 217
## 81 8 193
## 82 3 180
## 83 5 155
## 84 9 158
## 85 10 73
xtabs(~PAXX2+P410, data = datos1985, addNA = T)
## P410
## PAXX2 0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 3227 0 0 0 0 0 0 0 0 0 0 0 0 0
## 52 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## 53 0 1 0 0 0 0 0 0 0 0 0 0 0 0
## 54 0 1 3 1 0 1 1 0 0 0 0 0 0 0
## 55 0 0 2 3 2 2 3 1 0 0 1 0 0 0
## 56 0 1 1 4 2 1 1 1 2 0 0 0 0 0
## 57 0 3 3 5 5 4 5 1 0 2 0 1 0 0
## 58 0 3 12 14 6 3 6 2 3 0 0 0 1 0
## 59 0 3 13 22 12 8 4 3 3 0 2 0 0 0
## 60 0 2 40 38 23 8 6 4 1 2 3 0 0 0
## 61 0 9 39 36 23 17 8 3 2 1 0 0 0 0
## 62 0 11 47 45 28 14 6 0 3 0 0 0 0 0
## 63 0 6 53 61 34 15 10 2 2 0 1 0 0 1
## 64 1 4 52 58 23 11 5 5 2 1 0 0 0 0
## 65 0 10 52 57 42 15 7 1 1 1 0 0 0 0
## 66 0 12 52 68 25 11 4 5 0 1 0 0 0 0
## 67 1 10 75 62 42 16 4 3 0 0 0 0 0 0
## 68 1 19 75 58 30 13 4 0 1 0 0 0 1 0
## 69 1 21 84 80 45 12 5 3 0 0 0 0 0 0
## 70 2 25 97 71 27 13 2 4 1 0 0 0 0 0
## 71 3 22 124 76 29 9 2 0 3 0 0 0 0 0
## 72 2 16 122 73 21 10 1 0 0 0 0 0 0 0
## 73 1 21 120 80 18 12 4 0 0 0 0 0 0 0
## 74 0 38 126 77 25 8 1 0 0 0 0 0 0 0
## 75 1 36 147 72 17 3 0 0 0 0 0 0 0 0
## 76 4 47 133 49 12 2 0 0 0 0 0 0 0 0
## 77 5 45 138 59 14 1 0 0 0 0 0 0 0 0
## 78 2 55 153 30 3 0 0 0 0 0 0 0 0 0
## 79 6 74 135 27 3 0 0 0 0 0 0 0 0 0
## 80 4 96 110 10 1 0 0 0 0 0 0 0 0 0
## 81 8 116 73 4 0 0 0 0 0 0 0 0 0 0
## 82 4 128 49 2 0 0 0 0 0 0 0 0 0 0
## 83 6 131 21 2 0 0 0 0 0 0 0 0 0 0
## 84 17 147 3 0 0 0 0 0 0 0 0 0 0 0
## 85 10 72 1 0 0 0 0 0 0 0 0 0 0 0
datatable(as.matrix(datos1985 %>% frq(P401)))
# Hay casos extraños: 0 hijos/as, pero luego se indica el mes de nacimiento, no se tendrán en cuenta y se considerarán como perdidos
datatable(as.matrix(datos1999 %>% frq(EDADPR_f)))
xtabs(~EDADPR_f+rTrNumHij, data = datos1999, addNA = T)
## rTrNumHij
## EDADPR_f 0 1 2 3
## 12 0 1 0 1
## 13 0 2 0 1
## 14 0 0 0 3
## 15 0 2 11 13
## 16 0 7 17 14
## 17 0 29 43 39
## 18 0 34 80 52
## 19 0 52 103 81
## 20 0 52 124 98
## 21 0 60 182 106
## 22 0 73 219 115
## 23 0 80 253 107
## 24 0 98 235 77
## 25 0 104 232 86
## 26 0 124 204 59
## 27 0 119 172 33
## 28 0 123 123 21
## 29 0 88 104 17
## 30 0 97 72 10
## 31 0 81 48 5
## 32 0 57 34 1
## 33 0 39 29 4
## 34 0 47 16 1
## 35 0 24 13 2
## 36 0 8 3 0
## 37 0 12 2 0
## 38 0 13 2 0
## 39 0 8 4 0
## 40 0 7 0 0
## 41 0 4 1 0
## 42 0 2 0 0
## 46 0 1 0 0
## <NA> 3029 0 0 0
datatable(as.matrix(datos2018 %>% frq(EDADHIJO1)))
xtabs(~EDADHIJO1+rTrNumHij, data = datos2018, addNA = T)
## rTrNumHij
## EDADHIJO1 0 1 2 3
## 10 0 2 0 0
## 12 0 0 1 0
## 13 0 1 0 0
## 14 0 0 1 8
## 15 0 6 9 12
## 16 0 15 27 30
## 17 0 23 69 45
## 18 0 40 76 76
## 19 0 53 97 70
## 20 0 53 126 82
## 21 0 68 145 65
## 22 0 64 139 64
## 23 0 66 164 73
## 24 0 94 195 61
## 25 0 107 229 63
## 26 0 119 258 63
## 27 0 154 273 65
## 28 0 165 335 73
## 29 0 178 335 67
## 30 0 185 349 53
## 31 0 213 321 64
## 32 0 219 266 31
## 33 0 169 246 28
## 34 0 190 171 32
## 35 0 147 137 24
## 36 0 123 89 16
## 37 0 92 50 3
## 38 0 97 40 5
## 39 0 54 19 1
## 40 0 48 12 2
## 41 0 23 4 0
## 42 0 17 4 5
## 43 0 10 2 1
## 44 0 9 0 0
## 45 0 6 2 0
## 46 0 1 0 0
## 47 0 1 0 0
## 48 0 2 0 0
## 49 0 2 0 0
## <NA> 5730 308 269 60
xtabs(~EDADHIJO1+rNumHij, data = datos2018, addNA = T)
## rNumHij
## EDADHIJO1 0 1 2 3 4 5 6 7 8 9
## 10 0 2 0 0 0 0 0 0 0 0
## 12 0 0 1 0 0 0 0 0 0 0
## 13 0 1 0 0 0 0 0 0 0 0
## 14 0 0 1 3 2 2 0 1 0 0
## 15 0 6 9 4 6 0 2 0 0 0
## 16 0 15 27 20 6 3 1 0 0 0
## 17 0 23 69 31 8 5 1 0 0 0
## 18 0 40 76 45 24 5 1 1 0 0
## 19 0 53 97 51 12 4 1 2 0 0
## 20 0 53 126 57 15 8 1 1 0 0
## 21 0 68 145 49 10 4 0 2 0 0
## 22 0 64 139 49 9 4 1 1 0 0
## 23 0 66 164 48 17 5 1 2 0 0
## 24 0 94 195 47 6 8 0 0 0 0
## 25 0 107 229 47 13 2 1 0 0 0
## 26 0 119 258 55 6 0 1 0 0 1
## 27 0 154 273 56 6 2 0 0 1 0
## 28 0 165 335 58 9 4 1 1 0 0
## 29 0 178 335 61 5 1 0 0 0 0
## 30 0 185 349 50 2 0 0 1 0 0
## 31 0 213 321 50 11 3 0 0 0 0
## 32 0 219 266 29 1 0 0 1 0 0
## 33 0 169 246 26 2 0 0 0 0 0
## 34 0 190 171 29 3 0 0 0 0 0
## 35 0 147 137 24 0 0 0 0 0 0
## 36 0 123 89 16 0 0 0 0 0 0
## 37 0 92 50 3 0 0 0 0 0 0
## 38 0 97 40 4 1 0 0 0 0 0
## 39 0 54 19 1 0 0 0 0 0 0
## 40 0 48 12 1 1 0 0 0 0 0
## 41 0 23 4 0 0 0 0 0 0 0
## 42 0 17 4 3 2 0 0 0 0 0
## 43 0 10 2 1 0 0 0 0 0 0
## 44 0 9 0 0 0 0 0 0 0 0
## 45 0 6 2 0 0 0 0 0 0 0
## 46 0 1 0 0 0 0 0 0 0 0
## 47 0 1 0 0 0 0 0 0 0 0
## 48 0 2 0 0 0 0 0 0 0 0
## 49 0 2 0 0 0 0 0 0 0 0
## <NA> 5730 308 269 50 7 2 1 0 0 0
xtabs(~EDADHIJO1+NHIJOBIO, data = datos2018, addNA = T)
## NHIJOBIO
## EDADHIJO1 0 1 2 3 4 5 6 7 8 9
## 10 0 2 0 0 0 0 0 0 0 0
## 12 0 0 1 0 0 0 0 0 0 0
## 13 0 1 0 0 0 0 0 0 0 0
## 14 0 0 1 4 2 1 0 1 0 0
## 15 0 7 9 5 5 0 1 0 0 0
## 16 0 16 28 20 6 2 0 0 0 0
## 17 0 25 72 28 9 2 1 0 0 0
## 18 0 41 80 43 21 5 1 1 0 0
## 19 0 57 96 50 12 5 0 0 0 0
## 20 0 57 127 54 14 8 0 1 0 0
## 21 0 75 142 48 8 3 0 2 0 0
## 22 0 68 138 46 9 4 1 1 0 0
## 23 0 79 159 49 13 1 1 1 0 0
## 24 0 101 199 41 3 6 0 0 0 0
## 25 0 112 236 40 10 1 0 0 0 0
## 26 0 126 266 42 5 0 0 0 0 1
## 27 0 165 271 49 5 1 0 0 1 0
## 28 0 174 338 52 4 3 1 1 0 0
## 29 0 188 336 54 1 1 0 0 0 0
## 30 0 196 340 48 2 0 0 1 0 0
## 31 0 223 325 45 4 1 0 0 0 0
## 32 0 226 264 25 1 0 0 0 0 0
## 33 0 175 244 22 2 0 0 0 0 0
## 34 0 203 167 23 0 0 0 0 0 0
## 35 0 157 134 17 0 0 0 0 0 0
## 36 0 130 85 13 0 0 0 0 0 0
## 37 0 96 48 1 0 0 0 0 0 0
## 38 0 103 37 2 0 0 0 0 0 0
## 39 0 62 12 0 0 0 0 0 0 0
## 40 0 54 8 0 0 0 0 0 0 0
## 41 0 25 2 0 0 0 0 0 0 0
## 42 0 19 6 1 0 0 0 0 0 0
## 43 0 11 2 0 0 0 0 0 0 0
## 44 0 9 0 0 0 0 0 0 0 0
## 45 0 6 2 0 0 0 0 0 0 0
## 46 0 1 0 0 0 0 0 0 0 0
## 47 0 1 0 0 0 0 0 0 0 0
## 48 0 2 0 0 0 0 0 0 0 0
## 49 0 2 0 0 0 0 0 0 0 0
## <NA> 6367 0 0 0 0 0 0 0 0 0
# Los pérdidos de EDADHIJO1 corresponden a 0 hijos/as y a quienes tienen hijos/as biológicos
## 1985
# Como perdidos los casos de 0 hijos/as
datos1985 = datos1985 %>%
mutate(
r1HijEd_aux =rec(as.numeric(rNumHij),
rec="0 = NA;
else = 0",
as.num = T)
)
datatable(as.matrix(datos1985 %>% frq(r1HijEd_aux)))
xtabs(~rNumHij+r1HijEd_aux, data = datos1985, addNA = T)
## r1HijEd_aux
## rNumHij 0 <NA>
## 0 0 3306
## 1 1185 0
## 2 2155 0
## 3 1244 0
## 4 513 0
## 5 209 0
## 6 89 0
## 7 38 0
## 8 24 0
## 9 8 0
## 10 7 0
## 11 1 0
## 12 2 0
## 13 1 0
# Cálculo de la edad del 1 hij en la recogida de datos los datos se debieron tomar en mayo (mes 5)
# Se crea nueva variable aux con 0 si nacieron entre ene (1) y abril (4), y -1 entre may y dic
datos1985 = datos1985 %>%
mutate(
r1HijEd_aux1 =rec(as.numeric(PAXX1),
rec="0 = NA;
1:4 = 0;
5:12 = - 1",
as.num = T)
)
datatable(as.matrix(datos1985 %>% frq(r1HijEd_aux1)))
xtabs(~PAXX1+r1HijEd_aux1, data = datos1985, addNA = T)
## r1HijEd_aux1
## PAXX1 -1 0 <NA>
## 0 0 0 3227
## 1 0 432 0
## 2 0 449 0
## 3 0 453 0
## 4 0 494 0
## 5 514 0 0
## 6 493 0 0
## 7 510 0 0
## 8 511 0 0
## 9 459 0 0
## 10 432 0 0
## 11 368 0 0
## 12 440 0 0
# Se resta 85 (datos de 1985) al año de nacimiento + la nueva variable aux de mes de nacimiento + variable dummy 0 hijos como NA
datos1985 = datos1985 %>%
mutate(r1HijEdad_aux2 = 85 - (PAXX2-r1HijEd_aux1 + r1HijEd_aux))
datatable(as.matrix(datos1985 %>% frq(r1HijEdad_aux2)))
xtabs(~r1HijEdad_aux2+r1HijEd_aux, data = datos1985, addNA = T)
## r1HijEd_aux
## r1HijEdad_aux2 0 <NA>
## -1 15 0
## 0 165 0
## 1 144 0
## 2 173 0
## 3 188 0
## 4 207 0
## 5 247 0
## 6 215 0
## 7 266 0
## 8 244 0
## 9 265 0
## 10 288 0
## 11 245 0
## 12 254 0
## 13 268 0
## 14 245 0
## 15 244 0
## 16 225 0
## 17 189 0
## 18 188 0
## 19 186 0
## 20 170 0
## 21 178 0
## 22 177 0
## 23 136 0
## 24 129 0
## 25 93 0
## 26 46 0
## 27 41 0
## 28 14 0
## 29 16 0
## 30 11 0
## 31 2 0
## 32 2 0
## <NA> 0 3306
xtabs(~PAXX2+r1HijEdad_aux2, data = datos1985, addNA = T)
## r1HijEdad_aux2
## PAXX2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 53 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 54 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 57 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 59 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 62 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 63 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 67 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 69 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 72 0 0 0 0 0 0 0 0 0 0 0 0 0 165
## 73 0 0 0 0 0 0 0 0 0 0 0 0 166 89
## 74 0 0 0 0 0 0 0 0 0 0 0 196 79 0
## 75 0 0 0 0 0 0 0 0 0 0 183 92 0 0
## 76 0 0 0 0 0 0 0 0 0 161 82 0 0 0
## 77 0 0 0 0 0 0 0 0 174 83 0 0 0 0
## 78 0 0 0 0 0 0 0 149 92 0 0 0 0 0
## 79 0 0 0 0 0 0 173 66 0 0 0 0 0 0
## 80 0 0 0 0 0 143 74 0 0 0 0 0 0 0
## 81 0 0 0 0 129 64 0 0 0 0 0 0 0 0
## 82 0 0 0 120 59 0 0 0 0 0 0 0 0 0
## 83 0 0 101 53 0 0 0 0 0 0 0 0 0 0
## 84 0 107 43 0 0 0 0 0 0 0 0 0 0 0
## 85 15 58 0 0 0 0 0 0 0 0 0 0 0 0
## r1HijEdad_aux2
## PAXX2 13 14 15 16 17 18 19 20 21 22 23 24 25 26
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 53 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 54 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 57 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 58 0 0 0 0 0 0 0 0 0 0 0 0 0 29
## 59 0 0 0 0 0 0 0 0 0 0 0 0 53 17
## 60 0 0 0 0 0 0 0 0 0 0 0 87 40 0
## 61 0 0 0 0 0 0 0 0 0 0 96 42 0 0
## 62 0 0 0 0 0 0 0 0 0 114 40 0 0 0
## 63 0 0 0 0 0 0 0 0 122 63 0 0 0 0
## 64 0 0 0 0 0 0 0 105 56 0 0 0 0 0
## 65 0 0 0 0 0 0 121 65 0 0 0 0 0 0
## 66 0 0 0 0 0 113 65 0 0 0 0 0 0 0
## 67 0 0 0 0 137 75 0 0 0 0 0 0 0 0
## 68 0 0 0 149 52 0 0 0 0 0 0 0 0 0
## 69 0 0 174 76 0 0 0 0 0 0 0 0 0 0
## 70 0 170 70 0 0 0 0 0 0 0 0 0 0 0
## 71 190 75 0 0 0 0 0 0 0 0 0 0 0 0
## 72 78 0 0 0 0 0 0 0 0 0 0 0 0 0
## 73 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 74 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 75 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 76 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 77 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 79 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 81 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 82 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 83 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 84 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## r1HijEdad_aux2
## PAXX2 27 28 29 30 31 32 <NA>
## 0 0 0 0 0 0 0 3227
## 52 0 0 0 0 0 1 0
## 53 0 0 0 0 0 1 0
## 54 0 0 0 5 2 0 0
## 55 0 0 8 6 0 0 0
## 56 0 5 8 0 0 0 0
## 57 20 9 0 0 0 0 0
## 58 21 0 0 0 0 0 0
## 59 0 0 0 0 0 0 0
## 60 0 0 0 0 0 0 0
## 61 0 0 0 0 0 0 0
## 62 0 0 0 0 0 0 0
## 63 0 0 0 0 0 0 0
## 64 0 0 0 0 0 0 1
## 65 0 0 0 0 0 0 0
## 66 0 0 0 0 0 0 0
## 67 0 0 0 0 0 0 1
## 68 0 0 0 0 0 0 1
## 69 0 0 0 0 0 0 1
## 70 0 0 0 0 0 0 2
## 71 0 0 0 0 0 0 3
## 72 0 0 0 0 0 0 2
## 73 0 0 0 0 0 0 1
## 74 0 0 0 0 0 0 0
## 75 0 0 0 0 0 0 1
## 76 0 0 0 0 0 0 4
## 77 0 0 0 0 0 0 5
## 78 0 0 0 0 0 0 2
## 79 0 0 0 0 0 0 6
## 80 0 0 0 0 0 0 4
## 81 0 0 0 0 0 0 8
## 82 0 0 0 0 0 0 4
## 83 0 0 0 0 0 0 6
## 84 0 0 0 0 0 0 17
## 85 0 0 0 0 0 0 10
# Se recodifica el -1 como 0 --> esta sería la edad de los/as hijos/as
datos1985 = datos1985 %>%
mutate(
r1HijEdad_aux3 =rec(as.numeric(r1HijEdad_aux2),
rec="-1 = 0;
else = copy",
as.num = T)
)
datatable(as.matrix(datos1985 %>% frq(r1HijEdad_aux3)))
# Cálculo de la edad madre - edad al 1º hijo (en 1985)
datos1985 = datos1985 %>%
mutate(r1HijEdad = rEdad - r1HijEdad_aux3)
labelled::var_label(datos1985$r1HijEdad) <- "Edad al primer hijo/a"
datatable(as.matrix(datos1985 %>% frq(r1HijEdad)))
xtabs(~r1HijEdad+rNumHij, data = datos1985, addNA = T)
## rNumHij
## r1HijEdad 0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 7 0 0 0 0 0 1 0 0 0 0 0 0 0 0
## 11 0 0 0 1 0 0 0 0 0 0 0 0 0 0
## 12 0 0 0 1 1 0 0 0 0 0 0 0 0 0
## 13 0 0 0 2 0 0 0 0 0 0 0 0 0 0
## 14 0 0 1 0 0 0 1 0 0 0 0 0 0 0
## 15 0 1 5 0 2 3 0 0 1 0 0 0 0 0
## 16 0 5 14 13 4 1 2 1 0 0 0 0 0 0
## 17 0 15 17 7 7 8 4 0 1 1 0 0 0 0
## 18 0 29 52 26 18 6 3 3 2 0 2 0 0 0
## 19 0 50 53 42 23 9 5 3 0 1 2 0 0 0
## 20 0 71 104 72 44 15 12 5 3 2 0 1 0 1
## 21 0 87 149 100 37 21 11 6 2 0 1 0 0 0
## 22 0 100 200 132 65 23 9 2 5 1 1 0 0 0
## 23 0 108 215 168 66 23 11 5 2 0 0 0 1 0
## 24 0 120 286 174 70 30 9 4 2 1 1 0 0 0
## 25 0 115 291 150 55 26 5 3 4 1 0 0 1 0
## 26 0 98 226 112 36 15 10 4 2 0 0 0 0 0
## 27 0 74 166 95 27 11 3 2 0 0 0 0 0 0
## 28 0 73 109 61 25 7 4 0 0 0 0 0 0 0
## 29 0 68 85 32 12 5 0 0 0 0 0 0 0 0
## 30 0 40 58 25 5 1 0 0 0 1 0 0 0 0
## 31 0 30 30 9 8 2 0 0 0 0 0 0 0 0
## 32 0 31 25 6 3 1 0 0 0 0 0 0 0 0
## 33 0 15 17 5 3 1 0 0 0 0 0 0 0 0
## 34 0 12 19 3 2 0 0 0 0 0 0 0 0 0
## 35 0 7 10 2 0 0 0 0 0 0 0 0 0 0
## 36 0 15 5 1 0 0 0 0 0 0 0 0 0 0
## 37 0 5 9 3 0 0 0 0 0 0 0 0 0 0
## 38 0 4 5 0 0 0 0 0 0 0 0 0 0 0
## 39 0 4 1 1 0 0 0 0 0 0 0 0 0 0
## 40 0 1 2 1 0 0 0 0 0 0 0 0 0 0
## 41 0 2 0 0 0 0 0 0 0 0 0 0 0 0
## 42 0 3 0 0 0 0 0 0 0 0 0 0 0 0
## 43 0 1 1 0 0 0 0 0 0 0 0 0 0 0
## 44 0 1 0 0 0 0 0 0 0 0 0 0 0 0
## <NA> 3306 0 0 0 0 0 0 0 0 0 0 0 0 0
# Se exploran los casos extraños a partir de año nacim mujer y año nacim 1º hij
datatable(as.matrix(datos1985 %>% filter(r1HijEdad < 16) %>% flat_table(P1012, PAXX2)))
datatable(as.matrix(datos1985 %>% filter(r1HijEdad == 7) %>% flat_table(P1012, PAXX2)))
# Hay un caso con la edad del 1º hijo a los 7, sin embargo, la madre nace en 1945 y el hijo/a en el 63, no parece error de la recodificación
## 1999
datos1999 = datos1999 %>%
mutate(
r1HijEdad= rec(as.numeric(EDADPR_f),
rec = "else=copy",
as.num = T,
var.label = "Edad al primer hijo/a")
)
datatable(as.matrix(datos1999 %>% frq(r1HijEdad)))
## 2018
datos2018 = datos2018 %>%
mutate(
r1HijEdad= rec(as.numeric(EDADHIJO1),
rec = "else=copy",
as.num = T,
var.label = "Edad al primer hijo/a")
)
datatable(as.matrix(datos2018 %>% frq(r1HijEdad)))
r1HijEdad <- c("Edad al primer hijo/a",
"r1HijEdad", "255", "r1HijEdad", "534", "r1HijEdad", "494" )
## 1985
datatable(as.matrix(datos1985 %>% frq(P435)))
datatable(as.data.frame(datos1985 <- datos1985 %>% mutate(rNumDesHij=P435)))
labelled::var_label(datos1985$rNumDesHij) <- "Número de hijos/as deseado"
datatable(as.matrix(frq(datos1985$rNumDesHij)))
xtabs(~rNumDesHij+P435, data = datos1985, addNA = T)
## P435
## rNumDesHij 0 1 2 3 4 5 6 7 8 9 10
## 0 14 0 0 0 0 0 0 0 0 0 0
## 1 0 431 0 0 0 0 0 0 0 0 0
## 2 0 0 4358 0 0 0 0 0 0 0 0
## 3 0 0 0 2642 0 0 0 0 0 0 0
## 4 0 0 0 0 930 0 0 0 0 0 0
## 5 0 0 0 0 0 191 0 0 0 0 0
## 6 0 0 0 0 0 0 132 0 0 0 0
## 7 0 0 0 0 0 0 0 26 0 0 0
## 8 0 0 0 0 0 0 0 0 39 0 0
## 9 0 0 0 0 0 0 0 0 0 7 0
## 10 0 0 0 0 0 0 0 0 0 0 12
## 1999
datatable(as.matrix(datos1999 %>% frq(COINCIDE_f)))
# 1 sí 2 no . Para quienes tienen hijos/as
xtabs(~rNumHij+COINCIDE_f, data = datos1999, addNA = T)
## COINCIDE_f
## rNumHij 1 2 <NA>
## 0 0 0 3029
## 1 526 922 0
## 2 1730 596 0
## 3 508 197 0
## 4 101 56 0
## 5 31 26 0
## 6 4 13 0
## 7 4 2 0
## 8 1 1 0
## 9 2 0 0
datatable(as.matrix(datos1999 %>% frq(NUMDESE2_f)))
xtabs(~rNumHij+NUMDESE2_f, data = datos1999, addNA = T)
## NUMDESE2_f
## rNumHij 0 1 2 3 4 5 6 7 8 10 11 12 15 <NA>
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3029
## 1 8 0 683 192 31 3 2 1 1 1 0 0 0 526
## 2 4 33 0 415 100 20 15 4 1 2 1 1 0 1730
## 3 4 15 93 0 49 19 11 4 0 1 0 0 1 508
## 4 1 1 25 17 0 6 6 0 0 0 0 0 0 101
## 5 1 0 11 6 2 0 3 1 1 1 0 0 0 31
## 6 0 0 3 3 5 0 0 0 1 0 0 1 0 4
## 7 1 0 0 1 0 0 0 0 0 0 0 0 0 4
## 8 0 0 0 0 1 0 0 0 0 0 0 0 0 1
## 9 0 0 0 0 0 0 0 0 0 0 0 0 0 2
# filtrada para quienes tienen algún hijo + NO COINCIDE
datatable(as.matrix(datos1999 %>% frq(DESEOHIJ_f)))
# 1 sí 2 no
# filtro desde a 0 hijos/as
xtabs(~rNumHij+DESEOHIJ_f, data = datos1999, addNA = T)
## DESEOHIJ_f
## rNumHij 1 2 <NA>
## 0 2104 844 81
## 1 0 0 1448
## 2 0 0 2326
## 3 0 0 705
## 4 0 0 157
## 5 0 0 57
## 6 0 0 17
## 7 0 0 6
## 8 0 0 2
## 9 0 0 2
datatable(as.matrix(datos1999 %>% frq(NUMDESEO_f)))
# solo contestan 0 hijos/as + sí deseo hijos/as --> no hay 0
datatable(as.matrix(datos1999 %>% flat_table(NUMDESEO_f, DESEOHIJ_f)))
xtabs(~rNumHij+NUMDESEO_f, data = datos1999, addNA = T)
## NUMDESEO_f
## rNumHij 1 2 3 4 5 6 7 8 10 12 <NA>
## 0 230 1222 498 125 22 3 1 1 1 1 925
## 1 0 0 0 0 0 0 0 0 0 0 1448
## 2 0 0 0 0 0 0 0 0 0 0 2326
## 3 0 0 0 0 0 0 0 0 0 0 705
## 4 0 0 0 0 0 0 0 0 0 0 157
## 5 0 0 0 0 0 0 0 0 0 0 57
## 6 0 0 0 0 0 0 0 0 0 0 17
## 7 0 0 0 0 0 0 0 0 0 0 6
## 8 0 0 0 0 0 0 0 0 0 0 2
## 9 0 0 0 0 0 0 0 0 0 0 2
xtabs(~NUMDESEO_f+DESEOHIJ_f, data = datos1999, addNA = T)
## DESEOHIJ_f
## NUMDESEO_f 1 2 <NA>
## 1 230 0 0
## 2 1222 0 0
## 3 498 0 0
## 4 125 0 0
## 5 22 0 0
## 6 3 0 0
## 7 1 0 0
## 8 1 0 0
## 10 1 0 0
## 12 1 0 0
## <NA> 0 844 4801
# 1º var. aux. nº de hijos/as deseado para mujeres sin hijos (NA como 0)
datos1999 <- datos1999 %>%
mutate(
rNumDesHij_aux1=rec(as.numeric(NUMDESEO_f),
rec="NA = 0;
else=copy",
as.num = T,
var.label = "Número de hijos/as deseado - mujeres sin hijos/as")
)
datatable(as.matrix(datos1999 %>% frq(rNumDesHij_aux1)))
xtabs(~rNumDesHij_aux1+NUMDESEO_f, data = datos1999, addNA = T)
## NUMDESEO_f
## rNumDesHij_aux1 1 2 3 4 5 6 7 8 10 12 <NA>
## 0 0 0 0 0 0 0 0 0 0 0 5645
## 1 230 0 0 0 0 0 0 0 0 0 0
## 2 0 1222 0 0 0 0 0 0 0 0 0
## 3 0 0 498 0 0 0 0 0 0 0 0
## 4 0 0 0 125 0 0 0 0 0 0 0
## 5 0 0 0 0 22 0 0 0 0 0 0
## 6 0 0 0 0 0 3 0 0 0 0 0
## 7 0 0 0 0 0 0 1 0 0 0 0
## 8 0 0 0 0 0 0 0 1 0 0 0
## 10 0 0 0 0 0 0 0 0 1 0 0
## 12 0 0 0 0 0 0 0 0 0 1 0
# 2º var. aux. NA (mujeres sin hijos/as + coincide con el nº de hijos/as) como 0
datos1999 <- datos1999 %>%
mutate(
rNumDesHij_aux2=rec(as.numeric(NUMDESE2_f),
rec="NA = 0;
else=copy",
as.num = T,
var.label = "Número de hijos/as deseado - mujeres con hijos/as")
)
datatable(as.matrix(datos1999 %>% frq(rNumDesHij_aux2)))
xtabs(~rNumDesHij_aux2+NUMDESE2_f, data = datos1999, addNA = T)
## NUMDESE2_f
## rNumDesHij_aux2 0 1 2 3 4 5 6 7 8 10 11 12
## 0 19 0 0 0 0 0 0 0 0 0 0 0
## 1 0 49 0 0 0 0 0 0 0 0 0 0
## 2 0 0 815 0 0 0 0 0 0 0 0 0
## 3 0 0 0 634 0 0 0 0 0 0 0 0
## 4 0 0 0 0 188 0 0 0 0 0 0 0
## 5 0 0 0 0 0 48 0 0 0 0 0 0
## 6 0 0 0 0 0 0 37 0 0 0 0 0
## 7 0 0 0 0 0 0 0 10 0 0 0 0
## 8 0 0 0 0 0 0 0 0 4 0 0 0
## 10 0 0 0 0 0 0 0 0 0 5 0 0
## 11 0 0 0 0 0 0 0 0 0 0 1 0
## 12 0 0 0 0 0 0 0 0 0 0 0 2
## 15 0 0 0 0 0 0 0 0 0 0 0 0
## NUMDESE2_f
## rNumDesHij_aux2 15 <NA>
## 0 0 5936
## 1 0 0
## 2 0 0
## 3 0 0
## 4 0 0
## 5 0 0
## 6 0 0
## 7 0 0
## 8 0 0
## 10 0 0
## 11 0 0
## 12 0 0
## 15 1 0
# 3º var.aux. Mujeres con hijos/as que desean el mismo nº que tienen = 0, resto NA
datos1999 <- datos1999 %>%
mutate(
rNumDesHij_aux3=rec(as.numeric(COINCIDE_f),
rec="1 = 0;
else=NA",
as.num = T,
var.label =
"Aux_nºhijos/as deseado - mujeres con hijos/as coincide")
)
datatable(as.matrix(datos1999 %>% frq(rNumDesHij_aux3)))
xtabs(~rNumDesHij_aux3+COINCIDE_f, data = datos1999, addNA = T)
## COINCIDE_f
## rNumDesHij_aux3 1 2 <NA>
## 0 2907 0 0
## <NA> 0 1813 3029
# 4º var. aux. se suma la anterior variable aux. con el nº de hijos/as que tienen
datos1999 <- datos1999 %>%
mutate(rNumDesHij_aux4=rNumDesHij_aux3 + NUMHIJOS_f)
datos1999 %>% frq(rNumDesHij_aux4)
##
## Aux_nºhijos/as deseado - mujeres con hijos/as coincide (rNumDesHij_aux4) <numeric>
## # total N=7749 valid N=2907 mean=2.11 sd=0.82
##
## Value | N | Raw % | Valid % | Cum. %
## ---------------------------------------
## 1 | 526 | 6.79 | 18.09 | 18.09
## 2 | 1730 | 22.33 | 59.51 | 77.61
## 3 | 508 | 6.56 | 17.48 | 95.08
## 4 | 101 | 1.30 | 3.47 | 98.56
## 5 | 31 | 0.40 | 1.07 | 99.62
## 6 | 4 | 0.05 | 0.14 | 99.76
## 7 | 4 | 0.05 | 0.14 | 99.90
## 8 | 1 | 0.01 | 0.03 | 99.93
## 9 | 2 | 0.03 | 0.07 | 100.00
## <NA> | 4842 | 62.49 | <NA> | <NA>
xtabs(~rNumDesHij_aux4+COINCIDE_f, data = datos1999, addNA = T)
## COINCIDE_f
## rNumDesHij_aux4 1 2 <NA>
## 1 526 0 0
## 2 1730 0 0
## 3 508 0 0
## 4 101 0 0
## 5 31 0 0
## 6 4 0 0
## 7 4 0 0
## 8 1 0 0
## 9 2 0 0
## <NA> 0 1813 3029
xtabs(~rNumDesHij_aux4+NUMHIJOS_f, data = datos1999, addNA = T)
## NUMHIJOS_f
## rNumDesHij_aux4 1 2 3 4 5 6 7 8 9 <NA>
## 1 526 0 0 0 0 0 0 0 0 0
## 2 0 1730 0 0 0 0 0 0 0 0
## 3 0 0 508 0 0 0 0 0 0 0
## 4 0 0 0 101 0 0 0 0 0 0
## 5 0 0 0 0 31 0 0 0 0 0
## 6 0 0 0 0 0 4 0 0 0 0
## 7 0 0 0 0 0 0 4 0 0 0
## 8 0 0 0 0 0 0 0 1 0 0
## 9 0 0 0 0 0 0 0 0 2 0
## <NA> 922 596 197 56 26 13 2 1 0 3029
# sobre 4º variable aux NA = 0 (mujeres sin y mujeres con que no coincide)
datos1999 <- datos1999 %>%
mutate(
rNumDesHij_aux4=rec(as.numeric(rNumDesHij_aux4),
rec="NA = 0;
else=copy",
as.num = T,
var.label = "Aux_nºhijos/as deseado - mujeres con hijos/as coincide. Nº hijos/as")
)
datatable(as.matrix(datos1999 %>% frq(rNumDesHij_aux4)))
xtabs(~rNumDesHij_aux4+COINCIDE_f, data = datos1999, addNA = T)
## COINCIDE_f
## rNumDesHij_aux4 1 2 <NA>
## 0 0 1813 3029
## 1 526 0 0
## 2 1730 0 0
## 3 508 0 0
## 4 101 0 0
## 5 31 0 0
## 6 4 0 0
## 7 4 0 0
## 8 1 0 0
## 9 2 0 0
# var. definitiva sumando las aux.
datos1999 <- datos1999 %>%
mutate(rNumDesHij=rNumDesHij_aux1 + rNumDesHij_aux2 + rNumDesHij_aux4)
labelled::var_label(datos1999$rNumDesHij) <- "Número de hijos/as deseado"
datatable(as.matrix(datos1999 %>% frq(rNumDesHij)))
### 2018
# para todas
datatable(as.matrix(datos2018 %>% frq(NDESEOHIJO)))
datos2018 <- datos2018 %>%
mutate(
rNumDesHij=rec(as.numeric(NDESEOHIJO),
rec="else=copy",
as.num = T,
var.label = "Número de hijos/as deseado")
)
datatable(as.matrix(datos2018 %>% frq(rNumDesHij)))
rNumDesHij <- c("Número de hijos/as deseado", "rNumDesHij", "256", "rNumDesHij", "239", "rNumDesHij", "495" )
datatable(as.matrix(datos1985 %>% frq(P104)))
# 1 = NO CREYENTE, 2 = CATOLICA NO PRACTICANTE, 3 = CATOLICA PRACTICANTE,
# 4 = DE OTRA RELIGION, 5 = NO SABE. NO CONTESTA
datatable(as.matrix(datos1999 %>% frq(CREENCIA_f)))
# 1= CATOLICA PRACTICANTE , 2 = CATOLICA NO PRACTICANTE,
# 3= PROTESTANTE, 4= MUSULMANA, 5 = OTRAS RELIGIONES
# 6 = TIENE SUS PROPIAS CREENCIAS 7 = NO CREYENTE 8 = NO SABE / NO CONTESTA
datatable(as.matrix(datos2018 %>% frq(RELIGION)))
datatable(as.matrix(datos2018 %>% frq(PRACTICANTE)))
# Con las posibilidades, se recodificará para tener las siguientes catego.
ET_Religion <- c("NsNc", "Ninguna religión", "Católica no practicante", "Católica", "Otras religiones")
## 1985
datos1985 <- datos1985 %>%
mutate(
rRelig=rec(as.numeric(P104),
rec="1 = 1;
2 = 2;
3 = 3;
4 = 4;
5 = 0",
as.num = F,
val.labels = ET_Religion,
var.label = "Creencia religiosa")
)
datatable(as.matrix(datos1985 %>% frq(rRelig)))
xtabs(~rRelig+P104, data = datos1985, addNA = T)
## P104
## rRelig 1 2 3 4 5
## 0 0 0 0 0 93
## 1 259 0 0 0 0
## 2 0 3484 0 0 0
## 3 0 0 4841 0 0
## 4 0 0 0 105 0
## 1999
datos1999 <- datos1999 %>%
mutate(
rRelig=rec(as.numeric(CREENCIA_f),
rec="1 = 3;
2 = 2;
3 : 6 = 4;
7 = 1;
8 = 0",
as.num = F,
val.labels = ET_Religion,
var.label = "Creencia religiosa")
)
datatable(as.matrix(datos1999 %>% frq(rRelig)))
xtabs(~rRelig+CREENCIA_f, data = datos1999, addNA = T)
## CREENCIA_f
## rRelig 1 2 3 4 5 6 7 8
## 0 0 0 0 0 0 0 0 227
## 1 0 0 0 0 0 0 335 0
## 2 0 3829 0 0 0 0 0 0
## 3 2857 0 0 0 0 0 0 0
## 4 0 0 26 51 69 355 0 0
## 2018
datos2018 <- datos2018 %>%
mutate(
rRelig_aux1=rec(as.numeric(RELIGION),
rec="1 = 2;
2:5 = 4;
6 = 1;
7 = 0",
as.num = T,
var.label = "Aux.Religión")
)
datatable(as.matrix(datos2018 %>% frq(rRelig_aux1)))
xtabs(~RELIGION+rRelig_aux1, data = datos2018, addNA = T)
## rRelig_aux1
## RELIGION 0 1 2 4
## Cat\xf3lica 0 0 8739 0
## Protestante 0 0 0 72
## Musulmana 0 0 0 340
## Otros cristianos 0 0 0 279
## Otra religi\xf3n 0 0 0 197
## Ninguna 0 3503 0 0
## Prefiero no contestar 1426 0 0 0
datos2018 <- datos2018 %>%
mutate(
rRelig_aux2=rec(as.numeric(PRACTICANTE),
rec="1 = 0;
NA = 0;
else = 1",
as.num = T,
var.label = "Aux.Religión -practicante")
)
## One or more of the old values are recoded into identical new values.
## Please check if you correctly specified the recode-pattern,
## else separate multiple values with comma, e.g. rec="a,b,c=1; d,e,f=2".
xtabs(~PRACTICANTE+rRelig_aux2, data = datos2018, addNA = T)
## rRelig_aux2
## PRACTICANTE 0 1
## Nada practicante 2661 0
## Poco practicante 0 5324
## Bastante practicante 0 1282
## Muy practicante 0 360
## <NA> 4929 0
datos2018 <- datos2018 %>%
mutate(rRelig= rRelig_aux1 + rRelig_aux2)
datatable(as.matrix(datos2018 %>% frq(rRelig)))
xtabs(~RELIGION+rRelig, data = datos2018, addNA = T)
## rRelig
## RELIGION 0 1 2 3 4 5
## Cat\xf3lica 0 0 2547 6192 0 0
## Protestante 0 0 0 0 9 63
## Musulmana 0 0 0 0 11 329
## Otros cristianos 0 0 0 0 55 224
## Otra religi\xf3n 0 0 0 0 39 158
## Ninguna 0 3503 0 0 0 0
## Prefiero no contestar 1426 0 0 0 0 0
xtabs(~PRACTICANTE+rRelig, data = datos2018, addNA = T)
## rRelig
## PRACTICANTE 0 1 2 3 4 5
## Nada practicante 0 0 2547 0 114 0
## Poco practicante 0 0 0 5011 0 313
## Bastante practicante 0 0 0 991 0 291
## Muy practicante 0 0 0 190 0 170
## <NA> 1426 3503 0 0 0 0
datos2018 <- datos2018 %>%
mutate(
rRelig=rec(as.numeric(rRelig),
rec="4:5 = 4;
else = copy",
as.num = F,
val.labels = ET_Religion,
var.label = "Creencia religiosa")
)
datatable(as.matrix(datos2018 %>% frq(rRelig)))
xtabs(~RELIGION+rRelig, data = datos2018, addNA = T)
## rRelig
## RELIGION 0 1 2 3 4
## Cat\xf3lica 0 0 2547 6192 0
## Protestante 0 0 0 0 72
## Musulmana 0 0 0 0 340
## Otros cristianos 0 0 0 0 279
## Otra religi\xf3n 0 0 0 0 197
## Ninguna 0 3503 0 0 0
## Prefiero no contestar 1426 0 0 0 0
xtabs(~PRACTICANTE+rRelig, data = datos2018, addNA = T)
## rRelig
## PRACTICANTE 0 1 2 3 4
## Nada practicante 0 0 2547 0 114
## Poco practicante 0 0 0 5011 313
## Bastante practicante 0 0 0 991 291
## Muy practicante 0 0 0 190 170
## <NA> 1426 3503 0 0 0
rRelig <- c("Creencia religiosa", "rRelig", "257", "rRelig", "540", "rRelig", "498")
## Ya no se han identificado más variables comunes en las 3 encuestas
## Aunque se van a incluir 3 variables más por su potencial capacidad explicativa que comparten 2 de las 3 encuestas
## 1985: no hay pregunta en el cuestionario
datatable(as.matrix(datos1999 %>% frq(NDOCODPA_f)))
datatable(as.matrix(datos1999 %>% frq(NDOCODPR_f)))
# Los NA de País corresponden a los datos de Prov (y a la inversa)
datatable(as.matrix(datos2018 %>% frq(NACIM)))
## 1999
datos1999 = datos1999 %>%
mutate(
rPaisNac=rec(as.numeric(NDOCODPR_f),
rec="1:52 = 1;
NA = 2",
as.num=FALSE,
val.labels = c("España", "Otro país"),
var.label = "País de nacimiento"))
datatable(as.matrix(datos1999 %>% frq(rPaisNac)))
xtabs(~rPaisNac+NDOCODPR_f, data = datos1999, addNA = T)
## NDOCODPR_f
## rPaisNac 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
## 1 50 82 171 86 42 223 138 438 64 143 220 48 135 179 246 52 55
## 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## NDOCODPR_f
## rPaisNac 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
## 1 162 37 123 73 55 101 124 46 151 68 566 130 332 204 65 277 68
## 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## NDOCODPR_f
## rPaisNac 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
## 1 264 171 93 157 187 44 298 38 56 40 130 292 135 232 85 188 74
## 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## NDOCODPR_f
## rPaisNac 52 <NA>
## 1 54 0
## 2 0 257
## 2018
datos2018 = datos2018 %>%
mutate(
rPaisNac=rec(as.numeric(NACIM),
rec="1 = 1;
2 = 2",
as.num=FALSE,
val.labels = c("España", "Otro país"),
var.label = "País de nacimiento"))
datatable(as.matrix(datos2018 %>% frq(rPaisNac)))
xtabs(~rPaisNac+NACIM, data = datos2018, addNA = T)
## NACIM
## rPaisNac Espa\xf1a Otro pa\xeds
## 1 12808 0
## 2 0 1748
rPaisNac <- c("País de nacimiento", NA, NA, "rPaisNac", "541", "rPaisNac", "499")
datatable(as.matrix(datos1985 %>% frq(P102)))
## 1999: no hay pregunta en el cuestionario
datatable(as.matrix(datos2018 %>% frq(NHERM)))
## 1985
datos1985 = datos1985 %>%
mutate(
rNumHerm=rec(as.numeric(P102),
rec="else = copy",
as.num = T,
var.label = "Número de hermanos/as"))
datatable(as.matrix(datos1985 %>% frq(rNumHerm)))
xtabs(~rNumHerm+P102, data = datos1985, addNA = T)
## P102
## rNumHerm 0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 470 0 0 0 0 0 0 0 0 0 0 0 0 0
## 1 0 1628 0 0 0 0 0 0 0 0 0 0 0 0
## 2 0 0 1824 0 0 0 0 0 0 0 0 0 0 0
## 3 0 0 0 1562 0 0 0 0 0 0 0 0 0 0
## 4 0 0 0 0 1130 0 0 0 0 0 0 0 0 0
## 5 0 0 0 0 0 732 0 0 0 0 0 0 0 0
## 6 0 0 0 0 0 0 518 0 0 0 0 0 0 0
## 7 0 0 0 0 0 0 0 332 0 0 0 0 0 0
## 8 0 0 0 0 0 0 0 0 227 0 0 0 0 0
## 9 0 0 0 0 0 0 0 0 0 130 0 0 0 0
## 10 0 0 0 0 0 0 0 0 0 0 95 0 0 0
## 11 0 0 0 0 0 0 0 0 0 0 0 55 0 0
## 12 0 0 0 0 0 0 0 0 0 0 0 0 25 0
## 13 0 0 0 0 0 0 0 0 0 0 0 0 0 23
## 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## P102
## rNumHerm 14 15 16 17 19 20
## 0 0 0 0 0 0 0
## 1 0 0 0 0 0 0
## 2 0 0 0 0 0 0
## 3 0 0 0 0 0 0
## 4 0 0 0 0 0 0
## 5 0 0 0 0 0 0
## 6 0 0 0 0 0 0
## 7 0 0 0 0 0 0
## 8 0 0 0 0 0 0
## 9 0 0 0 0 0 0
## 10 0 0 0 0 0 0
## 11 0 0 0 0 0 0
## 12 0 0 0 0 0 0
## 13 0 0 0 0 0 0
## 14 14 0 0 0 0 0
## 15 0 4 0 0 0 0
## 16 0 0 3 0 0 0
## 17 0 0 0 6 0 0
## 19 0 0 0 0 3 0
## 20 0 0 0 0 0 1
## 2018
datos2018 = datos2018 %>%
mutate(
rNumHerm=rec(as.numeric(NHERM),
rec="else = copy",
as.num=T,
var.label = "Número de hermanos/as"))
datatable(as.matrix(datos2018 %>% frq(rNumHerm)))
xtabs(~rNumHerm+NHERM, data = datos2018, addNA = T)
## NHERM
## rNumHerm 0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 1121 0 0 0 0 0 0 0 0 0 0 0 0 0
## 1 0 5247 0 0 0 0 0 0 0 0 0 0 0 0
## 2 0 0 3593 0 0 0 0 0 0 0 0 0 0 0
## 3 0 0 0 1938 0 0 0 0 0 0 0 0 0 0
## 4 0 0 0 0 1106 0 0 0 0 0 0 0 0 0
## 5 0 0 0 0 0 602 0 0 0 0 0 0 0 0
## 6 0 0 0 0 0 0 340 0 0 0 0 0 0 0
## 7 0 0 0 0 0 0 0 244 0 0 0 0 0 0
## 8 0 0 0 0 0 0 0 0 131 0 0 0 0 0
## 9 0 0 0 0 0 0 0 0 0 91 0 0 0 0
## 10 0 0 0 0 0 0 0 0 0 0 58 0 0 0
## 11 0 0 0 0 0 0 0 0 0 0 0 34 0 0
## 12 0 0 0 0 0 0 0 0 0 0 0 0 22 0
## 13 0 0 0 0 0 0 0 0 0 0 0 0 0 16
## 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## NHERM
## rNumHerm 14 15 16 17 21
## 0 0 0 0 0 0
## 1 0 0 0 0 0
## 2 0 0 0 0 0
## 3 0 0 0 0 0
## 4 0 0 0 0 0
## 5 0 0 0 0 0
## 6 0 0 0 0 0
## 7 0 0 0 0 0
## 8 0 0 0 0 0
## 9 0 0 0 0 0
## 10 0 0 0 0 0
## 11 0 0 0 0 0
## 12 0 0 0 0 0
## 13 0 0 0 0 0
## 14 6 0 0 0 0
## 15 0 2 0 0 0
## 16 0 0 1 0 0
## 17 0 0 0 3 0
## 21 0 0 0 0 1
rNumHerm <- c("Número de hermanos/as", "rNumHerm", "258", NA, NA, "rNumHerm", "500")
datatable(as.matrix(datos1985 %>% frq(P105)))
# 1 = MEDIO RURAL
# 2 = MEDIO URBANO: MUNICIPIO MENOR DE 100.000 HABITANTES
# 3 = MEDIO URBANO: MUNICIPIO MAYOR DE 100.000 HABITANTES
datatable(as.matrix(datos1999 %>% frq(NDOTAMUN_f)))
# 1 = MAS DE 500.000 HABITANTES, 2 = DE 50.001 A 500.000 HABITANTES
# 3 = DE 10.001 A 50.000 HABITANTES, 4=HASTA 10.000 HABITANTES
# Según el glosario del INE se considera medio rural a aquellos por debajo de 10.000 habitantes. Como los demás cortes no es posible hacerlos coincidir la variable será dicotómica
## 2018: no hay pregunta en el cuestionario
## 1985
datos1985 <- datos1985 %>%
mutate(
rTamMunNac=rec(as.numeric(P105),
rec="1 = 0;
2:3 = 1",
as.num = F,
val.labels = c("Rural", "Urbano"),
var.label = "Hábitat del lugar de nacimiento"))
datatable(as.matrix(datos1985 %>% frq(rTamMunNac)))
xtabs(~rTamMunNac+P105, data = datos1985, addNA = T)
## P105
## rTamMunNac 1 2 3
## 0 4288 0 0
## 1 0 2009 2485
## 1999
datos1999 <- datos1999 %>%
mutate(
rTamMunNac=rec(as.numeric(NDOTAMUN_f),
rec="1:3 = 1;
4 = 0",
as.num = F,
val.labels = c("Rural", "Urbano"),
var.label = "Hábitat del lugar de nacimiento"))
datatable(as.matrix(datos1999 %>% frq(rTamMunNac)))
xtabs(~rTamMunNac+NDOTAMUN_f, data = datos1999, addNA = T)
## NDOTAMUN_f
## rTamMunNac 1 2 3 4 <NA>
## 0 0 0 0 1769 0
## 1 1301 3066 1356 0 0
## <NA> 0 0 0 0 257
rTamMunNac <- c("Hábitat del lugar de nacimiento", "rTamMunNac", "259", "rTamMunNac", "452", NA, NA)
# Cálculando pesos estandarizados
summary(datos1985$FACTOR)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.800e+08 5.321e+09 8.439e+09 9.408e+09 1.247e+10 6.990e+10
datos1985 <- datos1985 %>% mutate(rPesos = FACTOR/mean(FACTOR))
summary(datos1985$rPesos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.05102 0.56553 0.89699 1.00000 1.32496 7.42964
summary(datos1999$FELEVACI_f)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 7.681e+07 6.596e+08 1.048e+09 1.312e+09 1.623e+09 1.263e+10
datos1999 <- datos1999 %>% mutate(rPesos = FELEVACI_f/mean(FELEVACI_f))
summary(datos1999$rPesos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.05855 0.50282 0.79858 1.00000 1.23749 9.63045
summary(datos2018$FACTOR)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 92.39 474.26 717.07 819.38 1121.59 4565.54
datos2018 <- datos2018 %>% mutate(rPesos = FACTOR/mean(FACTOR))
summary(datos2018$rPesos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1128 0.5788 0.8751 1.0000 1.3688 5.5720
rPesos <- c("Factor de elevación estandarizado", "rPesos", "262", "rPesos", "545", "rPesos", "503")
rId <- c("Id. cuestionario", "I0", "1", "NUMEORD", "1", "IDEN", "1" )
COD <- rbind(rId, rEdad, rTrEdad, rEstudios, rEstCiv,
rSitLab, rConvPar, rNumHij,
rTrNumHij, r1HijEdad, rNumDesHij, rRelig,
rPaisNac, rNumHerm,
rTamMunNac, rPesos)
COD <- as.data.frame(COD, row.names = F)
colnames(COD) <- COD_nom
COD
## Variable N1985 P1985 N1999 P1999
## 1 Id. cuestionario I0 1 NUMEORD 1
## 2 Edad rEdad 243 rEdad 526
## 3 Tramos de edad rTrEdad 244 rTrEdad 527
## 4 Nivel de estudios alcanzado rEstudios 245 rEstudios 528
## 5 Estado civil rEstCiv 246 rEstCiv 529
## 6 Situación laboral rSitLab 247 rSitLab 530
## 7 Situación sentimental y convivencia rConvPar 248 rConvPar 531
## 8 Número de hijos/as rNumHij 249 rNumHij 532
## 9 Número de hijos/as (catego.) rTrNumHij 250 rTrNumHij 533
## 10 Edad al primer hijo/a r1HijEdad 255 r1HijEdad 534
## 11 Número de hijos/as deseado rNumDesHij 256 rNumDesHij 239
## 12 Creencia religiosa rRelig 257 rRelig 540
## 13 País de nacimiento <NA> <NA> rPaisNac 541
## 14 Número de hermanos/as rNumHerm 258 <NA> <NA>
## 15 Hábitat del lugar de nacimiento rTamMunNac 259 rTamMunNac 452
## 16 Factor de elevación estandarizado rPesos 262 rPesos 545
## N2018 P2018
## 1 IDEN 1
## 2 rEdad 486
## 3 rTrEdad 487
## 4 rEstudios 488
## 5 rEstCiv 489
## 6 rSitLab 490
## 7 rConvPar 491
## 8 rNumHij 492
## 9 rTrNumHij 493
## 10 r1HijEdad 494
## 11 rNumDesHij 495
## 12 rRelig 498
## 13 rPaisNac 499
## 14 rNumHerm 500
## 15 <NA> <NA>
## 16 rPesos 503
rm(COD_nom, ET_Estudios, ET_Religion, Et_rTrNumHij, ET_SitLab,
rNumDesHij, rEdad, r1HijEdad, rEstCiv, rEstudios,
rTamMunNac, rNumHerm, rNumHij, rPaisNac,
rPesos, rRelig, rSitLab, rConvPar,
rTrEdad, rTrNumHij, rId)
Como no coindicen los límites de edad de las mujeres en las diferentes encuestas, lo que podría incluir sesgos, se homogeneiza para trabajar con bbdd de 15 a 49 años
F1985Var <- COD[-13,2]
dtF1985 <- datos1985 %>% filter(rEdad > 17 & rEdad < 50 ) %>% select(F1985Var)
F1999Var <- COD[-14,4]
dtF1999 <- datos1999 %>% filter(rEdad > 17 & rEdad < 50 ) %>% select(F1999Var)
# Comprobación tamaño de la muestra extaída
datatable(as.matrix(datos1999 %>% filter(rEdad > 17 & rEdad < 50 ) %>% frq(rEdad)))
F2018Var <- COD[-15,6]
dtF2018 <- datos2018 %>% filter(rEdad > 17 & EDAD < 50 ) %>% select(F2018Var)
# Comprobación tamaño de la muestra extaída
datatable(as.matrix(datos2018 %>% filter(rEdad > 17 & rEdad < 50 ) %>% frq(rEdad)))
Lsjm <- c("n","NA.prc","mean","sd","se","md", "range", "skew")
## Edad
TB85Edad <- dtF1985 %>% sjmisc::descr(rEdad, show = Lsjm, encoding = "iso8859-1")
TB99Edad <- dtF1999 %>% sjmisc::descr(rEdad, show = Lsjm, encoding = "iso8859-1")
TB18Edad <- dtF2018 %>% sjmisc::descr(rEdad, show = Lsjm, encoding = "iso8859-1")
## aplicando pesos
TB85EdadP <- dtF1985 %>% sjmisc::descr(rEdad, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
TB99EdadP <- dtF1999 %>% sjmisc::descr(rEdad, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
TB18EdadP <- dtF2018 %>% sjmisc::descr(rEdad, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
## Tabla edad las 3 encuestas
TB85c <- cbind.data.frame(TB85Edad, TB85EdadP[,-1])
TB99c <- cbind.data.frame(TB99Edad, TB99EdadP[,-1])
TB18c <- cbind.data.frame(TB18Edad, TB18EdadP[,-1])
tb <- rbind.data.frame(TB85c, TB99c,TB18c)
Encuesta <- c("1985", "1999", "2018")
tb <- cbind.data.frame(Encuesta, tb)
Nomlsjm <- c("encuesta", "var", "n", "%NA", "media", "sd", "se", "moda",
"rango", "skew", "media pond", "sd pond")
sjPlot::tab_df(tb, encoding = "iso8859-1",
title = "Edad de las mujeres encuestadas",
col.header = Nomlsjm)
| encuesta | var | n | %NA | media | sd | se | moda | rango | skew | media pond | sd pond |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1985 | rEdad | 8782 | 0 | 32.13 | 9.30 | 0.10 | 32 | 31 (18-49) | 0.17 | 32.06 | 9.19 |
| 1999 | rEdad | 7454 | 0 | 33.98 | 8.61 | 0.10 | 34 | 31 (18-49) | -0.06 | 32.64 | 9.08 |
| 2018 | rEdad | 11595 | 0 | 35.77 | 9.10 | 0.08 | 37 | 31 (18-49) | -0.38 | 35.41 | 8.93 |
### visualización Edad
gedad <- ggplot(NULL) +
scale_y_continuous(breaks = seq(15,55, by=5), limits = c(15,55)) +
theme_minimal()+
theme(plot.title = element_text(size = 12,
face = "bold"))
gedad85 <- gedad + geom_boxplot(data = dtF1985, mapping = aes(y = rEdad), col = "mediumseagreen", fill = "seagreen3", size = 1) + labs(title = "1985", y = "Edad")
gedad99 <-gedad + geom_boxplot(data = dtF1999, mapping = aes(y = rEdad), col = "indianred2", fill = "indianred1", size = 1) + labs(title = "1999", y = " ")
gedad18 <- gedad + geom_boxplot(data = dtF2018, mapping = aes(y = rEdad), col = "slateblue", fill = "slateblue1", size = 1) + labs(title = "2018", y = " ")
GrafEdad <- ggarrange(gedad85, gedad99, gedad18, ncol=3, nrow = 1)
annotate_figure(GrafEdad,
top = text_grob("Edad de las mujeres encuestadas",
face = "bold", size = 16,
vjust = 0.5, hjust = 1))
LisEdad <- list("gedad", "gedad18", "gedad85", "gedad99",
"GrafEdad",
"TB18c","TB18Edad", "TB18EdadP",
"TB85c", "TB85Edad","TB85EdadP",
"TB99c", "TB99Edad", "TB99EdadP",
"tb")
rm(gedad, gedad18, gedad85, gedad99,
TB18c, TB18Edad, TB18EdadP,
TB85c, TB85Edad, TB85EdadP,
TB99c, TB99Edad, TB99EdadP)
TB85Nhij <- dtF1985 %>% sjmisc::descr(rNumHij, show = Lsjm, encoding = "iso8859-1")
TB99Nhij <- dtF1999 %>% sjmisc::descr(rNumHij, show = Lsjm, encoding = "iso8859-1")
TB18Nhij <- dtF2018 %>% sjmisc::descr(rNumHij, show = Lsjm, encoding = "iso8859-1")
# Ponderada
TB85NhijP <- dtF1985 %>% sjmisc::descr(rNumHij, weights = rPesos,
show = c("mean", "sd"), encoding = "iso8859-1")
TB99NhijP <- dtF1999 %>% sjmisc::descr(rNumHij, weights = rPesos,
show = c("mean", "sd"), encoding = "iso8859-1")
TB18NhijP <- dtF2018 %>% sjmisc::descr(rNumHij, weights = rPesos,
show = c("mean", "sd"), encoding = "iso8859-1")
# Tabla conjunta -Medias
TB85TTNhij <- cbind.data.frame(TB85Nhij, TB85NhijP[,-1])
TB99TTNhij <- cbind.data.frame(TB99Nhij, TB99NhijP[,-1])
TB18TTNhij <- cbind.data.frame(TB18Nhij, TB18NhijP[,-1])
TTNhij <- rbind.data.frame(TB85TTNhij, TB99TTNhij,TB18TTNhij)
TTNhij <- cbind.data.frame(Encuesta, TTNhij)
sjPlot::tab_df(TTNhij, encoding = "iso8859-1",
title = "Número de hijos/as",
col.header = Nomlsjm)
| encuesta | var | n | %NA | media | sd | se | moda | rango | skew | media pond | sd pond |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1985 | rNumHij | 8782 | 0 | 1.54 | 1.59 | 0.02 | 1 | 13 (0-13) | 1.16 | 1.56 | 1.56 |
| 1999 | rNumHij | 7454 | 0 | 1.25 | 1.19 | 0.01 | 1 | 9 (0-9) | 0.81 | 1.15 | 1.22 |
| 2018 | rNumHij | 11595 | 0 | 1.00 | 1.08 | 0.01 | 1 | 9 (0-9) | 0.89 | 1.00 | 1.09 |
rm(TB18Nhij, TB18NhijP, TB18TTNhij, TB85Nhij, TB85NhijP, TB85TTNhij,
TB99Nhij, TB99NhijP, TB99TTNhij)
sjPlot::sjt.xtab(dtF1985$rTrEdad, dtF1985$rTrNumHij,
encoding = "UTF-8", digits = 2,
show.row.prc = T, statistics = "auto", show.obs = F,
title = "Encuesta 1985. Relación entre la edad y el número de hijos/as")
| Tramos de edad |
Número de hijos/as (agregada) |
Total | |||
|---|---|---|---|---|---|
| Ningún hijo/a | Un hijo/a | Dos hijos/as | Tres o más hijos/as | ||
| De 18 a 19 años | 95.94 % | 3.19 % | 0.58 % | 0.29 % | 100 % |
| De 20 a 24 años | 83.02 % | 12.59 % | 4.1 % | 0.29 % | 100 % |
| De 25 a 29 años | 43.11 % | 26.94 % | 21.83 % | 8.12 % | 100 % |
| De 30 a 34 años | 16.3 % | 17.55 % | 42.08 % | 24.07 % | 100 % |
| De 35 a 39 años | 11.04 % | 11.49 % | 37.99 % | 39.49 % | 100 % |
| De 40 a 44 años | 10.2 % | 7.02 % | 33.28 % | 49.5 % | 100 % |
| De 45 a 49 años | 10.04 % | 8.69 % | 28.85 % | 52.42 % | 100 % |
| Total | 37.65 % | 13.49 % | 24.54 % | 24.32 % | 100 % | χ2=5069.908 · df=18 · Cramer’s V=0.439 · p=0.000 |
sjPlot::sjt.xtab(dtF1999$rTrEdad, dtF1999$rTrNumHij,
encoding = "UTF-8", digits = 2,
show.row.prc = T, statistics = "auto", show.obs = F,
title = "Encuesta 1999. Relación entre la edad y el número de hijos/as")
| Tramos de edad |
Número de hijos/as (agregada) |
Total | |||
|---|---|---|---|---|---|
| Ningún hijo/a | Un hijo/a | Dos hijos/as | Tres o más hijos/as | ||
| De 18 a 19 años | 96.42 % | 2.99 % | 0.6 % | 0 % | 100 % |
| De 20 a 24 años | 92.03 % | 5.88 % | 1.68 % | 0.42 % | 100 % |
| De 25 a 29 años | 66.64 % | 22.39 % | 9.49 % | 1.48 % | 100 % |
| De 30 a 34 años | 26.64 % | 31.79 % | 34.64 % | 6.93 % | 100 % |
| De 35 a 39 años | 12.76 % | 23.19 % | 48.65 % | 15.39 % | 100 % |
| De 40 a 44 años | 10.82 % | 18.06 % | 48.17 % | 22.95 % | 100 % |
| De 45 a 49 años | 8.84 % | 13.56 % | 44.7 % | 32.91 % | 100 % |
| Total | 36.71 % | 19.4 % | 31.2 % | 12.69 % | 100 % | χ2=3969.574 · df=18 · Cramer’s V=0.421 · p=0.000 |
sjPlot::sjt.xtab(dtF2018$rTrEdad, dtF2018$rTrNumHij,
encoding = "UTF-8", digits = 2,
show.row.prc = T, statistics = "auto", show.obs = F,
title = "Encuesta 2018. Relación entre la edad y el número de hijos/as")
| Tramos de edad |
Número de hijos/as(agregada) |
Total | |||
|---|---|---|---|---|---|
| Ningún hijo/a | Un hijo/a | Dos hijos/as | Tres o más hijos/as | ||
| De 18 a 19 años | 99.26 % | 0.74 % | 0 % | 0 % | 100 % |
| De 20 a 24 años | 94.55 % | 3.98 % | 1.25 % | 0.22 % | 100 % |
| De 25 a 29 años | 80.47 % | 11.47 % | 6.28 % | 1.78 % | 100 % |
| De 30 a 34 años | 52.85 % | 25.54 % | 16.67 % | 4.95 % | 100 % |
| De 35 a 39 años | 28.12 % | 29.86 % | 32.95 % | 9.08 % | 100 % |
| De 40 a 44 años | 19.33 % | 25.24 % | 43.8 % | 11.62 % | 100 % |
| De 45 a 49 años | 19.16 % | 23.61 % | 45.1 % | 12.14 % | 100 % |
| Total | 44.48 % | 20.6 % | 27.47 % | 7.45 % | 100 % | χ2=4463.375 · df=18 · Cramer’s V=0.358 · p=0.000 |
gTEd_TNhj <- ggplot(NULL) +
theme_minimal() +
scale_x_continuous(labels = c("0%", "25%", "50%", "75%", "100%")) +
theme(plot.title = element_text(size = 12,
face = "bold")) +
labs(x = NULL, y = NULL) +
theme(legend.position = "bottom", legend.text = element_text(size = 8))
gTEd_TNhj85 <- gTEd_TNhj + geom_bar(data = dtF1985,
mapping = aes(y = rTrEdad,
fill =rTrNumHij),
position = "fill") +
scale_fill_brewer(palette = "Greens", labels = c("0", "1", "2", "3 o más hijos/as")) +
scale_y_discrete(labels = c("18 - 19 años", "20 - 24 años",
"25 - 29 años", "30 - 34 años",
"35 - 39 años", "40 - 44 años",
"45 - 49 años")) +
labs(title = "1985", fill = "Nº hijos/as")
gTEd_TNhj99 <- gTEd_TNhj + geom_bar(data = dtF1999,
mapping = aes(y = rTrEdad,
fill =rTrNumHij),
position = "fill") +
scale_fill_brewer(palette = "Reds", labels = c("0", "1", "2", "3 o más")) +
theme(axis.text.y = element_blank()) +
labs(title = "1999", fill =NULL)
gTEd_TNhj18 <- gTEd_TNhj + geom_bar(data = dtF2018,
mapping = aes(y = rTrEdad,
fill =rTrNumHij),
position = "fill") +
scale_fill_brewer(palette = "PuBu", labels = c("0", "1", "2", "3 o más")) +
theme(axis.text.y = element_blank()) +
labs(title = "2018", fill =NULL)
GrafTEdad_TNhj <- ggarrange(gTEd_TNhj85, gTEd_TNhj99, gTEd_TNhj18,
ncol=3, nrow = 1)
annotate_figure(GrafTEdad_TNhj,
top = text_grob("Relación del nº de hijos/as según edad de las mujeres",
face = "bold", size = 16,
vjust = 0.5, hjust = 0.5))
rm(gTEd_TNhj, gTEd_TNhj85, gTEd_TNhj99, gTEd_TNhj18)
ggplot(NULL) +
labs(title = "Media de hijos/as según tramos de edad de las mujeres",
x = "Grupos de edad", y ="Nº de hijos/as" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 3, label = "1985", color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 3, label = "1999", color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 3, label = "2018", color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("18 - 19 años", "20 - 24 años",
"25 - 29 años", "30 - 34 años",
"35 - 39 años", "40 - 44 años",
"45 - 49 años")) +
stat_summary(geom = "point", data = dtF1985, aes(x = rTrEdad, y =rNumHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtF1985, aes(x = rTrEdad, y =rNumHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtF1985, aes(x = rTrEdad, y =rNumHij,
group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtF1999, aes(x = rTrEdad, y =rNumHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtF1999, aes(x = rTrEdad, y =rNumHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtF1999, aes(x = rTrEdad, y =rNumHij,
group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtF2018, aes(x = rTrEdad, y =rNumHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtF2018, aes(x = rTrEdad, y =rNumHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtF2018, aes(x = rTrEdad, y =rNumHij,
group = 1),
fun = mean, color="slateblue", linetype="dashed")
TB85Ed1H <- dtF1985 %>% sjmisc::descr(r1HijEdad, show = Lsjm, encoding = "iso8859-1")
TB99Ed1H <- dtF1999 %>% sjmisc::descr(r1HijEdad, show = Lsjm, encoding = "iso8859-1")
TB18Ed1H <- dtF2018 %>% sjmisc::descr(r1HijEdad, show = Lsjm, encoding = "iso8859-1")
# Ponderada
TB85Ed1HP <- dtF1985 %>% sjmisc::descr(r1HijEdad, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
TB99Ed1HP <- dtF1999 %>% sjmisc::descr(r1HijEdad, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
TB18Ed1HP <- dtF2018 %>% sjmisc::descr(r1HijEdad, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
# Tabla conjunta -Medias
TB85TTEd1H <- cbind.data.frame(TB85Ed1H, TB85Ed1HP[,-1])
TB99TTEd1H <- cbind.data.frame(TB99Ed1H, TB99Ed1HP[,-1])
TB18TTEd1H <- cbind.data.frame(TB18Ed1H, TB18Ed1HP[,-1])
TTEd1H <- rbind.data.frame(TB85TTEd1H, TB99TTEd1H,TB18TTEd1H)
TTEd1H <- cbind.data.frame(Encuesta, TTEd1H)
sjPlot::tab_df(TTEd1H, encoding = "iso8859-1",
title = "Edad con la que se tuvo al primer hijo/a",
col.header = c(Nomlsjm))
| encuesta | var | n | %NA | media | sd | se | moda | rango | skew | media pond | sd pond |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1985 | r1HijEdad | 5476 | 37.65 | 24.30 | 3.80 | 0.05 | 24 | 37 (7-44) | 0.65 | 24.11 | 3.81 |
| 1999 | r1HijEdad | 4718 | 36.71 | 24.58 | 4.48 | 0.07 | 24 | 34 (12-46) | 0.50 | 24.23 | 4.32 |
| 2018 | r1HijEdad | 5984 | 48.39 | 28.50 | 5.66 | 0.07 | 29 | 39 (10-49) | -0.21 | 28.23 | 5.72 |
rm("TB18Ed1H", "TB18Ed1HP", "TB18TTEd1H", "TB85Ed1H", "TB85Ed1HP", "TB85TTEd1H", "TB99Ed1H", "TB99Ed1HP", "TB99TTEd1H")
ggplot(NULL) +
scale_x_continuous(breaks = seq(5,50, by=5), limits = c(5,50)) +
geom_density(data = dtF1985, mapping = aes(r1HijEdad),
col = "mediumseagreen", fill = "mediumseagreen", alpha = 0.5,
size = 1.5) +
geom_density(data = dtF1999, mapping = aes(r1HijEdad),
col = "indianred2", fill = "indianred2", alpha = 0.4,
size = 1.5) +
geom_density(data = dtF2018, mapping = aes(r1HijEdad),
col = "slateblue", fill = "slateblue", alpha = 0.3,
size = 1.5) +
labs(title = "Edad con la que se tuvo al primer hijo/a",
x = "Edad", y ="densidad" ) +
annotate("text", x=31, y= 0.11, label = "media 24 años en 1985",
color = "mediumseagreen") +
annotate("text", x=15, y= 0.07, label = "media 24 años en 1999",
color = "indianred2") +
annotate("text", x=38, y= 0.07, label = "media 28 años en 2018",
color = "slateblue") +
theme_minimal()
TB85DesH <- dtF1985 %>% sjmisc::descr(rNumDesHij,
show = Lsjm, encoding = "iso8859-1")
TB99DesH <- dtF1999 %>% sjmisc::descr(rNumDesHij,
show = Lsjm, encoding = "iso8859-1")
TB18DesH <- dtF2018 %>% sjmisc::descr(rNumDesHij,
show = Lsjm, encoding = "iso8859-1")
# Ponderada
TB85DesHP <- dtF1985 %>% sjmisc::descr(rNumDesHij, weights = rPesos,
show = c("mean", "sd"),
encoding = "iso8859-1")
TB99DesHP <- dtF1999 %>% sjmisc::descr(rNumDesHij, weights = rPesos,
show = c("mean", "sd"),
encoding = "iso8859-1")
TB18DesHP <- dtF2018 %>% sjmisc::descr(rNumDesHij, weights = rPesos,
show = c("mean", "sd"),
encoding = "iso8859-1")
# Tabla conjunta -Medias
TB85TTDesH <- cbind.data.frame(TB85DesH, TB85DesHP[,-1])
TB99TTDesH <- cbind.data.frame(TB99DesH, TB99DesHP[,-1])
TB18TTDesH <- cbind.data.frame(TB18DesH, TB18DesHP[,-1])
TTDesH <- rbind.data.frame(TB85TTDesH, TB99TTDesH,TB18TTDesH)
TTDesH <- cbind.data.frame(Encuesta, TTDesH)
sjPlot::tab_df(TTDesH, encoding = "iso8859-1",
title = "Número de hijos/as deseado",
col.header = Nomlsjm)
| encuesta | var | n | %NA | media | sd | se | moda | rango | skew | media pond | sd pond |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1985 | rNumDesHij | 8782 | 0 | 2.64 | 1.08 | 0.01 | 2 | 10 (0-10) | 1.94 | 2.62 | 1.06 |
| 1999 | rNumDesHij | 7454 | 0 | 2.08 | 1.18 | 0.01 | 2 | 15 (0-15) | 1.03 | 2.08 | 1.22 |
| 2018 | rNumDesHij | 11595 | 0 | 1.95 | 1.16 | 0.01 | 2 | 21 (0-21) | 1.74 | 1.95 | 1.18 |
rm( "TB18DesH", "TB18DesHP", "TB18TTDesH", "TB85DesH",
"TB85DesHP", "TB85TTDesH", "TB99DesH",
"TB99DesHP", "TB99TTDesH")
gDesH <- ggplot(NULL) +
scale_y_continuous(breaks = seq(0,21, by=2), limits = c(0,21)) +
theme_minimal()+
theme(plot.title = element_text(size = 12,
face = "bold"))
gDesH85 <- gDesH + geom_boxplot(data = dtF1985, mapping = aes(y = rNumDesHij),
col = "mediumseagreen", fill = "seagreen3", size = 1) +
labs(title = "1985", y = "Nº hijos/as deseado")
gDesH99 <-gDesH + geom_boxplot(data = dtF1999, mapping = aes(y = rNumDesHij),
col = "indianred2", fill = "indianred1", size = 1) +
labs(title = "1999", y = " ")
gDesH18 <- gDesH + geom_boxplot(data = dtF2018, mapping = aes(y = rNumDesHij),
col = "slateblue", fill = "slateblue1", size = 1) +
labs(title = "2018", y = " ")
GrafDesHij <- ggarrange(gDesH85, gDesH99, gDesH18,
ncol=3, nrow = 1)
annotate_figure(GrafDesHij,
top = text_grob("Número de hijos/as deseado",
face = "bold", size = 16,
vjust = 0.5, hjust = 1))
rm(gDesH, gDesH18, gDesH85, gDesH99)
datatable(as.matrix(dtF2018 %>% frq(rNumDesHij)))
datatable(as.matrix(dtF1999 %>% frq(rNumDesHij)))
datatable(as.matrix(dtF1985 %>% frq(rNumDesHij)))
## Dado el nº de casos atípicos se exlcuyen del análisis en las 3 encuestas aquellos casos de mujeres que responden 7 hijos/as o más, que supone excluir de la muestra al 1% o menos
dtFF1985 <- dtF1985 %>% filter(rNumDesHij < 7 )
datatable(as.matrix(dtFF1985 %>% frq(rNumDesHij)))
dtFF1999 <- dtF1999 %>% filter(rNumDesHij < 7 )
datatable(as.matrix(dtFF1999 %>% frq(rNumDesHij)))
dtFF2018 <- dtF2018 %>% filter(rNumDesHij < 7 )
datatable(as.matrix(dtFF2018 %>% frq(rNumDesHij)))
TB85DesHaj <- dtFF1985 %>% sjmisc::descr(rNumDesHij, show = Lsjm, encoding = "iso8859-1")
TB99DesHaj <- dtFF1999 %>% sjmisc::descr(rNumDesHij, show = Lsjm, encoding = "iso8859-1")
TB18DesHaj <- dtFF2018 %>% sjmisc::descr(rNumDesHij, show = Lsjm, encoding = "iso8859-1")
# Ponderada
TB85DesHPaj <- dtFF1985 %>% sjmisc::descr(rNumDesHij, weights = rPesos, show = c("mean", "sd"), encoding = "iso8859-1")
TB99DesHPaj <- dtFF1999 %>% sjmisc::descr(rNumDesHij, weights = rPesos,
show = c("mean", "sd"),
encoding = "iso8859-1")
TB18DesHPaj <- dtFF2018 %>% sjmisc::descr(rNumDesHij, weights = rPesos,
show = c("mean", "sd"),
encoding = "iso8859-1")
# Tabla conjunta -Medias
TB85TTDesHaj <- cbind.data.frame(TB85DesHaj, TB85DesHPaj[,-1])
TB99TTDesHaj <- cbind.data.frame(TB99DesHaj, TB99DesHPaj[,-1])
TB18TTDesHaj <- cbind.data.frame(TB18DesHaj, TB18DesHPaj[,-1])
TTDesHaj <- rbind.data.frame(TB85TTDesHaj, TB99TTDesHaj,TB18TTDesHaj)
TTDesHaj <- cbind.data.frame(Encuesta, TTDesHaj)
sjPlot::tab_df(TTDesHaj, encoding = "iso8859-1",
title = "Número de hijos/as deseado",
col.header = Nomlsjm)
| encuesta | var | n | %NA | media | sd | se | moda | rango | skew | media pond | sd pond |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1985 | rNumDesHij | 8698 | 0 | 2.59 | 0.94 | 0.01 | 2 | 6 (0-6) | 1.09 | 2.57 | 0.93 |
| 1999 | rNumDesHij | 7421 | 0 | 2.05 | 1.09 | 0.01 | 2 | 6 (0-6) | 0.13 | 2.05 | 1.12 |
| 2018 | rNumDesHij | 11557 | 0 | 1.92 | 1.05 | 0.01 | 2 | 6 (0-6) | -0.08 | 1.93 | 1.04 |
rm( "TB18DesHaj", "TB18DesHPaj", "TB18TTDesHaj", "TB85DesHaj",
"TB85DesHPaj", "TB85TTDesHaj", "TB99DesHaj",
"TB99DesHPaj", "TB99TTDesHaj")
gDesHaj <- ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=0.5), limits = c(0,6)) +
theme_minimal()+
theme(plot.title = element_text(size = 12,
face = "bold"))
gDesH85aj <- gDesHaj + geom_boxplot(data = dtFF1985,
mapping = aes(y = rNumDesHij),
col = "mediumseagreen", fill = "seagreen3", size = 1) +
labs(title = "1985", y = "Nº hijos/as deseado")
gDesH99aj <-gDesHaj + geom_boxplot(data = dtFF1999,
mapping = aes(y = rNumDesHij),
col = "indianred2", fill = "indianred1", size = 1) +
labs(title = "1999", y = " ")
gDesH18aj <- gDesHaj + geom_boxplot(data = dtFF2018,
mapping = aes(y = rNumDesHij),
col = "slateblue", fill = "slateblue1", size = 1) +
labs(title = "2018", y = " ")
GrafDesHijaj <- ggarrange(gDesH85aj, gDesH99aj, gDesH18aj,
ncol=3, nrow = 1)
annotate_figure(GrafDesHijaj,
top = text_grob("Número de hijos/as deseado",
face = "bold", size = 16,
vjust = 0.5, hjust = 1))
rm(gDesHaj, gDesH18aj, gDesH85aj, gDesH99aj)
## Se guardan en listas las bbdd anteriores
bbdd <- list(datos1985, datos1999, datos2018,
dtF1985, dtF1999, dtF2018)
rm(datos1985, datos1999, datos2018,
dtF1985, dtF1999, dtF2018)
cor.test(dtFF1985$rNumDesHij, dtFF1985$rEdad, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF1985$rNumDesHij and dtFF1985$rEdad
## z = 14.967, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.124685
cor.test(dtFF1999$rNumDesHij, dtFF1999$rEdad, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF1999$rNumDesHij and dtFF1999$rEdad
## z = 19.583, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.1734607
cor.test(dtFF2018$rNumDesHij, dtFF2018$rEdad, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF2018$rNumDesHij and dtFF2018$rEdad
## z = 7.664, p-value = 1.802e-14
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.05445343
summary( aov (rNumDesHij~rTrEdad, data= dtFF1985))
## Df Sum Sq Mean Sq F value Pr(>F)
## rTrEdad 6 227 37.77 44.3 <2e-16 ***
## Residuals 8691 7411 0.85
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1985$rNumDesHij, g = dtFF1985$rTrEdad)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1985$rNumDesHij and dtFF1985$rTrEdad
##
## 1 2 3 4 5 6
## 2 0.94726 - - - - -
## 3 0.68864 0.56774 - - - -
## 4 0.19599 0.08638 0.00286 - - -
## 5 0.00078 7.1e-06 2.3e-08 0.09514 - -
## 6 1.4e-11 < 2e-16 < 2e-16 7.0e-09 0.00075 -
## 7 < 2e-16 < 2e-16 < 2e-16 < 2e-16 9.2e-11 0.02503
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rTrEdad, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rTrEdad 6 541 90.25 80.11 <2e-16 ***
## Residuals 7414 8352 1.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rTrEdad)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rTrEdad
##
## 1 2 3 4 5 6
## 2 0.00188 - - - - -
## 3 0.00052 0.60888 - - - -
## 4 4.0e-14 4.2e-09 1.3e-08 - - -
## 5 < 2e-16 < 2e-16 < 2e-16 0.00021 - -
## 6 < 2e-16 < 2e-16 < 2e-16 2.7e-09 0.04318 -
## 7 < 2e-16 < 2e-16 < 2e-16 < 2e-16 5.9e-09 0.00052
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rTrEdad, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rTrEdad 6 154 25.622 23.31 <2e-16 ***
## Residuals 11550 12693 1.099
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rTrEdad)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rTrEdad
##
## 1 2 3 4 5 6
## 2 0.02719 - - - - -
## 3 0.00018 0.22200 - - - -
## 4 1.1e-06 0.00707 0.82695 - - -
## 5 1.4e-13 5.7e-10 0.00019 0.01622 - -
## 6 5.3e-16 4.9e-13 2.5e-06 0.00065 0.82695 -
## 7 1.4e-13 4.9e-10 0.00020 0.01780 0.86074 0.82695
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según grupos de edad",
x = "Grupos de edad", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("18 - 19 años", "20 - 24 años",
"25 - 29 años", "30 - 34 años",
"35 - 39 años", "40 - 44 años",
"45 - 49 años")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rTrEdad, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rTrEdad, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rTrEdad, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rTrEdad, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rTrEdad, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rTrEdad, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rTrEdad, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rTrEdad, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rTrEdad, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
# Recodificar para unir tramos de edd 18 a 19 años y 20 a 24 (en las 3 encuestas de 18 a 19 concentra menos casos, y no parece haber mucha diferencia en la media Deseo hijos/as)
## 1985
dtFF1985 = dtFF1985 %>%
mutate(
rTrEdadRec=rec(as.numeric(rTrEdad),
rec="1 = 1;
2 = 1;
3 = 2;
4 = 3;
5 = 4;
6 = 5;
7 = 6",
as.num = F,
val.labels = c("De 18 a 24 años",
"De 25 a 29 años", "De 30 a 34 años",
"De 35 a 39 años", "De 40 a 44 años",
"De 45 a 49 años"),
var.label = "Tramos de edad ")
)
## One or more of the old values are recoded into identical new values.
## Please check if you correctly specified the recode-pattern,
## else separate multiple values with comma, e.g. rec="a,b,c=1; d,e,f=2".
datatable(as.matrix(dtFF1985 %>% frq(rTrEdadRec)))
## 1999
dtFF1999 = dtFF1999 %>%
mutate(
rTrEdadRec=rec(as.numeric(rTrEdad),
rec="1 = 1;
2 = 1;
3 = 2;
4 = 3;
5 = 4;
6 = 5;
7 = 6",
as.num = F,
val.labels = c("De 18 a 24 años",
"De 25 a 29 años", "De 30 a 34 años",
"De 35 a 39 años", "De 40 a 44 años",
"De 45 a 49 años"),
var.label = "Tramos de edad ")
)
## One or more of the old values are recoded into identical new values.
## Please check if you correctly specified the recode-pattern,
## else separate multiple values with comma, e.g. rec="a,b,c=1; d,e,f=2".
datatable(as.matrix(dtFF1999 %>% frq(rTrEdadRec)))
## 2018
dtFF2018 = dtFF2018 %>%
mutate(
rTrEdadRec=rec(as.numeric(rTrEdad),
rec="1 = 1;
2 = 1;
3 = 2;
4 = 3;
5 = 4;
6 = 5;
7 = 6",
as.num = F,
val.labels = c("De 18 a 24 años",
"De 25 a 29 años", "De 30 a 34 años",
"De 35 a 39 años", "De 40 a 44 años",
"De 45 a 49 años"),
var.label = "Tramos de edad ")
)
## One or more of the old values are recoded into identical new values.
## Please check if you correctly specified the recode-pattern,
## else separate multiple values with comma, e.g. rec="a,b,c=1; d,e,f=2".
datatable(as.matrix(dtFF2018 %>% frq(rTrEdadRec)))
cor.test(dtFF1985$rNumDesHij, dtFF1985$rNumHij, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF1985$rNumDesHij and dtFF1985$rNumHij
## z = 24.416, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.2217364
cor.test(dtFF1999$rNumDesHij, dtFF1999$rNumHij, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF1999$rNumDesHij and dtFF1999$rNumHij
## z = 39.583, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.388384
cor.test(dtFF2018$rNumDesHij, dtFF2018$rNumHij, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF2018$rNumDesHij and dtFF2018$rNumHij
## z = 45.592, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.3628754
summary( aov (rNumDesHij~rTrNumHij, data= dtFF1985))
## Df Sum Sq Mean Sq F value Pr(>F)
## rTrNumHij 3 910 303.35 392 <2e-16 ***
## Residuals 8694 6728 0.77
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1985$rNumDesHij, g = dtFF1985$rTrNumHij)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1985$rNumDesHij and dtFF1985$rTrNumHij
##
## 0 1 2
## 1 < 2e-16 - -
## 2 0.037 5.5e-15 -
## 3 < 2e-16 < 2e-16 < 2e-16
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rTrNumHij, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rTrNumHij 3 1969 656.3 703 <2e-16 ***
## Residuals 7417 6924 0.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rTrNumHij)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rTrNumHij
##
## 0 1 2
## 1 1.4e-12 - -
## 2 < 2e-16 < 2e-16 -
## 3 < 2e-16 < 2e-16 < 2e-16
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rTrNumHij, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rTrNumHij 3 2668 889.4 1010 <2e-16 ***
## Residuals 11553 10179 0.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rTrNumHij)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rTrNumHij
##
## 0 1 2
## 1 <2e-16 - -
## 2 <2e-16 <2e-16 -
## 3 <2e-16 <2e-16 <2e-16
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según nº de hijos/as",
x = "Nº de hijos/as", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("Ningún hijo/a", "Un hijo/a",
"Dos hijos/as", "Tres o más hijos/as")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rTrNumHij, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rTrNumHij, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rTrNumHij, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rTrNumHij, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rTrNumHij, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rTrNumHij, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rTrNumHij, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rTrNumHij, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rTrNumHij, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
summary( aov (rNumDesHij~rEstudios, data= dtFF1985))
## Df Sum Sq Mean Sq F value Pr(>F)
## rEstudios 4 121 30.180 34.9 <2e-16 ***
## Residuals 8693 7517 0.865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1985$rNumDesHij, g = dtFF1985$rEstudios)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1985$rNumDesHij and dtFF1985$rEstudios
##
## 1 2 3 4
## 2 6.1e-12 - - -
## 3 < 2e-16 1.4e-06 - -
## 4 < 2e-16 7.5e-06 0.9598 -
## 5 0.0001 0.9598 0.5391 0.5784
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rEstudios, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rEstudios 4 254 63.51 54.52 <2e-16 ***
## Residuals 7416 8639 1.16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rEstudios)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rEstudios
##
## 1 2 3 4
## 2 3.6e-07 - - -
## 3 3.5e-14 1.9e-07 - -
## 4 < 2e-16 < 2e-16 6.7e-10 -
## 5 < 2e-16 < 2e-16 3.6e-07 0.73
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rEstudios, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rEstudios 4 82 20.543 18.59 3.04e-15 ***
## Residuals 11552 12765 1.105
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rEstudios)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rEstudios
##
## 1 2 3 4
## 2 1.3e-06 - - -
## 3 1.5e-06 0.90065 - -
## 4 2.4e-11 0.00046 0.00025 -
## 5 2.1e-08 0.48141 0.48141 0.00018
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según nivel de estudios",
x = "Nivel de estudios", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("Menos que primaria",
"Primaria",
"Secundaria 1º etapa",
"Secundaria 2º et., post. y otros",
"Educ. universitaria")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rEstudios, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rEstudios, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rEstudios, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rEstudios, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rEstudios, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rEstudios, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rEstudios, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rEstudios, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rEstudios, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
summary( aov (rNumDesHij~rEstCiv, data= dtFF1985))
## Df Sum Sq Mean Sq F value Pr(>F)
## rEstCiv 3 47 15.635 17.91 1.39e-11 ***
## Residuals 8694 7591 0.873
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1985$rNumDesHij, g = dtFF1985$rEstCiv)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1985$rNumDesHij and dtFF1985$rEstCiv
##
## 1 2 3
## 2 3.7e-09 - -
## 3 7.9e-06 0.0025 -
## 4 0.9171 0.9171 0.0096
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rEstCiv, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rEstCiv 3 646 215.18 193.5 <2e-16 ***
## Residuals 7417 8247 1.11
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rEstCiv)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rEstCiv
##
## 1 2 3
## 2 < 2e-16 - -
## 3 1.1e-06 0.97 -
## 4 4.0e-16 0.25 0.90
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rEstCiv, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rEstCiv 3 749 249.65 238.4 <2e-16 ***
## Residuals 11553 12098 1.05
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rEstCiv)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rEstCiv
##
## 1 2 3
## 2 < 2e-16 - -
## 3 2.1e-05 0.35 -
## 4 < 2e-16 0.27 0.34
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según estado civil",
x = "Estado civil", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("Soltera", "Casada",
"Viuda", "Separada / Divorciada")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rEstCiv, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rEstCiv, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rEstCiv, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rEstCiv, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rEstCiv, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rEstCiv, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rEstCiv, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rEstCiv, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rEstCiv, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
var.test(rNumDesHij~rConvPar, data= dtFF1985)
##
## F test to compare two variances
##
## data: rNumDesHij by rConvPar
## F = 1.0213, num df = 2986, denom df = 5710, p-value = 0.506
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.9596555 1.0876663
## sample estimates:
## ratio of variances
## 1.02134
t.test(rNumDesHij~rConvPar, data= dtFF1985,
var.equal=F, paired=F)
##
## Welch Two Sample t-test
##
## data: rNumDesHij by rConvPar
## t = -5.4489, df = 6003.9, p-value = 5.269e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.15704704 -0.07394377
## sample estimates:
## mean in group 1 mean in group 3
## 2.515567 2.631063
summary( aov (rNumDesHij~rConvPar, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rConvPar 2 575 287.51 256.4 <2e-16 ***
## Residuals 7418 8318 1.12
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rConvPar)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rConvPar
##
## 1 2
## 2 0.014 -
## 3 <2e-16 <2e-16
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rConvPar, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rConvPar 2 632 316.17 299.1 <2e-16 ***
## Residuals 11554 12215 1.06
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rConvPar)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rConvPar
##
## 1 2
## 2 3.2e-06 -
## 3 < 2e-16 < 2e-16
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según situación sentimental y convivencia",
x = "Situación sentimental y de convivencia", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("Sin pareja","Pareja con la que no convive",
"Convive con pareja")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rConvPar, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rConvPar, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rConvPar, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rConvPar, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rConvPar, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rConvPar, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rConvPar, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rConvPar, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rConvPar, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
summary( aov (rNumDesHij~rSitLab, data= dtFF1985))
## Df Sum Sq Mean Sq F value Pr(>F)
## rSitLab 4 74 18.50 21.26 <2e-16 ***
## Residuals 8693 7564 0.87
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1985$rNumDesHij, g = dtFF1985$rSitLab)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1985$rNumDesHij and dtFF1985$rSitLab
##
## 1 2 3 4
## 2 0.970 - - -
## 3 0.021 0.441 - -
## 4 0.025 1.000 4.0e-10 -
## 5 0.490 1.000 8.3e-14 0.171
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rSitLab, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rSitLab 4 301 75.36 65.05 <2e-16 ***
## Residuals 7416 8592 1.16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rSitLab)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rSitLab
##
## 1 2 3 4
## 2 0.2138 - - -
## 3 < 2e-16 8.4e-08 - -
## 4 0.0002 0.4775 < 2e-16 -
## 5 4.1e-11 0.2138 < 2e-16 0.2138
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rSitLab, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rSitLab 4 176 44.06 40.16 <2e-16 ***
## Residuals 11552 12671 1.10
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rSitLab)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rSitLab
##
## 1 2 3 4
## 2 0.0044 - - -
## 3 < 2e-16 6.9e-07 - -
## 4 3.1e-12 0.5784 7.5e-09 -
## 5 5.8e-16 0.6915 3.3e-15 0.6915
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según situación laboral",
x = "Situación laboral", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("Estudiante", "Otras, jubilada o pensionista",
"Labores del hogar",
"En sit. de desempleo", "Trabajando")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rSitLab, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rSitLab, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rSitLab, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rSitLab, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rSitLab, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rSitLab, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rSitLab, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rSitLab, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rSitLab, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
# Comparando los resultados, merece la pena (para los modelos) que la categoría de comparación sea Labores del hogar
ET_SitLab2 <- c("Labores del hogar", "Otras, jub. o pensionista", "Estudiante",
"En sit. de desempleo", "Trabajando")
## 1985
dtFF1985 = dtFF1985 %>%
mutate(
rSitLabRec=rec(as.numeric(rSitLab),
rec="1 = 3;
3 = 1;
2 = 2;
4 = 4;
5 = 5",
as.num = F,
val.labels = ET_SitLab2,
var.label = "Situación laboral")
)
datatable(as.matrix(dtFF1985 %>% frq(rSitLabRec)))
## 1999
dtFF1999 = dtFF1999 %>%
mutate(
rSitLabRec=rec(as.numeric(rSitLab),
rec="1 = 3;
3 = 1;
2 = 2;
4 = 4;
5 = 5",
as.num = F,
val.labels = ET_SitLab2,
var.label = "Situación laboral")
)
datatable(as.matrix(dtFF1999 %>% frq(rSitLabRec)))
## 2018
dtFF2018 = dtFF2018 %>%
mutate(
rSitLabRec=rec(as.numeric(rSitLab),
rec="1 = 3;
3 = 1;
2 = 2;
4 = 4;
5 = 5",
as.num = F,
val.labels = ET_SitLab2,
var.label = "Situación laboral")
)
datatable(as.matrix(dtFF2018 %>% frq(rSitLabRec)))
summary( aov (rNumDesHij~rRelig, data= dtFF1985))
## Df Sum Sq Mean Sq F value Pr(>F)
## rRelig 4 177 44.27 51.59 <2e-16 ***
## Residuals 8693 7461 0.86
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1985$rNumDesHij, g = dtFF1985$rRelig)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1985$rNumDesHij and dtFF1985$rRelig
##
## 0 1 2 3
## 1 1.00000 - - -
## 2 1.00000 1.00000 - -
## 3 0.00064 1e-07 < 2e-16 -
## 4 0.00956 0.00473 0.00514 1.00000
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rRelig, data= dtFF1999))
## Df Sum Sq Mean Sq F value Pr(>F)
## rRelig 4 149 37.33 31.66 <2e-16 ***
## Residuals 7416 8744 1.18
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF1999$rNumDesHij, g = dtFF1999$rRelig)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF1999$rNumDesHij and dtFF1999$rRelig
##
## 0 1 2 3
## 1 1.00000 - - -
## 2 6.5e-05 5.6e-07 - -
## 3 4.6e-11 5.1e-16 5.2e-12 -
## 4 0.00025 2.2e-05 1.00000 0.00454
##
## P value adjustment method: holm
summary( aov (rNumDesHij~rRelig, data= dtFF2018))
## Df Sum Sq Mean Sq F value Pr(>F)
## rRelig 4 440 109.95 102.4 <2e-16 ***
## Residuals 11552 12407 1.07
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(x = dtFF2018$rNumDesHij, g = dtFF2018$rRelig)
##
## Pairwise comparisons using t tests with pooled SD
##
## data: dtFF2018$rNumDesHij and dtFF2018$rRelig
##
## 0 1 2 3
## 1 0.17285 - - -
## 2 0.00032 2.9e-10 - -
## 3 < 2e-16 < 2e-16 1.8e-11 -
## 4 < 2e-16 < 2e-16 < 2e-16 1.6e-09
##
## P value adjustment method: holm
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según creencia religiosa",
x = "Creencia religiosa", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("NsNc", "Ninguna religión",
"Católica no practicante",
"Católica", "Otras religiones")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rRelig, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rRelig, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rRelig, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rRelig, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rRelig, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rRelig, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rRelig, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rRelig, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rRelig, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
cor.test(dtFF1985$rNumDesHij, dtFF1985$rNumHerm, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF1985$rNumDesHij and dtFF1985$rNumHerm
## z = 12.733, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.1113374
cor.test(dtFF2018$rNumDesHij, dtFF2018$rNumHerm, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: dtFF2018$rNumDesHij and dtFF2018$rNumHerm
## z = 16.113, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## 0.1243862
var.test(rNumDesHij~rTamMunNac, data= dtFF1985)
##
## F test to compare two variances
##
## data: rNumDesHij by rTamMunNac
## F = 0.91318, num df = 4254, denom df = 4442, p-value = 0.002773
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.8604715 0.9691494
## sample estimates:
## ratio of variances
## 0.9131775
t.test(rNumDesHij~rTamMunNac, data= dtFF1985,
var.equal=T, paired=F)
##
## Two Sample t-test
##
## data: rNumDesHij by rTamMunNac
## t = 2.83, df = 8696, p-value = 0.004666
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.01747610 0.09625063
## sample estimates:
## mean in group 0 mean in group 1
## 2.620447 2.563583
var.test(rNumDesHij~rTamMunNac, data= dtFF1999)
##
## F test to compare two variances
##
## data: rNumDesHij by rTamMunNac
## F = 0.82065, num df = 1742, denom df = 5426, p-value = 6.33e-07
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.7609046 0.8864355
## sample estimates:
## ratio of variances
## 0.8206519
t.test(rNumDesHij~rTamMunNac, data= dtFF1999,
var.equal=T, paired=F)
##
## Two Sample t-test
##
## data: rNumDesHij by rTamMunNac
## t = 3.8316, df = 7168, p-value = 0.0001284
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.05626914 0.17415774
## sample estimates:
## mean in group 0 mean in group 1
## 2.137694 2.022480
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según hábitat del lugar de nacimiento",
x = "Hábitat del lugar de nacimiento", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("Rural", "Urbano")) +
stat_summary(geom = "point", data = dtFF1985,
aes(x = rTamMunNac, y =rNumDesHij),
fun = mean, color="mediumseagreen", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1985,
aes(x = rTamMunNac, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color = "mediumseagreen") +
stat_summary(geom = "line", data = dtFF1985,
aes(x = rTamMunNac, y =rNumDesHij, group = 1),
fun = mean, color="mediumseagreen", linetype="dashed") +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rTamMunNac, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rTamMunNac, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rTamMunNac, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed")
datatable(as.matrix(dtFF1999 %>% frq(rPaisNac)))
var.test(rNumDesHij~rPaisNac, data= dtFF1999)
##
## F test to compare two variances
##
## data: rNumDesHij by rPaisNac
## F = 0.91962, num df = 7169, denom df = 250, p-value = 0.3365
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.7633739 1.0912775
## sample estimates:
## ratio of variances
## 0.9196176
t.test(rNumDesHij~rPaisNac, data= dtFF1999,
var.equal=T, paired=F)
##
## Two Sample t-test
##
## data: rNumDesHij by rPaisNac
## t = -0.58525, df = 7419, p-value = 0.5584
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.17896010 0.09666946
## sample estimates:
## mean in group 1 mean in group 2
## 2.050488 2.091633
var.test(rNumDesHij~rPaisNac, data= dtFF2018)
##
## F test to compare two variances
##
## data: rNumDesHij by rPaisNac
## F = 0.86525, num df = 10089, denom df = 1466, p-value = 0.0001858
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.7998181 0.9339110
## sample estimates:
## ratio of variances
## 0.8652499
t.test(rNumDesHij~rPaisNac, data= dtFF2018,
var.equal=T, paired=F)
##
## Two Sample t-test
##
## data: rNumDesHij by rPaisNac
## t = -8.2213, df = 11555, p-value = 2.227e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.2991075 -0.1839376
## sample estimates:
## mean in group 1 mean in group 2
## 1.892765 2.134288
ggplot(NULL) +
scale_y_continuous(breaks = seq(0,6, by=1), limits = c(0,6)) +
labs(title = "Media de hijos/as deseados según país de nacimiento",
x = "País de nacimiento", y ="Nº de hijos/as deseados" ) +
theme(axis.title.x = element_text(size = 3)) +
theme(axis.title.y = element_text(size = 3)) +
annotate("text", x=0.75, y= 6, label = "1985",
color = "mediumseagreen", size = 5.5) +
annotate("text", x=1.25, y= 6, label = "1999",
color = "indianred2", size = 5.5) +
annotate("text", x=1.75, y= 6, label = "2018",
color = "slateblue", size = 5.5) +
theme_minimal() +
scale_x_discrete(labels = c("España", "Otro país")) +
stat_summary(geom = "point", data = dtFF1999,
aes(x = rPaisNac, y =rNumDesHij),
fun = mean, color="indianred2", size = 2) +
stat_summary(geom = "errorbar", data = dtFF1999,
aes(x = rPaisNac, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="indianred2") +
stat_summary(geom = "line", data = dtFF1999,
aes(x = rPaisNac, y =rNumDesHij, group = 1),
fun = mean, color="indianred2", linetype="dashed") +
stat_summary(geom = "point", data = dtFF2018,
aes(x = rPaisNac, y =rNumDesHij),
fun = mean, color="slateblue", size = 2) +
stat_summary(geom = "errorbar", data = dtFF2018,
aes(x = rPaisNac, y =rNumDesHij),
fun.data = mean_cl_normal, width = 0.2, color="slateblue") +
stat_summary(geom = "line", data = dtFF2018,
aes(x = rPaisNac, y =rNumDesHij, group = 1),
fun = mean, color="slateblue", linetype="dashed")
Mod85_1 <- lm(
rNumDesHij ~ rTrEdadRec + rNumHij +
rEstCiv + rConvPar +
rEstudios + rSitLabRec +
rRelig +
rNumHerm + rTamMunNac,
data=dtFF1985)
summary(Mod85_1)
##
## Call:
## lm(formula = rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rConvPar +
## rEstudios + rSitLabRec + rRelig + rNumHerm + rTamMunNac,
## data = dtFF1985)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4272 -0.5492 -0.2369 0.4579 4.0680
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.196634 0.102273 21.478 < 2e-16 ***
## rTrEdadRec2 -0.028132 0.033464 -0.841 0.400557
## rTrEdadRec3 -0.060612 0.037366 -1.622 0.104820
## rTrEdadRec4 -0.066205 0.038676 -1.712 0.086969 .
## rTrEdadRec5 -0.019337 0.040873 -0.473 0.636158
## rTrEdadRec6 0.019297 0.042348 0.456 0.648642
## rNumHij 0.234471 0.009018 26.000 < 2e-16 ***
## rEstCiv2 -0.352195 0.096474 -3.651 0.000263 ***
## rEstCiv3 -0.204916 0.092945 -2.205 0.027501 *
## rEstCiv4 -0.328537 0.094015 -3.495 0.000477 ***
## rConvPar3 -0.040322 0.094290 -0.428 0.668925
## rEstudios2 -0.067772 0.031964 -2.120 0.034011 *
## rEstudios3 -0.038228 0.037247 -1.026 0.304773
## rEstudios4 -0.001790 0.039119 -0.046 0.963502
## rEstudios5 0.130854 0.066150 1.978 0.047944 *
## rSitLabRec2 -0.153505 0.151798 -1.011 0.311926
## rSitLabRec3 0.069156 0.046030 1.502 0.133025
## rSitLabRec4 -0.065988 0.041702 -1.582 0.113600
## rSitLabRec5 -0.022993 0.023577 -0.975 0.329483
## rRelig1 0.114099 0.106207 1.074 0.282716
## rRelig2 0.135839 0.092225 1.473 0.140810
## rRelig3 0.350251 0.092176 3.800 0.000146 ***
## rRelig4 0.365328 0.125037 2.922 0.003490 **
## rNumHerm 0.027119 0.004005 6.772 1.35e-11 ***
## rTamMunNac1 0.032376 0.020222 1.601 0.109401
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8764 on 8673 degrees of freedom
## Multiple R-squared: 0.1278, Adjusted R-squared: 0.1254
## F-statistic: 52.97 on 24 and 8673 DF, p-value: < 2.2e-16
## Comprobación de supuestos del modelo normalidad
ks.test(Mod85_1$residuals, pnorm, mean(Mod85_1$residuals),
sd(Mod85_1$residuals))
##
## One-sample Kolmogorov-Smirnov test
##
## data: Mod85_1$residuals
## D = 0.11198, p-value < 2.2e-16
## alternative hypothesis: two-sided
jarque.bera.test(residuals(Mod85_1))
##
## Jarque Bera Test
##
## data: residuals(Mod85_1)
## X-squared = 2796.6, df = 2, p-value < 2.2e-16
qqnorm(Mod85_1$residuals)
qqline(Mod85_1$residuals)
# no se cumple la normalidad
# multicolinealidad
car::vif(Mod85_1)
## GVIF Df GVIF^(1/(2*Df))
## rTrEdadRec 2.700764 5 1.104457
## rNumHij 2.260421 1 1.503470
## rEstCiv 27.068598 3 1.732783
## rConvPar 22.702055 1 4.764667
## rEstudios 1.925346 4 1.085334
## rSitLabRec 2.116108 4 1.098227
## rRelig 1.162147 4 1.018961
## rNumHerm 1.103480 1 1.050466
## rTamMunNac 1.157163 1 1.075715
## entre Estado Civil y Sit. Sentimental y convivencia
### Modelo 2 1985
Mod85_2 <- lm(
rNumDesHij ~ rTrEdadRec + rNumHij +
rEstCiv +
rEstudios + rSitLabRec +
rRelig +
rNumHerm + rTamMunNac,
data=dtFF1985)
summary(Mod85_2)
##
## Call:
## lm(formula = rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rEstudios +
## rSitLabRec + rRelig + rNumHerm + rTamMunNac, data = dtFF1985)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4261 -0.5491 -0.2363 0.4579 4.0681
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.196206 0.102263 21.476 < 2e-16 ***
## rTrEdadRec2 -0.028451 0.033455 -0.850 0.395112
## rTrEdadRec3 -0.060960 0.037356 -1.632 0.102740
## rTrEdadRec4 -0.066246 0.038674 -1.713 0.086757 .
## rTrEdadRec5 -0.019303 0.040871 -0.472 0.636737
## rTrEdadRec6 0.019242 0.042346 0.454 0.649557
## rNumHij 0.234325 0.009011 26.003 < 2e-16 ***
## rEstCiv2 -0.391070 0.032299 -12.108 < 2e-16 ***
## rEstCiv3 -0.205695 0.092923 -2.214 0.026881 *
## rEstCiv4 -0.333814 0.093197 -3.582 0.000343 ***
## rEstudios2 -0.068071 0.031954 -2.130 0.033179 *
## rEstudios3 -0.038337 0.037245 -1.029 0.303353
## rEstudios4 -0.002131 0.039109 -0.054 0.956542
## rEstudios5 0.130042 0.066119 1.967 0.049242 *
## rSitLabRec2 -0.153866 0.151788 -1.014 0.310757
## rSitLabRec3 0.070059 0.045979 1.524 0.127620
## rSitLabRec4 -0.065625 0.041691 -1.574 0.115506
## rSitLabRec5 -0.022603 0.023558 -0.959 0.337367
## rRelig1 0.113224 0.106183 1.066 0.286313
## rRelig2 0.135412 0.092215 1.468 0.142022
## rRelig3 0.350202 0.092172 3.799 0.000146 ***
## rRelig4 0.364407 0.125013 2.915 0.003566 **
## rNumHerm 0.027096 0.004004 6.767 1.4e-11 ***
## rTamMunNac1 0.032366 0.020221 1.601 0.109493
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8763 on 8674 degrees of freedom
## Multiple R-squared: 0.1278, Adjusted R-squared: 0.1255
## F-statistic: 55.27 on 23 and 8674 DF, p-value: < 2.2e-16
# multicolinealidad - corregida
car::vif(Mod85_2)
## GVIF Df GVIF^(1/(2*Df))
## rTrEdadRec 2.697359 5 1.104317
## rNumHij 2.257188 1 1.502394
## rEstCiv 2.675154 3 1.178216
## rEstudios 1.922745 4 1.085151
## rSitLabRec 2.110512 4 1.097864
## rRelig 1.158773 4 1.018591
## rNumHerm 1.103276 1 1.050369
## rTamMunNac 1.157161 1 1.075714
## Comparación de los modelos
anova(Mod85_1, Mod85_2)
## Analysis of Variance Table
##
## Model 1: rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rConvPar + rEstudios +
## rSitLabRec + rRelig + rNumHerm + rTamMunNac
## Model 2: rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rEstudios + rSitLabRec +
## rRelig + rNumHerm + rTamMunNac
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 8673 6661.4
## 2 8674 6661.5 -1 -0.14046 0.1829 0.6689
### no se pierde info.Se opta por el Mod85_2
# (Se puede excluir Situación sentimental)
## comprobación de supuestos del modelo 2 1985
# normalidad de los residuos
ks.test(Mod85_2$residuals, pnorm, mean(Mod85_2$residuals),
sd(Mod85_2$residuals))
##
## One-sample Kolmogorov-Smirnov test
##
## data: Mod85_2$residuals
## D = 0.11197, p-value < 2.2e-16
## alternative hypothesis: two-sided
jarque.bera.test(residuals(Mod85_2))
##
## Jarque Bera Test
##
## data: residuals(Mod85_2)
## X-squared = 2798.3, df = 2, p-value < 2.2e-16
qqnorm(Mod85_2$residuals)
qqline(Mod85_2$residuals)
# sigue sin cumplirse la normalidad
## autocorrelación de los residuos
car::dwt(Mod85_2, max.lag = 4)
## lag Autocorrelation D-W Statistic p-value
## 1 0.09579534 1.807344 0
## 2 0.07124778 1.856276 0
## 3 0.07665347 1.845314 0
## 4 0.06610519 1.866374 0
## Alternative hypothesis: rho[lag] != 0
## valores próx. a 2: ausencia de correlación
## homocedasticidad
bptest(Mod85_2)
##
## studentized Breusch-Pagan test
##
## data: Mod85_2
## BP = 251.59, df = 23, p-value < 2.2e-16
# no se cumple
## El modelo incumple varios de los supuestos
## Como el objetivo no es realizar estimaciones, sino
## un análisis estructural (comparar la capacidad de influencia
## de diferentes las variables que se pueden controlar en los
## 3 momentos de las encuestas sobre el nº de hijos/as deseado)
## se continúa
sjPlot::tab_model(Mod85_2, show.std = T, collapse.ci = T,
show.reflvl = T, p.style = "numeric_stars",
encoding = "iso8859-1",
title = "Encuesta 1985. Modelo 2")
|
Número de hijos/as deseado |
|||
|---|---|---|---|
| Predictors | Estimates | std. Beta | p |
| (Intercept) |
2.20 *** (0.06) |
0.06 (-0.15 – 0.27) |
<0.001 |
| Número de hijos/as |
0.23 *** (0.39) |
0.39 (0.36 – 0.42) |
<0.001 |
| Número de hermanos/as |
0.03 *** (0.07) |
0.07 (0.05 – 0.09) |
<0.001 |
| De 18 a 24 años | Reference | ||
| De 25 a 29 años |
-0.03 (-0.03) |
-0.03 (-0.10 – 0.04) |
0.395 |
| De 30 a 34 años |
-0.06 (-0.07) |
-0.07 (-0.14 – 0.01) |
0.103 |
| De 35 a 39 años |
-0.07 (-0.07) |
-0.07 (-0.15 – 0.01) |
0.087 |
| De 40 a 44 años |
-0.02 (-0.02) |
-0.02 (-0.11 – 0.06) |
0.637 |
| De 45 a 49 años |
0.02 (0.02) |
0.02 (-0.07 – 0.11) |
0.650 |
| Soltera | Reference | ||
| Casada |
-0.39 *** (-0.42) |
-0.42 (-0.48 – -0.35) |
<0.001 |
| Viuda |
-0.21 * (-0.22) |
-0.22 (-0.41 – -0.03) |
0.027 |
| Separada / Divorciada |
-0.33 *** (-0.36) |
-0.36 (-0.55 – -0.16) |
<0.001 |
|
Analfabeta o sin estudios/menos que primaria |
Reference | ||
| Primaria |
-0.07 * (-0.07) |
-0.07 (-0.14 – -0.01) |
0.033 |
| Secundaria 1º etapa |
-0.04 (-0.04) |
-0.04 (-0.12 – 0.04) |
0.303 |
|
Secundaria 2º et., post. y otros |
-0.00 (-0.00) |
-0.00 (-0.08 – 0.08) |
0.957 |
| Educ. universitaria |
0.13 * (0.14) |
0.14 (0.00 – 0.28) |
0.049 |
| Labores del hogar | Reference | ||
| Otras, jub. o pensionista |
-0.15 (-0.16) |
-0.16 (-0.48 – 0.15) |
0.311 |
| Estudiante |
0.07 (0.07) |
0.07 (-0.02 – 0.17) |
0.128 |
| En sit. de desempleo |
-0.07 (-0.07) |
-0.07 (-0.16 – 0.02) |
0.116 |
| Trabajando |
-0.02 (-0.02) |
-0.02 (-0.07 – 0.03) |
0.337 |
| NsNc | Reference | ||
| Ninguna religión |
0.11 (0.12) |
0.12 (-0.10 – 0.34) |
0.286 |
| Católica no practicante |
0.14 (0.14) |
0.14 (-0.05 – 0.34) |
0.142 |
| Católica |
0.35 *** (0.37) |
0.37 (0.18 – 0.57) |
<0.001 |
| Otras religiones |
0.36 ** (0.39) |
0.39 (0.13 – 0.65) |
0.004 |
| Rural | Reference | ||
| Urbano |
0.03 (0.03) |
0.03 (-0.01 – 0.08) |
0.109 |
| Observations | 8698 | ||
| R2 / R2 adjusted | 0.128 / 0.126 | ||
|
|||
sjPlot::plot_model(Mod85_2, sort.est = TRUE, type = "std",
show.values=T, value.offset = .4, value.size =3,
auto.label = T,
title = "Encuesta 1985. Número de hijos/as deseado. Modelo 2")
Mod99_1 <- lm(
rNumDesHij ~ rTrEdadRec + rNumHij +
rEstCiv + rConvPar +
rEstudios + rSitLabRec +
rRelig +
rTamMunNac,
data=dtFF1999)
summary(Mod99_1)
##
## Call:
## lm(formula = rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rConvPar +
## rEstudios + rSitLabRec + rRelig + rTamMunNac, data = dtFF1999)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.9298 -0.4498 0.0383 0.5311 4.3966
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.34463 0.11211 11.993 < 2e-16 ***
## rTrEdadRec2 -0.04799 0.04454 -1.077 0.281306
## rTrEdadRec3 -0.14384 0.04923 -2.922 0.003490 **
## rTrEdadRec4 -0.20039 0.05162 -3.882 0.000104 ***
## rTrEdadRec5 -0.21280 0.05360 -3.970 7.26e-05 ***
## rTrEdadRec6 -0.15285 0.05650 -2.705 0.006842 **
## rNumHij 0.50408 0.01474 34.191 < 2e-16 ***
## rEstCiv2 -0.15372 0.06430 -2.391 0.016838 *
## rEstCiv3 -0.10487 0.11907 -0.881 0.378477
## rEstCiv4 -0.09804 0.06593 -1.487 0.137008
## rConvPar2 0.16146 0.04109 3.930 8.58e-05 ***
## rConvPar3 0.12084 0.06481 1.864 0.062293 .
## rEstudios2 -0.06488 0.07893 -0.822 0.411120
## rEstudios3 -0.09342 0.07771 -1.202 0.229363
## rEstudios4 -0.06518 0.08014 -0.813 0.416042
## rEstudios5 -0.03603 0.08199 -0.439 0.660387
## rSitLabRec2 -0.10388 0.07852 -1.323 0.185872
## rSitLabRec3 0.05888 0.05471 1.076 0.281834
## rSitLabRec4 -0.01282 0.04232 -0.303 0.761979
## rSitLabRec5 0.02595 0.02959 0.877 0.380460
## rRelig1 -0.02168 0.08643 -0.251 0.801961
## rRelig2 0.19904 0.06923 2.875 0.004053 **
## rRelig3 0.28160 0.07018 4.013 6.07e-05 ***
## rRelig4 0.20519 0.08249 2.487 0.012893 *
## rTamMunNac1 0.06598 0.02771 2.381 0.017293 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.958 on 7145 degrees of freedom
## (251 observations deleted due to missingness)
## Multiple R-squared: 0.2346, Adjusted R-squared: 0.232
## F-statistic: 91.26 on 24 and 7145 DF, p-value: < 2.2e-16
### comprobación de supuestos del modelo
# multicolinealidad
car::vif(Mod99_1)
## GVIF Df GVIF^(1/(2*Df))
## rTrEdadRec 3.031815 5 1.117301
## rNumHij 2.339920 1 1.529680
## rEstCiv 9.146216 3 1.446129
## rConvPar 7.474802 2 1.653484
## rEstudios 1.479618 4 1.050192
## rSitLabRec 1.990273 4 1.089843
## rRelig 1.118481 4 1.014095
## rTamMunNac 1.103920 1 1.050676
## entre Estado Civil y Sit. Sentimental y convivencia
### Modelo 2 1999 (excluyendo sit. sentimental)
Mod99_2 <- lm(
rNumDesHij ~ rTrEdadRec + rNumHij +
rEstCiv +
rEstudios + rSitLabRec +
rRelig +
rTamMunNac,
data=dtFF1999)
summary(Mod99_2)
##
## Call:
## lm(formula = rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rEstudios +
## rSitLabRec + rRelig + rTamMunNac, data = dtFF1999)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.9847 -0.4544 0.0404 0.5249 4.4242
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.41369 0.11083 12.755 < 2e-16 ***
## rTrEdadRec2 -0.04705 0.04442 -1.059 0.28953
## rTrEdadRec3 -0.15539 0.04878 -3.186 0.00145 **
## rTrEdadRec4 -0.21818 0.05116 -4.264 2.03e-05 ***
## rTrEdadRec5 -0.23172 0.05326 -4.351 1.38e-05 ***
## rTrEdadRec6 -0.17389 0.05618 -3.095 0.00197 **
## rNumHij 0.50798 0.01463 34.722 < 2e-16 ***
## rEstCiv2 -0.10135 0.03873 -2.617 0.00890 **
## rEstCiv3 -0.14526 0.11877 -1.223 0.22134
## rEstCiv4 -0.12036 0.06572 -1.831 0.06708 .
## rEstudios2 -0.06253 0.07901 -0.791 0.42870
## rEstudios3 -0.09076 0.07778 -1.167 0.24332
## rEstudios4 -0.06059 0.08020 -0.756 0.44997
## rEstudios5 -0.03121 0.08202 -0.380 0.70361
## rSitLabRec2 -0.11081 0.07856 -1.411 0.15842
## rSitLabRec3 0.04077 0.05441 0.749 0.45364
## rSitLabRec4 -0.01386 0.04232 -0.328 0.74328
## rSitLabRec5 0.02422 0.02958 0.819 0.41287
## rRelig1 -0.01287 0.08649 -0.149 0.88175
## rRelig2 0.20598 0.06923 2.975 0.00294 **
## rRelig3 0.28516 0.07012 4.067 4.82e-05 ***
## rRelig4 0.20960 0.08257 2.538 0.01116 *
## rTamMunNac1 0.06611 0.02774 2.383 0.01719 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.959 on 7147 degrees of freedom
## (251 observations deleted due to missingness)
## Multiple R-squared: 0.2328, Adjusted R-squared: 0.2305
## F-statistic: 98.6 on 22 and 7147 DF, p-value: < 2.2e-16
### comprobación
# multicolinealidad - corregida
car::vif(Mod99_2)
## GVIF Df GVIF^(1/(2*Df))
## rTrEdadRec 2.923260 5 1.113235
## rNumHij 2.299605 1 1.516445
## rEstCiv 2.657294 3 1.176901
## rEstudios 1.473363 4 1.049636
## rSitLabRec 1.961314 4 1.087848
## rRelig 1.102841 4 1.012311
## rTamMunNac 1.103889 1 1.050661
### Modelo 3 1999 (escluyendo Estado civil)
Mod99_3 <- lm(
rNumDesHij ~ rTrEdadRec + rNumHij +
rConvPar +
rEstudios + rSitLabRec +
rRelig +
rTamMunNac,
data=dtFF1999)
summary(Mod99_3)
##
## Call:
## lm(formula = rNumDesHij ~ rTrEdadRec + rNumHij + rConvPar + rEstudios +
## rSitLabRec + rRelig + rTamMunNac, data = dtFF1999)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.9519 -0.4586 0.0360 0.5314 4.3974
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.358906 0.111884 12.146 < 2e-16 ***
## rTrEdadRec2 -0.059816 0.044125 -1.356 0.175267
## rTrEdadRec3 -0.168913 0.047739 -3.538 0.000405 ***
## rTrEdadRec4 -0.227368 0.050198 -4.529 6.01e-06 ***
## rTrEdadRec5 -0.242194 0.051903 -4.666 3.12e-06 ***
## rTrEdadRec6 -0.182494 0.054818 -3.329 0.000876 ***
## rNumHij 0.496436 0.014298 34.721 < 2e-16 ***
## rConvPar2 0.166470 0.040816 4.079 4.58e-05 ***
## rConvPar3 0.016435 0.036459 0.451 0.652166
## rEstudios2 -0.077313 0.078798 -0.981 0.326547
## rEstudios3 -0.106330 0.077553 -1.371 0.170396
## rEstudios4 -0.077233 0.080016 -0.965 0.334464
## rEstudios5 -0.045759 0.081909 -0.559 0.576413
## rSitLabRec2 -0.099783 0.078495 -1.271 0.203697
## rSitLabRec3 0.062577 0.054660 1.145 0.252309
## rSitLabRec4 -0.008953 0.042232 -0.212 0.832111
## rSitLabRec5 0.027587 0.029530 0.934 0.350234
## rRelig1 -0.023355 0.086390 -0.270 0.786902
## rRelig2 0.191892 0.069179 2.774 0.005554 **
## rRelig3 0.272887 0.070052 3.896 9.89e-05 ***
## rRelig4 0.203549 0.082507 2.467 0.013646 *
## rTamMunNac1 0.066505 0.027710 2.400 0.016421 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9583 on 7148 degrees of freedom
## (251 observations deleted due to missingness)
## Multiple R-squared: 0.2339, Adjusted R-squared: 0.2317
## F-statistic: 103.9 on 21 and 7148 DF, p-value: < 2.2e-16
### comprobación
# multicolinealidad - corregida
car::vif(Mod99_3)
## GVIF Df GVIF^(1/(2*Df))
## rTrEdadRec 2.782450 5 1.107753
## rNumHij 2.199689 1 1.483135
## rConvPar 2.171690 2 1.213946
## rEstudios 1.463281 4 1.048736
## rSitLabRec 1.965720 4 1.088154
## rRelig 1.095234 4 1.011436
## rTamMunNac 1.103226 1 1.050346
## Comparación de los modelos
anova(Mod99_1, Mod99_2)
## Analysis of Variance Table
##
## Model 1: rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rConvPar + rEstudios +
## rSitLabRec + rRelig + rTamMunNac
## Model 2: rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rEstudios + rSitLabRec +
## rRelig + rTamMunNac
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 7145 6557.6
## 2 7147 6572.8 -2 -15.204 8.2829 0.0002552 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(Mod99_1, Mod99_3)
## Analysis of Variance Table
##
## Model 1: rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rConvPar + rEstudios +
## rSitLabRec + rRelig + rTamMunNac
## Model 2: rNumDesHij ~ rTrEdadRec + rNumHij + rConvPar + rEstudios + rSitLabRec +
## rRelig + rTamMunNac
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 7145 6557.6
## 2 7148 6563.6 -3 -6.0025 2.1801 0.08819 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## mejor (Mod_3) exluir el estado civil que la situación sentimental
### comprobación de supuestos del modelo 3 1999
# normalidad de los residuos
jarque.bera.test(residuals(Mod99_3))
##
## Jarque Bera Test
##
## data: residuals(Mod99_3)
## X-squared = 502.43, df = 2, p-value < 2.2e-16
qqnorm(Mod99_3$residuals)
qqline(Mod99_3$residuals)
# no se cumple la normalidad
## autocorrelación de los residuos
car::dwt(Mod99_3, max.lag = 4)
## lag Autocorrelation D-W Statistic p-value
## 1 0.05626148 1.887464 0
## 2 0.05750877 1.884899 0
## 3 0.04255678 1.914267 0
## 4 0.03864044 1.922041 0
## Alternative hypothesis: rho[lag] != 0
## valores próx. a 2: ausencia de correlación
## homocedasticidad
bptest(Mod99_3)
##
## studentized Breusch-Pagan test
##
## data: Mod99_3
## BP = 535.43, df = 21, p-value < 2.2e-16
# no se cumple
### El modelo incumple los supuestos
sjPlot::tab_model(Mod99_3, show.std = T, collapse.ci = T,
show.reflvl = T, p.style = "numeric_stars",
encoding = "iso8859-1",
title = "Encuesta 1999. Modelo 3")
|
Número de hijos/as deseado |
|||
|---|---|---|---|
| Predictors | Estimates | std. Beta | p |
| (Intercept) |
1.36 *** (-0.07) |
-0.07 (-0.27 – 0.13) |
<0.001 |
| Número de hijos/as |
0.50 *** (0.53) |
0.53 (0.50 – 0.56) |
<0.001 |
| De 18 a 24 años | Reference | ||
| De 25 a 29 años |
-0.06 (-0.05) |
-0.05 (-0.13 – 0.02) |
0.175 |
| De 30 a 34 años |
-0.17 *** (-0.15) |
-0.15 (-0.24 – -0.07) |
<0.001 |
| De 35 a 39 años |
-0.23 *** (-0.21) |
-0.21 (-0.30 – -0.12) |
<0.001 |
| De 40 a 44 años |
-0.24 *** (-0.22) |
-0.22 (-0.31 – -0.13) |
<0.001 |
| De 45 a 49 años |
-0.18 *** (-0.17) |
-0.17 (-0.27 – -0.07) |
0.001 |
| Sin pareja | Reference | ||
|
Pareja con la que no convive |
0.17 *** (0.15) |
0.15 (0.08 – 0.23) |
<0.001 |
| Convive con pareja |
0.02 (0.02) |
0.02 (-0.05 – 0.08) |
0.652 |
|
Analfabeta o sin estudios/menos que primaria |
Reference | ||
| Primaria |
-0.08 (-0.07) |
-0.07 (-0.21 – 0.07) |
0.327 |
| Secundaria 1º etapa |
-0.11 (-0.10) |
-0.10 (-0.24 – 0.04) |
0.170 |
|
Secundaria 2º et., post. y otros |
-0.08 (-0.07) |
-0.07 (-0.21 – 0.07) |
0.334 |
| Educ. universitaria |
-0.05 (-0.04) |
-0.04 (-0.19 – 0.11) |
0.576 |
| Labores del hogar | Reference | ||
| Otras, jub. o pensionista |
-0.10 (-0.09) |
-0.09 (-0.23 – 0.05) |
0.204 |
| Estudiante |
0.06 (0.06) |
0.06 (-0.04 – 0.16) |
0.252 |
| En sit. de desempleo |
-0.01 (-0.01) |
-0.01 (-0.08 – 0.07) |
0.832 |
| Trabajando |
0.03 (0.03) |
0.03 (-0.03 – 0.08) |
0.350 |
| NsNc | Reference | ||
| Ninguna religión |
-0.02 (-0.02) |
-0.02 (-0.18 – 0.13) |
0.787 |
| Católica no practicante |
0.19 ** (0.18) |
0.18 (0.05 – 0.30) |
0.006 |
| Católica |
0.27 *** (0.25) |
0.25 (0.12 – 0.38) |
<0.001 |
| Otras religiones |
0.20 * (0.19) |
0.19 (0.04 – 0.33) |
0.014 |
| Rural | Reference | ||
| Urbano |
0.07 * (0.06) |
0.06 (0.01 – 0.11) |
0.016 |
| Observations | 7170 | ||
| R2 / R2 adjusted | 0.234 / 0.232 | ||
|
|||
sjPlot::plot_model(Mod99_3, sort.est = TRUE, type = "std",
show.values=T, value.offset = .4, value.size =3,
auto.label = T,
title = "Encuesta 1999. Número de hijos/as deseado. Modelo 3")
#### 2018
Mod18_1 <- lm(
rNumDesHij ~ rTrEdadRec + rNumHij +
rEstCiv + rConvPar +
rEstudios + rSitLabRec +
rRelig +
rNumHerm,
data=dtFF2018)
summary(Mod18_1)
##
## Call:
## lm(formula = rNumDesHij ~ rTrEdadRec + rNumHij + rEstCiv + rConvPar +
## rEstudios + rSitLabRec + rRelig + rNumHerm, data = dtFF2018)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5559 -0.5605 0.0105 0.5364 4.2448
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.488266 0.094790 15.701 < 2e-16 ***
## rTrEdadRec2 -0.098203 0.038402 -2.557 0.010563 *
## rTrEdadRec3 -0.322276 0.040379 -7.981 1.59e-15 ***
## rTrEdadRec4 -0.502522 0.040243 -12.487 < 2e-16 ***
## rTrEdadRec5 -0.625291 0.040591 -15.405 < 2e-16 ***
## rTrEdadRec6 -0.685033 0.041380 -16.555 < 2e-16 ***
## rNumHij 0.527443 0.011131 47.385 < 2e-16 ***
## rEstCiv2 0.023472 0.028195 0.832 0.405147
## rEstCiv3 0.346554 0.129726 2.671 0.007564 **
## rEstCiv4 0.124914 0.040213 3.106 0.001899 **
## rConvPar2 0.129796 0.027438 4.731 2.27e-06 ***
## rConvPar3 0.110137 0.029765 3.700 0.000216 ***
## rEstudios2 -0.128212 0.083760 -1.531 0.125872
## rEstudios3 -0.074408 0.084091 -0.885 0.376256
## rEstudios4 -0.011508 0.081254 -0.142 0.887375
## rEstudios5 0.136620 0.082236 1.661 0.096678 .
## rSitLabRec2 0.075561 0.057080 1.324 0.185603
## rSitLabRec3 0.044915 0.047701 0.942 0.346424
## rSitLabRec4 0.052161 0.038258 1.363 0.172785
## rSitLabRec5 0.064056 0.032525 1.969 0.048924 *
## rRelig1 -0.074808 0.031864 -2.348 0.018906 *
## rRelig2 0.055872 0.033903 1.648 0.099384 .
## rRelig3 0.156479 0.030459 5.137 2.83e-07 ***
## rRelig4 0.172217 0.044535 3.867 0.000111 ***
## rNumHerm 0.038537 0.005294 7.280 3.56e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9115 on 11532 degrees of freedom
## Multiple R-squared: 0.2542, Adjusted R-squared: 0.2526
## F-statistic: 163.8 on 24 and 11532 DF, p-value: < 2.2e-16
# multicolinealidad
car::vif(Mod18_1)
## GVIF Df GVIF^(1/(2*Df))
## rTrEdadRec 3.273162 5 1.125892
## rNumHij 1.949983 1 1.396418
## rEstCiv 3.332906 3 1.222186
## rConvPar 2.748788 2 1.287613
## rEstudios 1.330323 4 1.036322
## rSitLabRec 2.313396 4 1.110532
## rRelig 1.216792 4 1.024830
## rNumHerm 1.244656 1 1.115641
## en este caso no se da multicolinealidad
### comprobación de supuestos del modelo 1 2018
# normalidad de los residuos
jarque.bera.test(residuals(Mod18_1))
##
## Jarque Bera Test
##
## data: residuals(Mod18_1)
## X-squared = 183.4, df = 2, p-value < 2.2e-16
qqnorm(Mod18_1$residuals)
qqline(Mod18_1$residuals)
# no se cumple la normalidad
## autocorrelación de los residuos
car::dwt(Mod18_1, max.lag = 4)
## lag Autocorrelation D-W Statistic p-value
## 1 0.0191438076 1.961318 0.028
## 2 0.0004873665 1.998546 0.974
## 3 -0.0049696313 2.009392 0.602
## 4 0.0039457408 1.991437 0.708
## Alternative hypothesis: rho[lag] != 0
## valores próx. a 2: ausencia de correlación
## homocedasticidad
bptest(Mod18_1)
##
## studentized Breusch-Pagan test
##
## data: Mod18_1
## BP = 1032, df = 24, p-value < 2.2e-16
# no se cumple
### El modelo incumple los supuestos
sjPlot::tab_model(Mod18_1, show.std = T, collapse.ci = T,
show.reflvl = T, p.style = "numeric_stars",
encoding = "iso8859-1",
title = "Encuesta 2018. Modelo 1")
|
Número de hijos/as deseado |
|||
|---|---|---|---|
| Predictors | Estimates | std. Beta | p |
| (Intercept) |
1.49 *** (0.16) |
0.16 (-0.01 – 0.34) |
<0.001 |
| Número de hijos/as |
0.53 *** (0.53) |
0.53 (0.51 – 0.55) |
<0.001 |
| Número de hermanos/as |
0.04 *** (0.07) |
0.07 (0.05 – 0.08) |
<0.001 |
| De 18 a 24 años | Reference | ||
| De 25 a 29 años |
-0.10 * (-0.09) |
-0.09 (-0.16 – -0.02) |
0.011 |
| De 30 a 34 años |
-0.32 *** (-0.31) |
-0.31 (-0.38 – -0.23) |
<0.001 |
| De 35 a 39 años |
-0.50 *** (-0.48) |
-0.48 (-0.55 – -0.40) |
<0.001 |
| De 40 a 44 años |
-0.63 *** (-0.59) |
-0.59 (-0.67 – -0.52) |
<0.001 |
| De 45 a 49 años |
-0.69 *** (-0.65) |
-0.65 (-0.73 – -0.57) |
<0.001 |
| Soltera | Reference | ||
| Casada |
0.02 (0.02) |
0.02 (-0.03 – 0.07) |
0.405 |
| Viuda |
0.35 ** (0.33) |
0.33 (0.09 – 0.57) |
0.008 |
| Separada / Divorciada |
0.12 ** (0.12) |
0.12 (0.04 – 0.19) |
0.002 |
| Sin pareja | Reference | ||
|
Pareja con la que no convive |
0.13 *** (0.12) |
0.12 (0.07 – 0.17) |
<0.001 |
| Convive con pareja |
0.11 *** (0.10) |
0.10 (0.05 – 0.16) |
<0.001 |
|
Analfabeta o sin estudios/menos que primaria |
Reference | ||
| Primaria |
-0.13 (-0.12) |
-0.12 (-0.28 – 0.03) |
0.126 |
| Secundaria 1º etapa |
-0.07 (-0.07) |
-0.07 (-0.23 – 0.09) |
0.376 |
|
Secundaria 2º et., post. y otros |
-0.01 (-0.01) |
-0.01 (-0.16 – 0.14) |
0.887 |
| Educ. universitaria |
0.14 (0.13) |
0.13 (-0.02 – 0.28) |
0.097 |
| Labores del hogar | Reference | ||
| Otras, jub. o pensionista |
0.08 (0.07) |
0.07 (-0.03 – 0.18) |
0.186 |
| Estudiante |
0.04 (0.04) |
0.04 (-0.05 – 0.13) |
0.346 |
| En sit. de desempleo |
0.05 (0.05) |
0.05 (-0.02 – 0.12) |
0.173 |
| Trabajando |
0.06 * (0.06) |
0.06 (0.00 – 0.12) |
0.049 |
| NsNc | Reference | ||
| Ninguna religión |
-0.07 * (-0.07) |
-0.07 (-0.13 – -0.01) |
0.019 |
| Católica no practicante |
0.06 (0.05) |
0.05 (-0.01 – 0.12) |
0.099 |
| Católica |
0.16 *** (0.15) |
0.15 (0.09 – 0.21) |
<0.001 |
| Otras religiones |
0.17 *** (0.16) |
0.16 (0.08 – 0.25) |
<0.001 |
| Observations | 11557 | ||
| R2 / R2 adjusted | 0.254 / 0.253 | ||
|
|||
sjPlot::plot_model(Mod18_1, sort.est = TRUE, type = "std",
show.values=T, value.offset = .4, value.size =3,
auto.label = T,
title = "Encuesta 2018 Número de hijos/as deseado. Modelo 1")
sjPlot::tab_model(Mod85_2, Mod99_3, Mod18_1,
show.std = T, collapse.ci = T,
show.reflvl = T, p.style = "numeric_stars",
encoding = "iso8859-1",
dv.labels = c("Encuesta 1985",
"Encuesta 1999", "Encuesta 2018"),
title = "Número de hijos/as deseado")
| Encuesta 1985 | Encuesta 1999 | Encuesta 2018 | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Predictors | Estimates | std. Beta | p | Estimates | std. Beta | p | Estimates | std. Beta | p |
| (Intercept) |
2.20 *** (0.06) |
0.06 (-0.15 – 0.27) |
<0.001 |
1.36 *** (-0.07) |
-0.07 (-0.27 – 0.13) |
<0.001 |
1.49 *** (0.16) |
0.16 (-0.01 – 0.34) |
<0.001 |
| Número de hijos/as |
0.23 *** (0.39) |
0.39 (0.36 – 0.42) |
<0.001 |
0.50 *** (0.53) |
0.53 (0.50 – 0.56) |
<0.001 |
0.53 *** (0.53) |
0.53 (0.51 – 0.55) |
<0.001 |
| Número de hermanos/as |
0.03 *** (0.07) |
0.07 (0.05 – 0.09) |
<0.001 |
0.04 *** (0.07) |
0.07 (0.05 – 0.08) |
<0.001 | |||
| De 18 a 24 años | Reference | Reference | Reference | ||||||
| De 25 a 29 años |
-0.03 (-0.03) |
-0.03 (-0.10 – 0.04) |
0.395 |
-0.06 (-0.05) |
-0.05 (-0.13 – 0.02) |
0.175 |
-0.10 * (-0.09) |
-0.09 (-0.16 – -0.02) |
0.011 |
| De 30 a 34 años |
-0.06 (-0.07) |
-0.07 (-0.14 – 0.01) |
0.103 |
-0.17 *** (-0.15) |
-0.15 (-0.24 – -0.07) |
<0.001 |
-0.32 *** (-0.31) |
-0.31 (-0.38 – -0.23) |
<0.001 |
| De 35 a 39 años |
-0.07 (-0.07) |
-0.07 (-0.15 – 0.01) |
0.087 |
-0.23 *** (-0.21) |
-0.21 (-0.30 – -0.12) |
<0.001 |
-0.50 *** (-0.48) |
-0.48 (-0.55 – -0.40) |
<0.001 |
| De 40 a 44 años |
-0.02 (-0.02) |
-0.02 (-0.11 – 0.06) |
0.637 |
-0.24 *** (-0.22) |
-0.22 (-0.31 – -0.13) |
<0.001 |
-0.63 *** (-0.59) |
-0.59 (-0.67 – -0.52) |
<0.001 |
| De 45 a 49 años |
0.02 (0.02) |
0.02 (-0.07 – 0.11) |
0.650 |
-0.18 *** (-0.17) |
-0.17 (-0.27 – -0.07) |
0.001 |
-0.69 *** (-0.65) |
-0.65 (-0.73 – -0.57) |
<0.001 |
| Soltera | Reference | Reference | Reference | ||||||
| Casada |
-0.39 *** (-0.42) |
-0.42 (-0.48 – -0.35) |
<0.001 |
0.02 (0.02) |
0.02 (-0.03 – 0.07) |
0.405 | |||
| Viuda |
-0.21 * (-0.22) |
-0.22 (-0.41 – -0.03) |
0.027 |
0.35 ** (0.33) |
0.33 (0.09 – 0.57) |
0.008 | |||
| Separada / Divorciada |
-0.33 *** (-0.36) |
-0.36 (-0.55 – -0.16) |
<0.001 |
0.12 ** (0.12) |
0.12 (0.04 – 0.19) |
0.002 | |||
|
Analfabeta o sin estudios/menos que primaria |
Reference | Reference | Reference | ||||||
| Primaria |
-0.07 * (-0.07) |
-0.07 (-0.14 – -0.01) |
0.033 |
-0.08 (-0.07) |
-0.07 (-0.21 – 0.07) |
0.327 |
-0.13 (-0.12) |
-0.12 (-0.28 – 0.03) |
0.126 |
| Secundaria 1º etapa |
-0.04 (-0.04) |
-0.04 (-0.12 – 0.04) |
0.303 |
-0.11 (-0.10) |
-0.10 (-0.24 – 0.04) |
0.170 |
-0.07 (-0.07) |
-0.07 (-0.23 – 0.09) |
0.376 |
|
Secundaria 2º et., post. y otros |
-0.00 (-0.00) |
-0.00 (-0.08 – 0.08) |
0.957 |
-0.08 (-0.07) |
-0.07 (-0.21 – 0.07) |
0.334 |
-0.01 (-0.01) |
-0.01 (-0.16 – 0.14) |
0.887 |
| Educ. universitaria |
0.13 * (0.14) |
0.14 (0.00 – 0.28) |
0.049 |
-0.05 (-0.04) |
-0.04 (-0.19 – 0.11) |
0.576 |
0.14 (0.13) |
0.13 (-0.02 – 0.28) |
0.097 |
| Labores del hogar | Reference | Reference | Reference | ||||||
| Otras, jub. o pensionista |
-0.15 (-0.16) |
-0.16 (-0.48 – 0.15) |
0.311 |
-0.10 (-0.09) |
-0.09 (-0.23 – 0.05) |
0.204 |
0.08 (0.07) |
0.07 (-0.03 – 0.18) |
0.186 |
| Estudiante |
0.07 (0.07) |
0.07 (-0.02 – 0.17) |
0.128 |
0.06 (0.06) |
0.06 (-0.04 – 0.16) |
0.252 |
0.04 (0.04) |
0.04 (-0.05 – 0.13) |
0.346 |
| En sit. de desempleo |
-0.07 (-0.07) |
-0.07 (-0.16 – 0.02) |
0.116 |
-0.01 (-0.01) |
-0.01 (-0.08 – 0.07) |
0.832 |
0.05 (0.05) |
0.05 (-0.02 – 0.12) |
0.173 |
| Trabajando |
-0.02 (-0.02) |
-0.02 (-0.07 – 0.03) |
0.337 |
0.03 (0.03) |
0.03 (-0.03 – 0.08) |
0.350 |
0.06 * (0.06) |
0.06 (0.00 – 0.12) |
0.049 |
| NsNc | Reference | Reference | Reference | ||||||
| Ninguna religión |
0.11 (0.12) |
0.12 (-0.10 – 0.34) |
0.286 |
-0.02 (-0.02) |
-0.02 (-0.18 – 0.13) |
0.787 |
-0.07 * (-0.07) |
-0.07 (-0.13 – -0.01) |
0.019 |
| Católica no practicante |
0.14 (0.14) |
0.14 (-0.05 – 0.34) |
0.142 |
0.19 ** (0.18) |
0.18 (0.05 – 0.30) |
0.006 |
0.06 (0.05) |
0.05 (-0.01 – 0.12) |
0.099 |
| Católica |
0.35 *** (0.37) |
0.37 (0.18 – 0.57) |
<0.001 |
0.27 *** (0.25) |
0.25 (0.12 – 0.38) |
<0.001 |
0.16 *** (0.15) |
0.15 (0.09 – 0.21) |
<0.001 |
| Otras religiones |
0.36 ** (0.39) |
0.39 (0.13 – 0.65) |
0.004 |
0.20 * (0.19) |
0.19 (0.04 – 0.33) |
0.014 |
0.17 *** (0.16) |
0.16 (0.08 – 0.25) |
<0.001 |
| Rural | Reference | Reference | Reference | ||||||
| Urbano |
0.03 (0.03) |
0.03 (-0.01 – 0.08) |
0.109 |
0.07 * (0.06) |
0.06 (0.01 – 0.11) |
0.016 | |||
| Sin pareja | Reference | Reference | Reference | ||||||
|
Pareja con la que no convive |
0.17 *** (0.15) |
0.15 (0.08 – 0.23) |
<0.001 |
0.13 *** (0.12) |
0.12 (0.07 – 0.17) |
<0.001 | |||
| Convive con pareja |
0.02 (0.02) |
0.02 (-0.05 – 0.08) |
0.652 |
0.11 *** (0.10) |
0.10 (0.05 – 0.16) |
<0.001 | |||
| Observations | 8698 | 7170 | 11557 | ||||||
| R2 / R2 adjusted | 0.128 / 0.126 | 0.234 / 0.232 | 0.254 / 0.253 | ||||||
|
|||||||||
sjPlot::plot_models(Mod85_2, Mod99_3, Mod18_1, std.est = "std",
p.shape = T,
rm.terms = c("rEstudios3", "rEstudios4",
"rSitLabRec2",
"rSitLabRec3",
"rSitLabRec4"),
colors = c("mediumseagreen", "indianred2","slateblue"),
m.labels = c("Encuesta 1985",
"Encuesta 1999", "Encuesta 2018"),
legend.title = " ",
title = "Número de hijos/as deseado")