Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Trabajo Grupal Grupo #5
Trabajo Grupal Grupo #5
diseño
muestral complejo y criterios
para la evaluación de la calidad de las
estimaciones, GRUPO Nº5
Leonardo Echeverria, Gisell Pazmiño, Francisco
Paspuel
2023-07-31
true
Instrucciones:
Grupo 5:
rm(list = ls())
library(tidyverse)
## ✔ purrr 1.0.1
library(srvyr)
##
##
##
## filter
library(rio)
#choose.files()
dim(base)# dimension
nrow(base)
## [1] 28757
names(base)
## [1] "area" "ciudad" "conglomerado" "panelm" "vivienda"
table(base$estrato,useNA = "ifany")
##
## 0111 0112 0113 0121 0122 0123 0211 0212 0213 0221 0222 0223 0311 0312 0313 0321
## 0322 0323 0411 0412 0413 0421 0422 0423 0511 0512 0513 0521 0522 0523 0611 0612
## 0613 0621 0622 0623 0711 0712 0713 0721 0722 0723 0811 0812 0813 0821 0822 0823
## 0911 0912 0913 0921 0922 0923 1011 1012 1013 1021 1022 1023 1111 1112 1113 1121
## 191 107 79 86 89 86 208 264 345 199 189 175 173 172 159 149
## 1122 1123 1211 1212 1213 1221 1222 1223 1311 1312 1313 1321 1322 1323 1419 1421
## 1422 1423 1519 1521 1522 1523 1611 1612 1613 1621 1622 1623 1711 1712 1713 1721
## 1722 1723 1811 1812 1813 1821 1822 1823 1911 1912 1913 1921 1922 1923 2011 2022
## 2023 2111 2112 2113 2121 2122 2123 2211 2212 2213 2221 2222 2223 2311 2312 2313
## 2321 2322 2323 2411 2412 2413 2429 2511 2512 2513 2611 2612 2613 2711 2712 2713
## 91 91 89 376 347 297 224 887 1043 795 670 1433 835 543 832 618
##
## 24 13 26 27 25 21
## 22 21 17 20 16 26
## 18 22 21 13 15 20
## 18 12 28 28 21 20
## 21 23 32 22 22 17
## 22 26 24 11 25 25
## 23 14 28 12 19 25
## 20 23 18 16 28 33
## 28 17 18 19 23 11
## 12 21 31 27 15 31
## 27 23 26 21 25 22
## 24 15 23 22 21 26
## 23 11 15 35 26 19
## 17 24 20 30 21 22
## 18 19 21 23 21 23
## 31 23 24 31 27 19
## 22 32 23 27 27 29
## 23 26 12 20 17 22
## 29 28 27 14 26 37
## 15 29 11 14 20 28
## 23 18 20 19 21 22
## 17 29 29 17 17 19
## 21 22 20 18 18 28
## 25 18 19 21 34 19
## 23 22 27 22 20 24
## 26 25 29 29 19 20
## 16 27 25 14 19 19
## 25 11 24 23 28 11
## 32 26 19 26 20 20
## 22 14 19 29 14 18
## 19 29 22 21 27 11
## 15 24 14 19 20 25
## 20 20 16 18 21 18
## 19 20 18 21 19 21
## 26 20 19 11 23 20
## 33 22 17 27 20 22
## 17 18 18 28 22 25
## 22 28 14 22 11 22
## 12 17 17 27 19 29
## 15 24 18 16 18 17
## 23 27 30 18 25 26
## 22 18 18 30 20 22
## 23 20 18 17 23 31
## 20 19 19 25 17 20
## 28 26 28 22 22 29
## 17 20 25 23 20 19
## 21 16 20 19 14 29
## 26 15 22 25 24 28
## 31 24 21 22 24 32
## 20 25 23 23 28 26
## 25 31 21 21 19 21
## 24 15 18 20 21 22
## 21 22 24 22 22 26
## 18 29 28 14 21 15
## 33 21 28 27 33 22
## 33 27 18 28 22 23
## 21 25 14 28 19 19
## 23 19 22 28 24 26
## 24 25 12 17 24 27
## 30 28 17 18 25 24
## 26 22 18 23 24 19
## 23 20 17 22 20 30
## 21 19 16 21 18 14
## 21 22 17 17 24 32
## 29 26 19 23 47 30
## 17 18 25 20 27 25
## 23 25 40 28 22 24
## 29 21 29 27 19 29
## 26 26 24 32 34 27
## 19 18 25 27 33 23
## 27 27 23 25 19 30
## 22 36 19 25 25 13
## 31 25 25 23 25 24
## 16 22 29 22 34 27
## 35 28 28 20 20 21
## 21 23 20 27 17 28
## 25 26 28 15 15 19
## 25 14 29 32 34 28
## 36 25 33 30 17 27
## 18 19 25 28 21 12
## 11 23 31 26 23 26
## 28 30 16 21 20 24
## 17 30 20 39 29 19
## 29 27 13 13 21 14
## 20 28 21 18 23 24
## 31 17 10 16 10 20
## 22 11 31 16 15 17
## 16 25 16 25 27 19
## 18 22 19 23 20 24
## 24 10 19 18 19 15
## 15 23 20 19 20 23
## 13 37 31 25 31 30
## 28 26 22 28 30 32
## 26 22 32 19 28 40
## 28 30 29 17 21 21
## 20 30 18 24 20 35
## 27 31 12 23 9 35
## 18 15 27 27 20 19
## 29 23 24 25 21 18
## 28 21 31 26 27 22
## 23 19 27 24 7 24
## 17 32 23 17 18 20
## 25 18 19 20 17 18
## 33 20 21 16 31 18
## 26 20 18 22 21 18
## 23 20 30 20 25 29
## 21 26 20 23 17 24
## 24 21 23 28 21 28
## 20 15 30 19 40 36
## 23 22 35 24 27 29
## 25 34 21 26 16 14
## 20 22 18 18 17 22
## 15 25 20 31 22 20
## 18 22 26 11 17 16
## 20 27 15 16 28 23
## 27 20 27 28 30 19
## 16 14 17 33 27 11
## 25 13 13 35 24 19
## 22 26 19 26 19 23
## 28 14 14 24 27 13
## 29 27 17 20 25 37
## 30 16 14 17 20 33
## 18 30 17 26 14 21
## 27 33 29 17 20 21
## 16 22 20 14 21 29
## 16 24 21 11 30 22
## 23 26 20 26 20 18
## 21 19 16 35 27 20
## 27 23 19 12 28 20
## 20 24 16 27 25 30
## 22 25 16 26 20 23
## 32 24 28 38 39 43
## 26 17 29 18 19 24
## 9 15 21 26 34 19
## 22 26 17 17 17 20
## 18 23 45 21 25 22
## 15 24 27 23 18 28
## 51 34 22 16 24 15
## 25 16 19 25 25 18
## 20 22 19 26 18 24
## 28 14 14 12 19 26
## 18 14 14 22 25 22
## 20 24 15 24 24 19
## 14 25 15 27 13 20
## 21 16 11 17 16 20
## 16 19 21 25 23 19
## 24 19 23 8 18 15
## 18 22 21 29 17 23
## 4 16 17 20 18 16
## 17 20 15 18 17 12
## 17 25 16 21 21 29
## 23 22 20 18 18 17
## 19 14 17 20 24 23
## 32 20 16 19 23 18
## 25 18 20 36 30 23
## 21 23 16 29 23 19
## 24 15 29 21 21 19
## 21 28 17 23 19 23
## 28 25 19 21 18 17
## 16 14 19 23 18 19
## 17 18 27 32 22 24
## 30 15 16 26 23 19
## 24 21 13 15 20 24
## 20 16 30 17 23 24
## 24 12 16 31 19 21
## 24 20 25 29 19 24
## 22 21 21 32 20 22
## 23 24 22 21 17 26
## 22 23 39 20 22 20
## 12 20 22 14 15 30
## 23 27 22 21 18 25
## 20 18 22 20 22 16
## 18 17 24 24 16 17
## 17 21 21 22 28 20
## 22 23 26 14 25 16
## 20 17 22 21 19 20
## 28 21 23 19 15 22
## 11 12 19 18 21 20
## 13 23 22 20 16 22
## 26 20 20 21 23 16
## 23 30 30 21 29 18
## 20 15 28 20 17 21
## 22 13 14 17 25 29
## 20 10 23 27 22 16
## 17 19 28 23 16 21
## 22 25 15 19 29 25
## 17 20 20 16 19 19
## 24 19 18 25 24 35
## 20 18 29 20 20 21
## 17 22 28 29 22 23
## 23 27 32 36 31 17
## 30 13 13 23 22 18
## 16 20 16 17 14 16
## 15 22 24 32 15 17
## 22 22 16 13 22 22
## 20 22 18 35 21 21
## 17 19 22 19 19 27
## 25 27 12 22 29 25
## 13 27 33 25 23 20
## 24 22 28 21 18 19
## 34 22 22 28 22 23
## 30 44 37 31 21 22
## 33 42 27 19 16 23
## 18 25 24 25 11 15
## 12 18 19 21 34 23
## 26 29 21 19 20 13
## 27 24 21 28 20 18
## 12 23 26 26 32 30
## 47 45 25 22 34 28
## 26 33 27 40 31 31
## 25 27 28 23 44 37
## 28 33 19 39 23 22
## 28 30 21 30 23 23
## 29 16 30 16 20 31
## 24 20 30 22
View(base)
upm_1<-filter(base,base$upm=="060150001304"|base$upm== "060150005502"|base$upm=="0
60150005702"|
base$upm=="060150006701"|base$upm== "060150007503"|base$upm=="0601
50900103"|
base$upm=="060158000102"|base$upm== "060161000502"|base$upm=="0602
50000801"|
base$upm=="060251900103"|base$upm== "060254900302"|base$upm=="0603
50000306"|
base$upm=="060350000307"|base$upm== "060352903201"|base$upm=="0603
52903702"|
base$upm=="060450000304"|base$upm=="060450901102"|base$upm== "0606
50000405"|
base$upm=="060650900302"|base$upm=="060750000305"|base$upm== "0607
50901201"|
base$upm=="060754901502"|base$upm=="060950000104"|base$upm== "0609
50000203")
n_distinct((base$upm))
## [1] 1288
n_distinct(base$id_vivienda)
## [1] 8743
names(base)
##
## 0 1 2 3 4 5 6 7 8 9
class(base$condact)
## [1] "numeric"
base = base %>%
p03>=15, 1, NA))
##
## 1 <NA>
## 1341 27416
##
## 0 1 2 3 4 5 6 7 8 9
options(survey.lonely.psu = “certainty”): Se
establece una opción para el paquete “survey” que indica
cómo manejar
las PSU solitarias (“lonely PSU”) en el diseño de la encuesta. En este
caso, se establece en
“certainty”, lo que significa que se considerarán
como PSU certezas.
table(base$t_empleo_nr,useNA = "ifany")
##
## 1 <NA>
## 1341 27416
# Declaracion del plan de muestreo
as_survey_design(
ids = upm,
strata = estrato,
weights = fexp
options(survey.lonely.psu = "certainty")
summary(plan)
## Probabilities:
## Stratum Sizes:
## 0111 0112 0113 0121 0122 0123 0211 0212 0213 0221 0222 0223 0311
## design.PSU 4 4 4 4 4 4 4 4 4 4 4 4 4
## actual.PSU 4 4 4 4 4 4 4 4 4 4 4 4 4
## 0312 0313 0321 0322 0323 0411 0412 0413 0421 0422 0423 0511 0512
## design.PSU 4 4 4 4 4 4 8 4 4 4 4 4 4
## actual.PSU 4 4 4 4 4 4 8 4 4 4 4 4 4
## 0513 0521 0522 0523 0611 0612 0613 0621 0622 0623 0711 0712 0713
## design.PSU 4 4 4 4 4 4 4 4 4 4 4 8 8
## actual.PSU 4 4 4 4 4 4 4 4 4 4 4 8 8
## 0721 0722 0723 0811 0812 0813 0821 0822 0823 0911 0912 0913 0921
## design.PSU 4 4 4 12 16 16 12 12 8 8 4 4 4
## actual.PSU 4 4 4 12 16 16 12 12 8 8 4 4 4
## 0922 0923 1011 1012 1013 1021 1022 1023 1111 1112 1113 1121 1122
## obs 89 86 208 264 345 199 189 175 173 172 159 149 188
## design.PSU 4 4 8 12 16 8 8 8 8 8 8 8 8
## actual.PSU 4 4 8 12 16 8 8 8 8 8 8 8 8
## 1123 1211 1212 1213 1221 1222 1223 1311 1312 1313 1321 1322 1323
## design.PSU 4 4 4 4 4 4 4 4 8 4 4 4 4
## actual.PSU 4 4 4 4 4 4 4 4 8 4 4 4 4
## 1419 1421 1422 1423 1519 1521 1522 1523 1611 1612 1613 1621 1622
## design.PSU 4 4 4 4 8 4 4 4 4 4 4 4 4
## actual.PSU 4 4 4 4 8 4 4 4 4 4 4 4 4
## 1623 1711 1712 1713 1721 1722 1723 1811 1812 1813 1821 1822 1823
## design.PSU 4 8 8 12 8 8 8 4 4 4 4 4 4
## actual.PSU 4 8 8 12 8 8 8 4 4 4 4 4 4
## 1911 1912 1913 1921 1922 1923 2011 2022 2023 2111 2112 2113 2121
## design.PSU 4 4 4 4 4 4 8 4 4 4 8 4 4
## actual.PSU 4 4 4 4 4 4 8 4 4 4 8 4 4
## 2122 2123 2211 2212 2213 2221 2222 2223 2311 2312 2313 2321 2322
## design.PSU 8 4 4 4 4 4 4 4 4 8 4 4 4
## actual.PSU 8 4 4 4 4 4 4 4 4 8 4 4 4
## 2323 2411 2412 2413 2429 2511 2512 2513 2611 2612 2613 2711 2712
## obs 89 376 347 297 224 887 1043 795 670 1433 835 543 832
## design.PSU 4 12 12 12 8 48 52 36 36 60 32 28 36
## actual.PSU 4 12 12 12 8 48 52 36 36 60 32 28 36
## design.PSU 28 28 44 32 24 32 28
## actual.PSU 28 28 44 32 24 32 28
## Data variables:
##
## 1 <NA>
## 1341 27416
summarise(t_empleo_nr = survey_total(t_empleo_nr,
deff = T,
na.rm = T))
View(emp_nr_nac)
group_by(area) %>%
summarise(t_empleo_nr = survey_total(t_empleo_nr,
vartype = c("se","ci","cv"),
deff = T,
na.rm = T))
View(emp_area)
group_by(p02) %>%
summarise(t_empleo_nr = survey_total(t_empleo_nr,
vartype = c("se","ci","cv"),
deff = T,
na.rm = T))
view(emp_sexo)
group_by(p15) %>%
summarise(t_empleo_nr = survey_total(t_empleo_nr,
vartype = c("se","ci","cv"),
deff = T,
na.rm = T))
view(emp_etnia)
# NIVEL NACIONAL
group_by(area,p02,p15) %>%
summarise(t_empleo_nr =survey_mean(t_empleo_nr,
deff = T,
na.rm = T))
summarise(n = n())
View(res)
group_by(area,p02) %>%
summarise(emp_nr_nac = survey_mean(t_empleo_nr,
vartype = c("se","ci","cv"),
deff = T,
na.rm = T),
n = unweighted(n()),
n_upm = n_distinct(upm),
H = n_distinct(estrato),
gl = n_upm - H,
p_error = (emp_nr_nac^(2/3))/9)
View(t_empleo_nr)
INTREPRETACION: