load("sens_esp_23022017.RData")
#sex 1 es varon 0 mujer
names(todo)
## [1] "escuela" "ci_fdn" "p1" "p2"
## [5] "p3" "p4" "p5" "p6"
## [9] "p7" "p8" "p9" "p10"
## [13] "p11" "p12" "p13" "coor_izq"
## [17] "coor_cruzaizq" "p16" "p17" "p18"
## [21] "p19" "p20" "p21" "p22"
## [25] "p23" "p24" "p25" "p26"
## [29] "p27" "p28" "p29" "p30"
## [33] "p31" "p32" "p33" "p34"
## [37] "p35" "p36" "p37" "p38"
## [41] "p39" "p40" "p41" "p42"
## [45] "p43" "p44" "p45" "p46"
## [49] "p47" "p48" "p49" "p50"
## [53] "p51" "p52" "p53" "p54"
## [57] "p55" "p56" "p57" "p58"
## [61] "p59" "p60" "p61" "p62"
## [65] "p63" "p64" "p65" "p66"
## [69] "p67" "p68" "p69" "p70"
## [73] "p71" "p72" "p73" "p74"
## [77] "p75" "p76" "p77" "p78"
## [81] "p79" "p80" "p81" "p82"
## [85] "p83" "p84" "p85" "p86"
## [89] "p87" "p88" "p89" "p90"
## [93] "p91" "p92" "p93" "p94"
## [97] "p95" "p96" "p97" "p98"
## [101] "p99" "p100" "p101" "tot.ci"
## [105] "sexo" "edmes" "totcom.ci" "totmot.ci"
## [109] "ttmotmf.ci" "totad.ci" "totps.ci" "mot_izq"
## [113] "mot_cruzaizq" "cor_izq" "cor_cruzaizq" "leng_izq"
## [117] "leng_cruzaizq" "soc_izq" "soc_cruzaizq" "nbi5"
## [121] "nbi4" "nbi3" "nbi2" "nbi1"
## [125] "cuantas" "tipo" "peso" "sexo.rec"
## [129] "totps.ci.rec" "totad.ci.rec" "ttmotmf.ci.rec" "totmot.ci.rec"
## [133] "totcom.ci.rec" "nbi.rec"
summary(todo[,c(105:127)])
## sexo edmes totcom.ci totmot.ci
## Min. :0.0000 Min. : 5.00 Min. : 65.00 Min. : 65.00
## 1st Qu.:0.0000 1st Qu.:26.00 1st Qu.: 79.00 1st Qu.: 83.75
## Median :1.0000 Median :40.00 Median : 89.00 Median : 94.00
## Mean :0.5359 Mean :38.77 Mean : 88.11 Mean : 95.53
## 3rd Qu.:1.0000 3rd Qu.:51.00 3rd Qu.: 97.00 3rd Qu.: 101.00
## Max. :1.0000 Max. :71.00 Max. :128.00 Max. :1048.00
## NA's :7 NA's :6 NA's :6
## ttmotmf.ci totad.ci totps.ci mot_izq
## Min. : 65.00 Min. : 65.00 Min. : 65.0 no pasa: 61
## 1st Qu.: 81.00 1st Qu.: 87.00 1st Qu.: 84.0 pasa :323
## Median : 93.00 Median : 95.50 Median : 94.5 NA's : 6
## Mean : 91.73 Mean : 95.94 Mean : 92.9
## 3rd Qu.:102.00 3rd Qu.:105.00 3rd Qu.:102.0
## Max. :135.00 Max. :205.00 Max. :131.0
## NA's :6 NA's :4 NA's :2
## mot_cruzaizq cor_izq cor_cruzaizq leng_izq leng_cruzaizq
## no pasa:188 no pasa: 61 no pasa:212 no pasa:118 no pasa:257
## pasa :196 pasa :327 pasa :176 pasa :271 pasa :132
## NA's : 6 NA's : 2 NA's : 2 NA's : 1 NA's : 1
##
##
##
##
## soc_izq soc_cruzaizq nbi5 nbi4
## no pasa: 63 no pasa:130 Min. :0.0 Min. :0.000000
## pasa :326 pasa :259 1st Qu.:0.0 1st Qu.:0.000000
## NA's : 1 NA's : 1 Median :0.0 Median :0.000000
## Mean :0.1 Mean :0.005128
## 3rd Qu.:0.0 3rd Qu.:0.000000
## Max. :1.0 Max. :1.000000
##
## nbi3 nbi2 nbi1 cuantas
## Min. :0.00000 Min. :0.00000 Min. :0.0000 Min. :0.0000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.00000 Median :0.00000 Median :0.0000 Median :0.0000
## Mean :0.05641 Mean :0.02821 Mean :0.2795 Mean :0.4692
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.00000 Max. :1.00000 Max. :1.0000 Max. :4.0000
##
## tipo peso
## CAIF :110 Min. :1135
## C_diurno : 59 1st Qu.:2940
## jar_privado:123 Median :3292
## jar_publico: 98 Mean :3269
## 3rd Qu.:3678
## Max. :4380
## NA's :92
summary(todo$peso)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 1135 2940 3292 3269 3678 4380 92
plot(density(todo$peso,na.rm=TRUE),cex.main=0.9,main="Distribucion del Peso al nacer", xlab="Peso en gramos",ylab="F.R")

summary(todo$tot.ci)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 65.00 84.00 94.00 92.57 101.00 128.00 6
plot(density(todo$tot.ci,na.rm=TRUE),cex.main=0.9,main="Distribucion del Batelle", xlab="Puntaje",ylab="F.R")
abline(v=85,col=2)
abline(v=115,col=3)

todo$sexo.rec<-as.factor(todo$sexo)
levels(todo$sexo.rec)<-c("F","M")
cdplot(todo$sexo.rec~todo$tot.ci,cex.main=0.9,xlab="Puntaje Batelle",ylab="Sexo",main="Distribución condicional del sexo según Batelle")
## Warning: In density.default(x, bw = bw, n = n, ...) :
## extra argument 'cex.main' will be disregarded
## Warning: In density.default(x[y %in% levels(y)[seq_len(i)]], bw = dx$bw,
## n = n, from = min(dx$x), to = max(dx$x), ...) :
## extra argument 'cex.main' will be disregarded

summary(todo$edmes)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 5.00 26.00 40.00 38.77 51.00 71.00 7
summary(todo$tot.ci)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 65.00 84.00 94.00 92.57 101.00 128.00 6
#coor va con bat$totad.ci o con coor con bat$ttmotmf.ci
#motor va con bat$totmot.ci
#leng va con bat$totcom.ci
#soc va con bat$totps.ci
cdplot(todo$soc_izq~todo$totps.ci,cex.main=0.9,xlab="Puntaje Batelle Social",ylab="Guia",main="Distribución condicional de la Guia según Batelle Social")
## Warning: In density.default(x, bw = bw, n = n, ...) :
## extra argument 'cex.main' will be disregarded
## Warning: In density.default(x[y %in% levels(y)[seq_len(i)]], bw = dx$bw,
## n = n, from = min(dx$x), to = max(dx$x), ...) :
## extra argument 'cex.main' will be disregarded

cdplot(todo$soc_cruzaizq~todo$totps.ci,cex.main=0.9,xlab="Puntaje Batelle Social",ylab="Guia",main="Distribución condicional de la Guia (C+I)
según Batelle Social")
## Warning: In density.default(x, bw = bw, n = n, ...) :
## extra argument 'cex.main' will be disregarded
## Warning: In density.default(x[y %in% levels(y)[seq_len(i)]], bw = dx$bw,
## n = n, from = min(dx$x), to = max(dx$x), ...) :
## extra argument 'cex.main' will be disregarded

summary(todo[,120:126])
## nbi5 nbi4 nbi3 nbi2
## Min. :0.0 Min. :0.000000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.0 1st Qu.:0.000000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.0 Median :0.000000 Median :0.00000 Median :0.00000
## Mean :0.1 Mean :0.005128 Mean :0.05641 Mean :0.02821
## 3rd Qu.:0.0 3rd Qu.:0.000000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.0 Max. :1.000000 Max. :1.00000 Max. :1.00000
## nbi1 cuantas tipo
## Min. :0.0000 Min. :0.0000 CAIF :110
## 1st Qu.:0.0000 1st Qu.:0.0000 C_diurno : 59
## Median :0.0000 Median :0.0000 jar_privado:123
## Mean :0.2795 Mean :0.4692 jar_publico: 98
## 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :4.0000
table(todo$nbi1)
##
## 0 1
## 281 109
table(todo$nbi2)
##
## 0 1
## 379 11
table(todo$nbi3)
##
## 0 1
## 368 22
table(todo$nbi4)
##
## 0 1
## 388 2
table(todo$nbi5)
##
## 0 1
## 351 39
table(todo$cuantas)
##
## 0 1 2 3 4
## 257 94 29 9 1
#library(car)
#todo$nbi.rec<-as.factor(recode(todo$cuantas,"0=0;1:4=1"))
#levels(todo$nbi.rec)<-c("Sin NBI","Con NBI")
cdplot(todo$nbi.rec~todo$tot.ci,cex.main=0.9,xlab="Puntaje Batelle",ylab="Sexo",main="Distribución condicional de NBI según Batelle")
## Warning: In density.default(x, bw = bw, n = n, ...) :
## extra argument 'cex.main' will be disregarded
## Warning: In density.default(x[y %in% levels(y)[seq_len(i)]], bw = dx$bw,
## n = n, from = min(dx$x), to = max(dx$x), ...) :
## extra argument 'cex.main' will be disregarded

boxplot(todo$tot.ci~todo$tipo,cex.main=0.8,main="Distribución condicional de Batelle segun tipo de Centro",varwdith=TRUE,horizontal=TRUE)
abline(v=85,col=2)

addmargins(table(todo$tipo,todo$nbi.rec))
##
## Sin NBI Con NBI Sum
## CAIF 67 43 110
## C_diurno 29 30 59
## jar_privado 106 17 123
## jar_publico 55 43 98
## Sum 257 133 390
prop.table(table(todo$tipo,todo$nbi.rec),1)
##
## Sin NBI Con NBI
## CAIF 0.6090909 0.3909091
## C_diurno 0.4915254 0.5084746
## jar_privado 0.8617886 0.1382114
## jar_publico 0.5612245 0.4387755
library(epiR)
## Loading required package: survival
## Package epiR 0.9-79 is loaded
## Type help(epi.about) for summary information
##
#coor va con bat$totad.ci o con coor con bat$ttmotmf.ci
#motor va con bat$totmot.ci
#leng va con bat$totcom.ci
#soc va con bat$totps.ci
tabla.soc1<-table(todo$soc_izq,todo$totps.ci.rec)
tabla.soc2<-table(todo$soc_cruzaizq,todo$totps.ci.rec)
addmargins(tabla.soc1)
##
## Bat.No pasa Bat.Pasa Sum
## no pasa 25 38 63
## pasa 77 247 324
## Sum 102 285 387
addmargins(tabla.soc2)
##
## Bat.No pasa Bat.Pasa Sum
## no pasa 48 82 130
## pasa 54 203 257
## Sum 102 285 387
rval.soc1<-epi.tests(tabla.soc1,conf.level=0.95)
rval.soc1
## Outcome + Outcome - Total
## Test + 25 38 63
## Test - 77 247 324
## Total 102 285 387
##
## Point estimates and 95 % CIs:
## ---------------------------------------------------------
## Apparent prevalence 0.16 (0.13, 0.20)
## True prevalence 0.26 (0.22, 0.31)
## Sensitivity 0.25 (0.17, 0.34)
## Specificity 0.87 (0.82, 0.90)
## Positive predictive value 0.40 (0.28, 0.53)
## Negative predictive value 0.76 (0.71, 0.81)
## Positive likelihood ratio 1.84 (1.17, 2.89)
## Negative likelihood ratio 0.87 (0.77, 0.98)
## ---------------------------------------------------------
rval.soc2<-epi.tests(tabla.soc1,conf.level=0.95)
rval.soc2
## Outcome + Outcome - Total
## Test + 25 38 63
## Test - 77 247 324
## Total 102 285 387
##
## Point estimates and 95 % CIs:
## ---------------------------------------------------------
## Apparent prevalence 0.16 (0.13, 0.20)
## True prevalence 0.26 (0.22, 0.31)
## Sensitivity 0.25 (0.17, 0.34)
## Specificity 0.87 (0.82, 0.90)
## Positive predictive value 0.40 (0.28, 0.53)
## Negative predictive value 0.76 (0.71, 0.81)
## Positive likelihood ratio 1.84 (1.17, 2.89)
## Negative likelihood ratio 0.87 (0.77, 0.98)
## ---------------------------------------------------------
tabla.mot1<-table(todo$mot_izq,todo$totmot.ci.rec)
tabla.mot2<-table(todo$mot_cruzaizq,todo$totmot.ci.rec)
addmargins(tabla.mot1)
##
## Bat.No pasa Bat.Pasa Sum
## no pasa 30 28 58
## pasa 75 245 320
## Sum 105 273 378
addmargins(tabla.mot2)
##
## Bat.No pasa Bat.Pasa Sum
## no pasa 72 112 184
## pasa 33 161 194
## Sum 105 273 378
rval.mot1<-epi.tests(tabla.mot1,conf.level=0.95)
rval.mot1
## Outcome + Outcome - Total
## Test + 30 28 58
## Test - 75 245 320
## Total 105 273 378
##
## Point estimates and 95 % CIs:
## ---------------------------------------------------------
## Apparent prevalence 0.15 (0.12, 0.19)
## True prevalence 0.28 (0.23, 0.33)
## Sensitivity 0.29 (0.20, 0.38)
## Specificity 0.90 (0.86, 0.93)
## Positive predictive value 0.52 (0.38, 0.65)
## Negative predictive value 0.77 (0.72, 0.81)
## Positive likelihood ratio 2.79 (1.75, 4.43)
## Negative likelihood ratio 0.80 (0.70, 0.90)
## ---------------------------------------------------------
rval.mot2<-epi.tests(tabla.mot2,conf.level=0.95)
rval.mot2
## Outcome + Outcome - Total
## Test + 72 112 184
## Test - 33 161 194
## Total 105 273 378
##
## Point estimates and 95 % CIs:
## ---------------------------------------------------------
## Apparent prevalence 0.49 (0.44, 0.54)
## True prevalence 0.28 (0.23, 0.33)
## Sensitivity 0.69 (0.59, 0.77)
## Specificity 0.59 (0.53, 0.65)
## Positive predictive value 0.39 (0.32, 0.47)
## Negative predictive value 0.83 (0.77, 0.88)
## Positive likelihood ratio 1.67 (1.38, 2.03)
## Negative likelihood ratio 0.53 (0.40, 0.72)
## ---------------------------------------------------------
tabla.len1<-table(todo$leng_izq,todo$totcom.ci.rec)
tabla.len2<-table(todo$leng_cruzaizq,todo$totcom.ci.rec)
addmargins(tabla.len1)
##
## Bat.No pasa Bat.Pasa Sum
## no pasa 72 45 117
## pasa 70 196 266
## Sum 142 241 383
addmargins(tabla.len2)
##
## Bat.No pasa Bat.Pasa Sum
## no pasa 114 140 254
## pasa 28 101 129
## Sum 142 241 383
rval.len1<-epi.tests(tabla.len1,conf.level=0.95)
rval.len1
## Outcome + Outcome - Total
## Test + 72 45 117
## Test - 70 196 266
## Total 142 241 383
##
## Point estimates and 95 % CIs:
## ---------------------------------------------------------
## Apparent prevalence 0.31 (0.26, 0.35)
## True prevalence 0.37 (0.32, 0.42)
## Sensitivity 0.51 (0.42, 0.59)
## Specificity 0.81 (0.76, 0.86)
## Positive predictive value 0.62 (0.52, 0.70)
## Negative predictive value 0.74 (0.68, 0.79)
## Positive likelihood ratio 2.72 (1.99, 3.70)
## Negative likelihood ratio 0.61 (0.51, 0.72)
## ---------------------------------------------------------
rval.len2<-epi.tests(tabla.len2,conf.level=0.95)
rval.len2
## Outcome + Outcome - Total
## Test + 114 140 254
## Test - 28 101 129
## Total 142 241 383
##
## Point estimates and 95 % CIs:
## ---------------------------------------------------------
## Apparent prevalence 0.66 (0.61, 0.71)
## True prevalence 0.37 (0.32, 0.42)
## Sensitivity 0.80 (0.73, 0.86)
## Specificity 0.42 (0.36, 0.48)
## Positive predictive value 0.45 (0.39, 0.51)
## Negative predictive value 0.78 (0.70, 0.85)
## Positive likelihood ratio 1.38 (1.21, 1.58)
## Negative likelihood ratio 0.47 (0.33, 0.68)
## ---------------------------------------------------------