IMPORTACION DE DATOS

library(readxl)
DATA_PARCIAL2 <- read_excel("C:/Users/USERPRO/Desktop/DATA_PARCIAL2.xlsx")

INTRODUCCION

El censo poblacional emerge como la herramienta fundamental que nos permite arrojar luz sobre la compleja red de individuos que conforman una comunidad, ciudad o nación. Este meticuloso recuento no solo captura la magnitud numérica de una población, sino que también revela la diversidad en términos de edad, género, origen étnico, ocupación y otros aspectos cruciales. Así, el censo poblacional se erige como el punto de partida esencial para diseñar políticas públicas, asignar recursos eficientemente y construir un futuro que aborde las necesidades cambiantes de la sociedad. En esta exploración minuciosa, no solo contamos cabezas, sino que también trazamos la historia y las tendencias que moldean el tejido mismo de nuestra existencia colectiva.

#DATA

podemos observar una data con 38 variables de las cuales representan el censo que se ha hecho en una poblacion se podria decir censo basico como tipo de alimentacion tipos de vivienda si tiene cantidad de personas que habitan el hogar etc

#INTERPRETACION DE LAS VARIABLES

UBICACION lugar o parroquia de la provincia de chimborazo

EN QUE CANTON VIVE DE LA PROVINCIA DE CHIMBORAZO lugar en donde vive la persona censada en la provincia

EDAD edad de la persona encuestada

SEXO sexo de la persona encuestada

ESTADO CIVIL estado civil de la persona encuestada

CANTIDAD DE PERSONAS DEL HOGAR cantidad de personas que conforma la familia censada

PARENTEZCO CON LA PERSONA CENSADA tipo de familiar que es con la persona censada

TIPO DE VIVIENDA de que tipo esta construida la vivienda

QUE MATERIAL PREDOMINA EN LA VIVIENDA material del cual es construido la vivienda

CUANTOS CUARTOS DE BAÑO CON DUCHA TIENE se refiere a los baños con ducha que tiene la familia

CUENTA CON INTERNET se refiere a que si la familia dispone del servicio de internet

CUENTA CON COMPUTADORA PORTATIL se refiere a si la familia dispone de una laptop

CUANTOS CELULARES TIENE se refiere a cuantos telefonos celulares dispone la familia encuestada

TIENE SU HOGAR TELEFONO CONVENCIONAL se refiere a que si dispone del servicio de linea telefonica

EN SU HOGAR TIENE COCINA CON HORNO se refiere a que si als familias encuestadas cuales tiene cocina con horno o cocinan de otra manera

TIENE REFRIGERADORA se refiere a que si poseen refrigeradora las familias encuestadas

TIENE LAVADORA se refiere a que si poseen lavadora las familias encuestadas

TIENE EQUIPO DE SONIDO se refiere a que si poseen las familias encuestadas equipos de sonido

Se trata de variables con preguntas basicas que se hacen en un censo poblacional para medir el nivel socioeconomico de las familias

NOMBRES DE LAS VARIABLES QUE TIENE NUESTRA BASE DE DATOS

classes<-sapply(DATA_PARCIAL2,class);classes
##                                                                                                                                                                                                    UBICACIÓN 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                           ¿En qué cantón de la provincia de Chimborazo vive? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                          Edad del encuestado 
##                                                                                                                                                                                                    "numeric" 
##                                                                                                                                                                                                         Sexo 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                                 Estado civil 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                  Cantidad de personas que conforman el hogar 
##                                                                                                                                                                                                    "numeric" 
##                                                                                                                                                        ¿Qué parentesco tiene con el representante del hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                ¿Cuál es el tipo de vivienda? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                     El material predominante de las paredes exteriores de la vivienda es de: 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                      EL material predominante del piso de la vivienda es de: 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                        ¿Cuántos cuartos de baño con ducha de uso exclusivo tiene este hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                         Tipo de servicio higiénico con que cuenta este hogar 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                            ¿Cuenta con servicio de internet? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                       ¿Cuenta con computadora de escritorio? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                            ¿Cuenta con computadora portátil? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                            ¿Cuántos celulares activados tiene en este hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                           ¿Tiene su hogar servicio de teléfono convencional? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                         ¿Tiene en su hogar cocina con horno? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                        ¿Tiene refrigeradora? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                             ¿Tiene lavadora? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                     ¿Tiene equipo de sonido? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                    ¿Cuántas TV a color tienen en este hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                        ¿Cuántos vehículos de uso exclusivo tiene este hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                               ¿Alguien en el hogar compra vestimenta en centros comerciales? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                               ¿En el hogar alguien ha usado internet en los últimos 6 meses? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                       ¿En el hogar alguien utiliza correo electrónico que no es del trabajo? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                      ¿En el hogar alguien está registrado en una red social? 
##                                                                                                                                                                                                  "character" 
##                                                          Exceptuando los libros de texto o manuales de estudio y lecturas de trabajo¿Alguien del hogar ha leído algún libro completo en los últimos 3 meses? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                         ¿Cuál es el nivel de instrucción del Jefe del hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                        ¿Alguien en el hogar está afiliado o cubierto por el seguro del IESS (general, voluntario o campesino) y/o seguro del ISSFA o ISSPOL? 
##                                                                                                                                                                                                  "character" 
## ¿Alguien en el hogar tiene seguro de salud privada con hospitalización, seguro de salud privada sin hospitalización, seguro internacional,seguros municipales y de Consejos Provinciales y/o seguro de vida? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                           ¿Cuál es la ocupación del Representante del hogar? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                               NSE_2023_CUALI 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                    ¿Para qué sector trabaja? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                        ¿Consume usted arroz? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                  ¿Consume usted queso industrial (CON MARCA) 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                       ¿Consume usted huevos? 
##                                                                                                                                                                                                  "character" 
##                                                                                                                                                                                             ¿Consume frutas? 
##                                                                                                                                                                                                  "character"

COVERTIMOS EN FACTOR LAS VARIABLES

datos <- as.data.frame(lapply(DATA_PARCIAL2, function(x) if(is.character(x))
as.factor(x) else x))
str(datos)
## 'data.frame':    577 obs. of  38 variables:
##  $ UBICACIÓN                                                                                                                                                                                                    : Factor w/ 25 levels "Alausí","Cacha",..: 23 23 25 23 6 11 10 24 24 23 ...
##  $ X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.                                                                                                                                                          : Factor w/ 10 levels "Alausí","Chambo",..: 10 10 10 10 4 7 6 10 10 10 ...
##  $ Edad.del.encuestado                                                                                                                                                                                          : num  58 28 40 15 36 23 19 23 48 24 ...
##  $ Sexo                                                                                                                                                                                                         : Factor w/ 2 levels "Femenino","Masculino": 2 2 2 2 2 1 2 2 2 1 ...
##  $ Estado.civil                                                                                                                                                                                                 : Factor w/ 5 levels "Casado","Divorciado",..: 1 1 1 4 1 4 4 4 1 4 ...
##  $ Cantidad.de.personas.que.conforman.el.hogar                                                                                                                                                                  : num  6 3 4 4 6 7 4 6 5 5 ...
##  $ X.Qué.parentesco.tiene.con.el.representante.del.hogar.                                                                                                                                                       : Factor w/ 7 levels "Cónyugue o conviviente",..: 7 7 7 6 7 2 2 6 7 2 ...
##  $ X.Cuál.es.el.tipo.de.vivienda.                                                                                                                                                                               : Factor w/ 7 levels "Casa/Villa","Choza/Covacha/Otro",..: 1 4 1 1 1 1 4 4 1 3 ...
##  $ El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.                                                                                                                                     : Factor w/ 5 levels "Adobe/Tapia",..: 5 3 5 5 5 5 5 5 5 5 ...
##  $ EL.material.predominante.del.piso.de.la.vivienda.es.de.                                                                                                                                                      : Factor w/ 5 levels "Cerámica, baldosa, vinil o marmetón",..: 1 1 1 2 3 3 1 4 2 3 ...
##  $ X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                       : Factor w/ 4 levels "No tiene cuarto de baño exclusivo con ducha en el hogar",..: 4 4 3 2 3 3 4 2 3 2 ...
##  $ Tipo.de.servicio.higiénico.con.que.cuenta.este.hogar                                                                                                                                                         : Factor w/ 6 levels "Con descarga directa al mar, río, lago o quebrada",..: 4 4 4 4 4 4 5 5 4 4 ...
##  $ X.Cuenta.con.servicio.de.internet.                                                                                                                                                                           : Factor w/ 2 levels "No","Si": 2 2 2 2 2 2 2 2 2 2 ...
##  $ X.Cuenta.con.computadora.de.escritorio.                                                                                                                                                                      : Factor w/ 2 levels "No","Si": 2 2 1 2 1 2 2 2 2 2 ...
##  $ X.Cuenta.con.computadora.portátil.                                                                                                                                                                           : Factor w/ 2 levels "No","Si": 2 2 2 2 2 1 2 2 2 1 ...
##  $ X.Cuántos.celulares.activados.tiene.en.este.hogar.                                                                                                                                                           : Factor w/ 5 levels "No tiene celular nadie en el hogar",..: 5 3 4 4 4 3 5 3 4 4 ...
##  $ X.Tiene.su.hogar.servicio.de.teléfono.convencional.                                                                                                                                                          : Factor w/ 2 levels "No","Si": 2 2 2 2 1 1 2 2 2 2 ...
##  $ X.Tiene.en.su.hogar.cocina.con.horno.                                                                                                                                                                        : Factor w/ 2 levels "No","Si": 2 1 2 2 1 1 2 2 2 2 ...
##  $ X.Tiene.refrigeradora.                                                                                                                                                                                       : Factor w/ 2 levels "No","Si": 2 2 2 2 2 2 2 2 2 2 ...
##  $ X.Tiene.lavadora.                                                                                                                                                                                            : Factor w/ 2 levels "No","Si": 2 2 1 1 1 1 2 2 2 1 ...
##  $ X.Tiene.equipo.de.sonido.                                                                                                                                                                                    : Factor w/ 2 levels "No","Si": 2 2 2 2 2 1 2 2 2 1 ...
##  $ X.Cuántas.TV.a.color.tienen.en.este.hogar.                                                                                                                                                                   : Factor w/ 4 levels "No tiene TV a color en el hogar",..: 4 2 2 3 3 3 3 4 3 2 ...
##  $ X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                                       : Factor w/ 4 levels "No tiene vehículo exclusivo para el hogar",..: 2 1 1 2 1 1 4 2 4 1 ...
##  $ X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.                                                                                                                                              : Factor w/ 2 levels "No","Si": 2 2 2 2 2 1 2 2 2 2 ...
##  $ X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.                                                                                                                                              : Factor w/ 2 levels "No","Si": 2 2 2 2 2 2 2 1 2 2 ...
##  $ X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.                                                                                                                                      : Factor w/ 2 levels "No","Si": 2 2 2 2 1 1 2 1 2 2 ...
##  $ X.En.el.hogar.alguien.está.registrado.en.una.red.social.                                                                                                                                                     : Factor w/ 2 levels "No","Si": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.                                                          : Factor w/ 2 levels "No","Si": 2 2 1 2 2 2 2 2 2 1 ...
##  $ X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.                                                                                                                                                        : Factor w/ 8 levels "4 ó más años de educación superior (completa sin postgrado)",..: 1 7 2 3 6 7 6 6 1 7 ...
##  $ X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.                                                                       : Factor w/ 2 levels "No","Si": 2 2 2 2 2 1 2 1 2 1 ...
##  $ X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.: Factor w/ 2 levels "No","Si": 1 2 1 1 1 1 1 2 2 1 ...
##  $ X.Cuál.es.la.ocupación.del.Representante.del.hogar.                                                                                                                                                          : Factor w/ 12 levels "Desempleado",..: 3 3 11 5 11 11 11 8 11 9 ...
##  $ NSE_2023_CUALI                                                                                                                                                                                               : Factor w/ 5 levels "Alto","Bajo",..: 1 3 3 1 5 4 3 5 1 5 ...
##  $ X.Para.qué.sector.trabaja.                                                                                                                                                                                   : Factor w/ 3 levels "Ninguno","Sector privado",..: 3 3 3 2 3 3 2 3 2 2 ...
##  $ X.Consume.usted.arroz.                                                                                                                                                                                       : Factor w/ 2 levels "No","Si": 2 2 2 2 2 2 2 1 2 2 ...
##  $ X.Consume.usted.queso.industrial..CON.MARCA.                                                                                                                                                                 : Factor w/ 2 levels "No","Si": 2 2 2 2 NA NA NA 2 2 2 ...
##  $ X.Consume.usted.huevos.                                                                                                                                                                                      : Factor w/ 2 levels "No","Si": 2 2 2 1 1 2 1 1 2 2 ...
##  $ X.Consume.frutas.                                                                                                                                                                                            : Factor w/ 2 levels "No","Si": 2 2 2 2 1 2 1 2 2 2 ...
class(datos)
## [1] "data.frame"
summary(datos$X.Consume.usted.arroz.)
##  No  Si 
##  43 534

INTERPRETACION podemos ver que existe un total de personas que consumen arroz de 43 y que no consumen arroz de 534

summary(datos$X.Consume.usted.queso.industrial..CON.MARCA.)
##   No   Si NA's 
##  227  166  184

INTERPRETACION podemos ver que existe un total de 227 personas que consumen queso industrial un total de 166 que no consumen y 184 no respondieron

summary(datos$X.Consume.usted.huevos.)
##  No  Si 
## 107 470

INTERPRETACION podemos ver un total de 107 personas que consumen huevos y 470 que no consumen

summary(datos$X.Consume.frutas.)
##  No  Si 
##  88 489

podemos ver un total de 88 personas que consumen frutas y 489 que no consumen

VERIFICACION DE DATOS NA

anyNA(datos) 
## [1] TRUE
sum(is.na(datos))
## [1] 197
datos_limpios <- na.omit(datos)
anyNA(datos_limpios) 
## [1] FALSE
sum(is.na(datos_limpios))
## [1] 0

DIAGRAMA DE BARRAS

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
library(gridExtra)
g1<- ggplot(datos_limpios,aes(x=datos_limpios$X.Consume.usted.arroz.))+ geom_bar(stat="count",width=0.7,fill="aquamarine2")+theme_minimal()

g2<- ggplot(datos_limpios,aes(x=datos_limpios$X.Consume.usted.queso.industrial..CON.MARCA.))+ geom_bar(stat="count",width=0.7,fill="bisque1")+theme_minimal()

g3<- ggplot(datos_limpios,aes(x=datos_limpios$X.Consume.usted.huevos.   ))+ geom_bar(stat="count",width=0.7,fill="chocolate2")+theme_minimal()

g4<- ggplot(datos_limpios,aes(x=datos_limpios$X.Consume.frutas.))+ geom_bar(stat="count",width=0.7,fill="gold")+theme_minimal()

grid.arrange(g1,g2,g3,g4,nrow=2,ncol=2)

datos_limpios
x=model.matrix(`X.Consume.usted.arroz.`~.,data = datos_limpios)
head(x)
##   (Intercept) UBICACIÓNCacha UBICACIÓNCalpi UBICACIÓNChambo UBICACIÓNChunchi
## 1           1              0              0               0                0
## 2           1              0              0               0                0
## 3           1              0              0               0                0
## 4           1              0              0               0                0
## 8           1              0              0               0                0
## 9           1              0              0               0                0
##   UBICACIÓNColta UBICACIÓNCubijíes UBICACIÓNCumanda UBICACIÓNFlores
## 1              0                 0                0               0
## 2              0                 0                0               0
## 3              0                 0                0               0
## 4              0                 0                0               0
## 8              0                 0                0               0
## 9              0                 0                0               0
##   UBICACIÓNGuamote UBICACIÓNGuano UBICACIÓNLicán UBICACIÓNLicto
## 1                0              0              0              0
## 2                0              0              0              0
## 3                0              0              0              0
## 4                0              0              0              0
## 8                0              0              0              0
## 9                0              0              0              0
##   UBICACIÓNLizarzaburu UBICACIÓNMaldonado UBICACIÓNPallatanga UBICACIÓNPenipe
## 1                    0                  0                   0               0
## 2                    0                  0                   0               0
## 3                    0                  0                   0               0
## 4                    0                  0                   0               0
## 8                    0                  0                   0               0
## 9                    0                  0                   0               0
##   UBICACIÓNPungalá UBICACIÓNPunín UBICACIÓNQuimiag UBICACIÓNSan Juan
## 1                0              0                0                 0
## 2                0              0                0                 0
## 3                0              0                0                 0
## 4                0              0                0                 0
## 8                0              0                0                 0
## 9                0              0                0                 0
##   UBICACIÓNSan Luis UBICACIÓNVelasco UBICACIÓNVeloz UBICACIÓNYaruquíes
## 1                 0                1              0                  0
## 2                 0                1              0                  0
## 3                 0                0              0                  1
## 4                 0                1              0                  0
## 8                 0                0              1                  0
## 9                 0                0              1                  0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chambo
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chunchi
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Colta
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Cumanda
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guamote
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guano
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Pallatanga
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Penipe
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Riobamba
## 1                                                           1
## 2                                                           1
## 3                                                           1
## 4                                                           1
## 8                                                           1
## 9                                                           1
##   Edad.del.encuestado SexoMasculino Estado.civilDivorciado Estado.civilOtro
## 1                  58             1                      0                0
## 2                  28             1                      0                0
## 3                  40             1                      0                0
## 4                  15             1                      0                0
## 8                  23             1                      0                0
## 9                  48             1                      0                0
##   Estado.civilSoltero Estado.civilViudo
## 1                   0                 0
## 2                   0                 0
## 3                   0                 0
## 4                   1                 0
## 8                   1                 0
## 9                   0                 0
##   Cantidad.de.personas.que.conforman.el.hogar
## 1                                           6
## 2                                           3
## 3                                           4
## 4                                           4
## 8                                           6
## 9                                           5
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Hijo o hija
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros no parientes
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros parientes
## 1                                                                     0
## 2                                                                     0
## 3                                                                     0
## 4                                                                     0
## 8                                                                     0
## 9                                                                     0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Padres o suegros
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yerno o nuera
## 1                                                                   0
## 2                                                                   0
## 3                                                                   0
## 4                                                                   1
## 8                                                                   1
## 9                                                                   0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yo soy el representante del Hogar
## 1                                                                                       1
## 2                                                                                       1
## 3                                                                                       1
## 4                                                                                       0
## 8                                                                                       0
## 9                                                                                       1
##   X.Cuál.es.el.tipo.de.vivienda.Choza/Covacha/Otro
## 1                                                0
## 2                                                0
## 3                                                0
## 4                                                0
## 8                                                0
## 9                                                0
##   X.Cuál.es.el.tipo.de.vivienda.Cuarto(s) en casa de inquilinato
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              0
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.tipo.de.vivienda.Departamento en casa o edificio
## 1                                                             0
## 2                                                             1
## 3                                                             0
## 4                                                             0
## 8                                                             1
## 9                                                             0
##   X.Cuál.es.el.tipo.de.vivienda.Mediagua X.Cuál.es.el.tipo.de.vivienda.Rancho
## 1                                      0                                    0
## 2                                      0                                    0
## 3                                      0                                    0
## 4                                      0                                    0
## 8                                      0                                    0
## 9                                      0                                    0
##   X.Cuál.es.el.tipo.de.vivienda.Suite de lujo
## 1                                           0
## 2                                           0
## 3                                           0
## 4                                           0
## 8                                           0
## 9                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña no revestida/ Otros materiales
## 1                                                                                                           0
## 2                                                                                                           0
## 3                                                                                                           0
## 4                                                                                                           0
## 8                                                                                                           0
## 9                                                                                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña revestida o bahareque/Madera
## 1                                                                                                         0
## 2                                                                                                         1
## 3                                                                                                         0
## 4                                                                                                         0
## 8                                                                                                         0
## 9                                                                                                         0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Hormigón
## 1                                                                                0
## 2                                                                                0
## 3                                                                                0
## 4                                                                                0
## 8                                                                                0
## 9                                                                                0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Ladrillo o bloque
## 1                                                                                         1
## 2                                                                                         0
## 3                                                                                         1
## 4                                                                                         1
## 8                                                                                         1
## 9                                                                                         1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Duela, parquet, tablón o piso flotante
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             0
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Ladrillo o cemento
## 1                                                                         0
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tabla sin tratar
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       1
## 9                                                                       0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tierra/ Caña/ Otros materiales
## 1                                                                                     0
## 2                                                                                     0
## 3                                                                                     0
## 4                                                                                     0
## 8                                                                                     0
## 9                                                                                     0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 1 cuarto de baño exclusivo con ducha
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                1
## 8                                                                                                                1
## 9                                                                                                                0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 2 cuartos de baño exclusivos con ducha
## 1                                                                                                                  0
## 2                                                                                                                  0
## 3                                                                                                                  1
## 4                                                                                                                  0
## 8                                                                                                                  0
## 9                                                                                                                  1
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 3 o más cuartos de baño exclusivos con ducha
## 1                                                                                                                        1
## 2                                                                                                                        1
## 3                                                                                                                        0
## 4                                                                                                                        0
## 8                                                                                                                        0
## 9                                                                                                                        0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo ciego
## 1                                                                          0
## 2                                                                          0
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo séptico
## 1                                                                            0
## 2                                                                            0
## 3                                                                            0
## 4                                                                            0
## 8                                                                            0
## 9                                                                            0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a red pública de alcantarillado
## 1                                                                                             1
## 2                                                                                             1
## 3                                                                                             1
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarLetrina
## 1                                                           0
## 2                                                           0
## 3                                                           0
## 4                                                           0
## 8                                                           1
## 9                                                           0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarSin Marca
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.Cuenta.con.servicio.de.internet.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuenta.con.computadora.de.escritorio.Si
## 1                                         1
## 2                                         1
## 3                                         0
## 4                                         1
## 8                                         1
## 9                                         1
##   X.Cuenta.con.computadora.portátil.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 1 celular
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 2 celulares
## 1                                                                   0
## 2                                                                   1
## 3                                                                   0
## 4                                                                   0
## 8                                                                   1
## 9                                                                   0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 3 celulares
## 1                                                                   0
## 2                                                                   0
## 3                                                                   1
## 4                                                                   1
## 8                                                                   0
## 9                                                                   1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 4 ó más celulares
## 1                                                                         1
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   X.Tiene.su.hogar.servicio.de.teléfono.convencional.Si
## 1                                                     1
## 2                                                     1
## 3                                                     1
## 4                                                     1
## 8                                                     1
## 9                                                     1
##   X.Tiene.en.su.hogar.cocina.con.horno.Si X.Tiene.refrigeradora.Si
## 1                                       1                        1
## 2                                       0                        1
## 3                                       1                        1
## 4                                       1                        1
## 8                                       1                        1
## 9                                       1                        1
##   X.Tiene.lavadora.Si X.Tiene.equipo.de.sonido.Si
## 1                   1                           1
## 2                   1                           1
## 3                   0                           1
## 4                   0                           1
## 8                   1                           1
## 9                   1                           1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 1 TV a color
## 1                                                            0
## 2                                                            1
## 3                                                            1
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 2 TV a color
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            1
## 8                                                            0
## 9                                                            1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 3 ó más TV a color
## 1                                                                  1
## 2                                                                  0
## 3                                                                  0
## 4                                                                  0
## 8                                                                  1
## 9                                                                  0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 2 vehículo exclusivo
## 1                                                                                1
## 2                                                                                0
## 3                                                                                0
## 4                                                                                1
## 8                                                                                1
## 9                                                                                0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 3 ó más vehículo exclusivo
## 1                                                                                      0
## 2                                                                                      0
## 3                                                                                      0
## 4                                                                                      0
## 8                                                                                      0
## 9                                                                                      0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene un vehículo exclusivo
## 1                                                                                 0
## 2                                                                                 0
## 3                                                                                 0
## 4                                                                                 0
## 8                                                                                 0
## 9                                                                                 1
##   X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 1
## 9                                                                 1
##   X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 0
## 9                                                                 1
##   X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.Si
## 1                                                                         1
## 2                                                                         1
## 3                                                                         1
## 4                                                                         1
## 8                                                                         0
## 9                                                                         1
##   X.En.el.hogar.alguien.está.registrado.en.una.red.social.Si
## 1                                                          1
## 2                                                          1
## 3                                                          1
## 4                                                          1
## 8                                                          1
## 9                                                          1
##   Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.Si
## 1                                                                                                                                                     1
## 2                                                                                                                                                     1
## 3                                                                                                                                                     0
## 4                                                                                                                                                     1
## 8                                                                                                                                                     1
## 9                                                                                                                                                     1
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Hasta 3 años de educación superior (incompleta)
## 1                                                                                                    0
## 2                                                                                                    0
## 3                                                                                                    1
## 4                                                                                                    0
## 8                                                                                                    0
## 9                                                                                                    0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Postgrado
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              1
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria completa
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria incompleta
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria completa
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        1
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria incompleta
## 1                                                                          0
## 2                                                                          1
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Sin estudios
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.Si
## 1                                                                                                                                        1
## 2                                                                                                                                        1
## 3                                                                                                                                        1
## 4                                                                                                                                        1
## 8                                                                                                                                        0
## 9                                                                                                                                        1
##   X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.Si
## 1                                                                                                                                                                                                               0
## 2                                                                                                                                                                                                               1
## 3                                                                                                                                                                                                               0
## 4                                                                                                                                                                                                               0
## 8                                                                                                                                                                                                               1
## 9                                                                                                                                                                                                               1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Empleados de oficina
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       0
## 9                                                                       0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Fuerzas Armadas
## 1                                                                  1
## 2                                                                  1
## 3                                                                  0
## 4                                                                  0
## 8                                                                  0
## 9                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Inactivos
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Oficiales operarios y artesanos
## 1                                                                                  0
## 2                                                                                  0
## 3                                                                                  0
## 4                                                                                  1
## 8                                                                                  0
## 9                                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Operadores de instalaciones y máquinas
## 1                                                                                         0
## 2                                                                                         0
## 3                                                                                         0
## 4                                                                                         0
## 8                                                                                         0
## 9                                                                                         0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Personal directivo de la Administración Pública y de empresas
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                0
## 8                                                                                                                0
## 9                                                                                                                0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Profesionales científicos e intelectuales
## 1                                                                                            0
## 2                                                                                            0
## 3                                                                                            0
## 4                                                                                            0
## 8                                                                                            1
## 9                                                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Técnicos y profesionales de nivel medio
## 1                                                                                          0
## 2                                                                                          0
## 3                                                                                          0
## 4                                                                                          0
## 8                                                                                          0
## 9                                                                                          0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador calificados agropecuarios y pesqueros
## 1                                                                                                   0
## 2                                                                                                   0
## 3                                                                                                   0
## 4                                                                                                   0
## 8                                                                                                   0
## 9                                                                                                   0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador de los servicios y comerciantes
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             1
## 4                                                                                             0
## 8                                                                                             0
## 9                                                                                             1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajadores no calificados
## 1                                                                              0
## 2                                                                              0
## 3                                                                              0
## 4                                                                              0
## 8                                                                              0
## 9                                                                              0
##   NSE_2023_CUALIBajo NSE_2023_CUALIMedio Alto NSE_2023_CUALIMedio Bajo
## 1                  0                        0                        0
## 2                  0                        1                        0
## 3                  0                        1                        0
## 4                  0                        0                        0
## 8                  0                        0                        0
## 9                  0                        0                        0
##   NSE_2023_CUALIMedio Típico X.Para.qué.sector.trabaja.Sector privado
## 1                          0                                        0
## 2                          0                                        0
## 3                          0                                        0
## 4                          0                                        1
## 8                          1                                        0
## 9                          0                                        1
##   X.Para.qué.sector.trabaja.Sector público
## 1                                        1
## 2                                        1
## 3                                        1
## 4                                        0
## 8                                        1
## 9                                        0
##   X.Consume.usted.queso.industrial..CON.MARCA.Si X.Consume.usted.huevos.Si
## 1                                              1                         1
## 2                                              1                         1
## 3                                              1                         1
## 4                                              1                         0
## 8                                              1                         0
## 9                                              1                         1
##   X.Consume.frutas.Si
## 1                   1
## 2                   1
## 3                   1
## 4                   1
## 8                   1
## 9                   1
x=model.matrix(`X.Consume.usted.queso.industrial..CON.MARCA.`~.,data = datos_limpios)
head(x)
##   (Intercept) UBICACIÓNCacha UBICACIÓNCalpi UBICACIÓNChambo UBICACIÓNChunchi
## 1           1              0              0               0                0
## 2           1              0              0               0                0
## 3           1              0              0               0                0
## 4           1              0              0               0                0
## 8           1              0              0               0                0
## 9           1              0              0               0                0
##   UBICACIÓNColta UBICACIÓNCubijíes UBICACIÓNCumanda UBICACIÓNFlores
## 1              0                 0                0               0
## 2              0                 0                0               0
## 3              0                 0                0               0
## 4              0                 0                0               0
## 8              0                 0                0               0
## 9              0                 0                0               0
##   UBICACIÓNGuamote UBICACIÓNGuano UBICACIÓNLicán UBICACIÓNLicto
## 1                0              0              0              0
## 2                0              0              0              0
## 3                0              0              0              0
## 4                0              0              0              0
## 8                0              0              0              0
## 9                0              0              0              0
##   UBICACIÓNLizarzaburu UBICACIÓNMaldonado UBICACIÓNPallatanga UBICACIÓNPenipe
## 1                    0                  0                   0               0
## 2                    0                  0                   0               0
## 3                    0                  0                   0               0
## 4                    0                  0                   0               0
## 8                    0                  0                   0               0
## 9                    0                  0                   0               0
##   UBICACIÓNPungalá UBICACIÓNPunín UBICACIÓNQuimiag UBICACIÓNSan Juan
## 1                0              0                0                 0
## 2                0              0                0                 0
## 3                0              0                0                 0
## 4                0              0                0                 0
## 8                0              0                0                 0
## 9                0              0                0                 0
##   UBICACIÓNSan Luis UBICACIÓNVelasco UBICACIÓNVeloz UBICACIÓNYaruquíes
## 1                 0                1              0                  0
## 2                 0                1              0                  0
## 3                 0                0              0                  1
## 4                 0                1              0                  0
## 8                 0                0              1                  0
## 9                 0                0              1                  0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chambo
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chunchi
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Colta
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Cumanda
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guamote
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guano
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Pallatanga
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Penipe
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Riobamba
## 1                                                           1
## 2                                                           1
## 3                                                           1
## 4                                                           1
## 8                                                           1
## 9                                                           1
##   Edad.del.encuestado SexoMasculino Estado.civilDivorciado Estado.civilOtro
## 1                  58             1                      0                0
## 2                  28             1                      0                0
## 3                  40             1                      0                0
## 4                  15             1                      0                0
## 8                  23             1                      0                0
## 9                  48             1                      0                0
##   Estado.civilSoltero Estado.civilViudo
## 1                   0                 0
## 2                   0                 0
## 3                   0                 0
## 4                   1                 0
## 8                   1                 0
## 9                   0                 0
##   Cantidad.de.personas.que.conforman.el.hogar
## 1                                           6
## 2                                           3
## 3                                           4
## 4                                           4
## 8                                           6
## 9                                           5
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Hijo o hija
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros no parientes
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros parientes
## 1                                                                     0
## 2                                                                     0
## 3                                                                     0
## 4                                                                     0
## 8                                                                     0
## 9                                                                     0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Padres o suegros
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yerno o nuera
## 1                                                                   0
## 2                                                                   0
## 3                                                                   0
## 4                                                                   1
## 8                                                                   1
## 9                                                                   0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yo soy el representante del Hogar
## 1                                                                                       1
## 2                                                                                       1
## 3                                                                                       1
## 4                                                                                       0
## 8                                                                                       0
## 9                                                                                       1
##   X.Cuál.es.el.tipo.de.vivienda.Choza/Covacha/Otro
## 1                                                0
## 2                                                0
## 3                                                0
## 4                                                0
## 8                                                0
## 9                                                0
##   X.Cuál.es.el.tipo.de.vivienda.Cuarto(s) en casa de inquilinato
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              0
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.tipo.de.vivienda.Departamento en casa o edificio
## 1                                                             0
## 2                                                             1
## 3                                                             0
## 4                                                             0
## 8                                                             1
## 9                                                             0
##   X.Cuál.es.el.tipo.de.vivienda.Mediagua X.Cuál.es.el.tipo.de.vivienda.Rancho
## 1                                      0                                    0
## 2                                      0                                    0
## 3                                      0                                    0
## 4                                      0                                    0
## 8                                      0                                    0
## 9                                      0                                    0
##   X.Cuál.es.el.tipo.de.vivienda.Suite de lujo
## 1                                           0
## 2                                           0
## 3                                           0
## 4                                           0
## 8                                           0
## 9                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña no revestida/ Otros materiales
## 1                                                                                                           0
## 2                                                                                                           0
## 3                                                                                                           0
## 4                                                                                                           0
## 8                                                                                                           0
## 9                                                                                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña revestida o bahareque/Madera
## 1                                                                                                         0
## 2                                                                                                         1
## 3                                                                                                         0
## 4                                                                                                         0
## 8                                                                                                         0
## 9                                                                                                         0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Hormigón
## 1                                                                                0
## 2                                                                                0
## 3                                                                                0
## 4                                                                                0
## 8                                                                                0
## 9                                                                                0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Ladrillo o bloque
## 1                                                                                         1
## 2                                                                                         0
## 3                                                                                         1
## 4                                                                                         1
## 8                                                                                         1
## 9                                                                                         1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Duela, parquet, tablón o piso flotante
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             0
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Ladrillo o cemento
## 1                                                                         0
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tabla sin tratar
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       1
## 9                                                                       0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tierra/ Caña/ Otros materiales
## 1                                                                                     0
## 2                                                                                     0
## 3                                                                                     0
## 4                                                                                     0
## 8                                                                                     0
## 9                                                                                     0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 1 cuarto de baño exclusivo con ducha
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                1
## 8                                                                                                                1
## 9                                                                                                                0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 2 cuartos de baño exclusivos con ducha
## 1                                                                                                                  0
## 2                                                                                                                  0
## 3                                                                                                                  1
## 4                                                                                                                  0
## 8                                                                                                                  0
## 9                                                                                                                  1
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 3 o más cuartos de baño exclusivos con ducha
## 1                                                                                                                        1
## 2                                                                                                                        1
## 3                                                                                                                        0
## 4                                                                                                                        0
## 8                                                                                                                        0
## 9                                                                                                                        0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo ciego
## 1                                                                          0
## 2                                                                          0
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo séptico
## 1                                                                            0
## 2                                                                            0
## 3                                                                            0
## 4                                                                            0
## 8                                                                            0
## 9                                                                            0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a red pública de alcantarillado
## 1                                                                                             1
## 2                                                                                             1
## 3                                                                                             1
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarLetrina
## 1                                                           0
## 2                                                           0
## 3                                                           0
## 4                                                           0
## 8                                                           1
## 9                                                           0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarSin Marca
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.Cuenta.con.servicio.de.internet.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuenta.con.computadora.de.escritorio.Si
## 1                                         1
## 2                                         1
## 3                                         0
## 4                                         1
## 8                                         1
## 9                                         1
##   X.Cuenta.con.computadora.portátil.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 1 celular
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 2 celulares
## 1                                                                   0
## 2                                                                   1
## 3                                                                   0
## 4                                                                   0
## 8                                                                   1
## 9                                                                   0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 3 celulares
## 1                                                                   0
## 2                                                                   0
## 3                                                                   1
## 4                                                                   1
## 8                                                                   0
## 9                                                                   1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 4 ó más celulares
## 1                                                                         1
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   X.Tiene.su.hogar.servicio.de.teléfono.convencional.Si
## 1                                                     1
## 2                                                     1
## 3                                                     1
## 4                                                     1
## 8                                                     1
## 9                                                     1
##   X.Tiene.en.su.hogar.cocina.con.horno.Si X.Tiene.refrigeradora.Si
## 1                                       1                        1
## 2                                       0                        1
## 3                                       1                        1
## 4                                       1                        1
## 8                                       1                        1
## 9                                       1                        1
##   X.Tiene.lavadora.Si X.Tiene.equipo.de.sonido.Si
## 1                   1                           1
## 2                   1                           1
## 3                   0                           1
## 4                   0                           1
## 8                   1                           1
## 9                   1                           1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 1 TV a color
## 1                                                            0
## 2                                                            1
## 3                                                            1
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 2 TV a color
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            1
## 8                                                            0
## 9                                                            1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 3 ó más TV a color
## 1                                                                  1
## 2                                                                  0
## 3                                                                  0
## 4                                                                  0
## 8                                                                  1
## 9                                                                  0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 2 vehículo exclusivo
## 1                                                                                1
## 2                                                                                0
## 3                                                                                0
## 4                                                                                1
## 8                                                                                1
## 9                                                                                0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 3 ó más vehículo exclusivo
## 1                                                                                      0
## 2                                                                                      0
## 3                                                                                      0
## 4                                                                                      0
## 8                                                                                      0
## 9                                                                                      0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene un vehículo exclusivo
## 1                                                                                 0
## 2                                                                                 0
## 3                                                                                 0
## 4                                                                                 0
## 8                                                                                 0
## 9                                                                                 1
##   X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 1
## 9                                                                 1
##   X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 0
## 9                                                                 1
##   X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.Si
## 1                                                                         1
## 2                                                                         1
## 3                                                                         1
## 4                                                                         1
## 8                                                                         0
## 9                                                                         1
##   X.En.el.hogar.alguien.está.registrado.en.una.red.social.Si
## 1                                                          1
## 2                                                          1
## 3                                                          1
## 4                                                          1
## 8                                                          1
## 9                                                          1
##   Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.Si
## 1                                                                                                                                                     1
## 2                                                                                                                                                     1
## 3                                                                                                                                                     0
## 4                                                                                                                                                     1
## 8                                                                                                                                                     1
## 9                                                                                                                                                     1
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Hasta 3 años de educación superior (incompleta)
## 1                                                                                                    0
## 2                                                                                                    0
## 3                                                                                                    1
## 4                                                                                                    0
## 8                                                                                                    0
## 9                                                                                                    0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Postgrado
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              1
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria completa
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria incompleta
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria completa
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        1
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria incompleta
## 1                                                                          0
## 2                                                                          1
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Sin estudios
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.Si
## 1                                                                                                                                        1
## 2                                                                                                                                        1
## 3                                                                                                                                        1
## 4                                                                                                                                        1
## 8                                                                                                                                        0
## 9                                                                                                                                        1
##   X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.Si
## 1                                                                                                                                                                                                               0
## 2                                                                                                                                                                                                               1
## 3                                                                                                                                                                                                               0
## 4                                                                                                                                                                                                               0
## 8                                                                                                                                                                                                               1
## 9                                                                                                                                                                                                               1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Empleados de oficina
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       0
## 9                                                                       0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Fuerzas Armadas
## 1                                                                  1
## 2                                                                  1
## 3                                                                  0
## 4                                                                  0
## 8                                                                  0
## 9                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Inactivos
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Oficiales operarios y artesanos
## 1                                                                                  0
## 2                                                                                  0
## 3                                                                                  0
## 4                                                                                  1
## 8                                                                                  0
## 9                                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Operadores de instalaciones y máquinas
## 1                                                                                         0
## 2                                                                                         0
## 3                                                                                         0
## 4                                                                                         0
## 8                                                                                         0
## 9                                                                                         0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Personal directivo de la Administración Pública y de empresas
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                0
## 8                                                                                                                0
## 9                                                                                                                0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Profesionales científicos e intelectuales
## 1                                                                                            0
## 2                                                                                            0
## 3                                                                                            0
## 4                                                                                            0
## 8                                                                                            1
## 9                                                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Técnicos y profesionales de nivel medio
## 1                                                                                          0
## 2                                                                                          0
## 3                                                                                          0
## 4                                                                                          0
## 8                                                                                          0
## 9                                                                                          0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador calificados agropecuarios y pesqueros
## 1                                                                                                   0
## 2                                                                                                   0
## 3                                                                                                   0
## 4                                                                                                   0
## 8                                                                                                   0
## 9                                                                                                   0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador de los servicios y comerciantes
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             1
## 4                                                                                             0
## 8                                                                                             0
## 9                                                                                             1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajadores no calificados
## 1                                                                              0
## 2                                                                              0
## 3                                                                              0
## 4                                                                              0
## 8                                                                              0
## 9                                                                              0
##   NSE_2023_CUALIBajo NSE_2023_CUALIMedio Alto NSE_2023_CUALIMedio Bajo
## 1                  0                        0                        0
## 2                  0                        1                        0
## 3                  0                        1                        0
## 4                  0                        0                        0
## 8                  0                        0                        0
## 9                  0                        0                        0
##   NSE_2023_CUALIMedio Típico X.Para.qué.sector.trabaja.Sector privado
## 1                          0                                        0
## 2                          0                                        0
## 3                          0                                        0
## 4                          0                                        1
## 8                          1                                        0
## 9                          0                                        1
##   X.Para.qué.sector.trabaja.Sector público X.Consume.usted.arroz.Si
## 1                                        1                        1
## 2                                        1                        1
## 3                                        1                        1
## 4                                        0                        1
## 8                                        1                        0
## 9                                        0                        1
##   X.Consume.usted.huevos.Si X.Consume.frutas.Si
## 1                         1                   1
## 2                         1                   1
## 3                         1                   1
## 4                         0                   1
## 8                         0                   1
## 9                         1                   1
x=model.matrix(`X.Consume.usted.huevos.`~.,data = datos_limpios)
head(x)
##   (Intercept) UBICACIÓNCacha UBICACIÓNCalpi UBICACIÓNChambo UBICACIÓNChunchi
## 1           1              0              0               0                0
## 2           1              0              0               0                0
## 3           1              0              0               0                0
## 4           1              0              0               0                0
## 8           1              0              0               0                0
## 9           1              0              0               0                0
##   UBICACIÓNColta UBICACIÓNCubijíes UBICACIÓNCumanda UBICACIÓNFlores
## 1              0                 0                0               0
## 2              0                 0                0               0
## 3              0                 0                0               0
## 4              0                 0                0               0
## 8              0                 0                0               0
## 9              0                 0                0               0
##   UBICACIÓNGuamote UBICACIÓNGuano UBICACIÓNLicán UBICACIÓNLicto
## 1                0              0              0              0
## 2                0              0              0              0
## 3                0              0              0              0
## 4                0              0              0              0
## 8                0              0              0              0
## 9                0              0              0              0
##   UBICACIÓNLizarzaburu UBICACIÓNMaldonado UBICACIÓNPallatanga UBICACIÓNPenipe
## 1                    0                  0                   0               0
## 2                    0                  0                   0               0
## 3                    0                  0                   0               0
## 4                    0                  0                   0               0
## 8                    0                  0                   0               0
## 9                    0                  0                   0               0
##   UBICACIÓNPungalá UBICACIÓNPunín UBICACIÓNQuimiag UBICACIÓNSan Juan
## 1                0              0                0                 0
## 2                0              0                0                 0
## 3                0              0                0                 0
## 4                0              0                0                 0
## 8                0              0                0                 0
## 9                0              0                0                 0
##   UBICACIÓNSan Luis UBICACIÓNVelasco UBICACIÓNVeloz UBICACIÓNYaruquíes
## 1                 0                1              0                  0
## 2                 0                1              0                  0
## 3                 0                0              0                  1
## 4                 0                1              0                  0
## 8                 0                0              1                  0
## 9                 0                0              1                  0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chambo
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chunchi
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Colta
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Cumanda
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guamote
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guano
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Pallatanga
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Penipe
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Riobamba
## 1                                                           1
## 2                                                           1
## 3                                                           1
## 4                                                           1
## 8                                                           1
## 9                                                           1
##   Edad.del.encuestado SexoMasculino Estado.civilDivorciado Estado.civilOtro
## 1                  58             1                      0                0
## 2                  28             1                      0                0
## 3                  40             1                      0                0
## 4                  15             1                      0                0
## 8                  23             1                      0                0
## 9                  48             1                      0                0
##   Estado.civilSoltero Estado.civilViudo
## 1                   0                 0
## 2                   0                 0
## 3                   0                 0
## 4                   1                 0
## 8                   1                 0
## 9                   0                 0
##   Cantidad.de.personas.que.conforman.el.hogar
## 1                                           6
## 2                                           3
## 3                                           4
## 4                                           4
## 8                                           6
## 9                                           5
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Hijo o hija
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros no parientes
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros parientes
## 1                                                                     0
## 2                                                                     0
## 3                                                                     0
## 4                                                                     0
## 8                                                                     0
## 9                                                                     0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Padres o suegros
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yerno o nuera
## 1                                                                   0
## 2                                                                   0
## 3                                                                   0
## 4                                                                   1
## 8                                                                   1
## 9                                                                   0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yo soy el representante del Hogar
## 1                                                                                       1
## 2                                                                                       1
## 3                                                                                       1
## 4                                                                                       0
## 8                                                                                       0
## 9                                                                                       1
##   X.Cuál.es.el.tipo.de.vivienda.Choza/Covacha/Otro
## 1                                                0
## 2                                                0
## 3                                                0
## 4                                                0
## 8                                                0
## 9                                                0
##   X.Cuál.es.el.tipo.de.vivienda.Cuarto(s) en casa de inquilinato
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              0
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.tipo.de.vivienda.Departamento en casa o edificio
## 1                                                             0
## 2                                                             1
## 3                                                             0
## 4                                                             0
## 8                                                             1
## 9                                                             0
##   X.Cuál.es.el.tipo.de.vivienda.Mediagua X.Cuál.es.el.tipo.de.vivienda.Rancho
## 1                                      0                                    0
## 2                                      0                                    0
## 3                                      0                                    0
## 4                                      0                                    0
## 8                                      0                                    0
## 9                                      0                                    0
##   X.Cuál.es.el.tipo.de.vivienda.Suite de lujo
## 1                                           0
## 2                                           0
## 3                                           0
## 4                                           0
## 8                                           0
## 9                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña no revestida/ Otros materiales
## 1                                                                                                           0
## 2                                                                                                           0
## 3                                                                                                           0
## 4                                                                                                           0
## 8                                                                                                           0
## 9                                                                                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña revestida o bahareque/Madera
## 1                                                                                                         0
## 2                                                                                                         1
## 3                                                                                                         0
## 4                                                                                                         0
## 8                                                                                                         0
## 9                                                                                                         0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Hormigón
## 1                                                                                0
## 2                                                                                0
## 3                                                                                0
## 4                                                                                0
## 8                                                                                0
## 9                                                                                0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Ladrillo o bloque
## 1                                                                                         1
## 2                                                                                         0
## 3                                                                                         1
## 4                                                                                         1
## 8                                                                                         1
## 9                                                                                         1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Duela, parquet, tablón o piso flotante
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             0
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Ladrillo o cemento
## 1                                                                         0
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tabla sin tratar
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       1
## 9                                                                       0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tierra/ Caña/ Otros materiales
## 1                                                                                     0
## 2                                                                                     0
## 3                                                                                     0
## 4                                                                                     0
## 8                                                                                     0
## 9                                                                                     0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 1 cuarto de baño exclusivo con ducha
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                1
## 8                                                                                                                1
## 9                                                                                                                0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 2 cuartos de baño exclusivos con ducha
## 1                                                                                                                  0
## 2                                                                                                                  0
## 3                                                                                                                  1
## 4                                                                                                                  0
## 8                                                                                                                  0
## 9                                                                                                                  1
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 3 o más cuartos de baño exclusivos con ducha
## 1                                                                                                                        1
## 2                                                                                                                        1
## 3                                                                                                                        0
## 4                                                                                                                        0
## 8                                                                                                                        0
## 9                                                                                                                        0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo ciego
## 1                                                                          0
## 2                                                                          0
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo séptico
## 1                                                                            0
## 2                                                                            0
## 3                                                                            0
## 4                                                                            0
## 8                                                                            0
## 9                                                                            0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a red pública de alcantarillado
## 1                                                                                             1
## 2                                                                                             1
## 3                                                                                             1
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarLetrina
## 1                                                           0
## 2                                                           0
## 3                                                           0
## 4                                                           0
## 8                                                           1
## 9                                                           0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarSin Marca
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.Cuenta.con.servicio.de.internet.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuenta.con.computadora.de.escritorio.Si
## 1                                         1
## 2                                         1
## 3                                         0
## 4                                         1
## 8                                         1
## 9                                         1
##   X.Cuenta.con.computadora.portátil.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 1 celular
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 2 celulares
## 1                                                                   0
## 2                                                                   1
## 3                                                                   0
## 4                                                                   0
## 8                                                                   1
## 9                                                                   0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 3 celulares
## 1                                                                   0
## 2                                                                   0
## 3                                                                   1
## 4                                                                   1
## 8                                                                   0
## 9                                                                   1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 4 ó más celulares
## 1                                                                         1
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   X.Tiene.su.hogar.servicio.de.teléfono.convencional.Si
## 1                                                     1
## 2                                                     1
## 3                                                     1
## 4                                                     1
## 8                                                     1
## 9                                                     1
##   X.Tiene.en.su.hogar.cocina.con.horno.Si X.Tiene.refrigeradora.Si
## 1                                       1                        1
## 2                                       0                        1
## 3                                       1                        1
## 4                                       1                        1
## 8                                       1                        1
## 9                                       1                        1
##   X.Tiene.lavadora.Si X.Tiene.equipo.de.sonido.Si
## 1                   1                           1
## 2                   1                           1
## 3                   0                           1
## 4                   0                           1
## 8                   1                           1
## 9                   1                           1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 1 TV a color
## 1                                                            0
## 2                                                            1
## 3                                                            1
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 2 TV a color
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            1
## 8                                                            0
## 9                                                            1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 3 ó más TV a color
## 1                                                                  1
## 2                                                                  0
## 3                                                                  0
## 4                                                                  0
## 8                                                                  1
## 9                                                                  0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 2 vehículo exclusivo
## 1                                                                                1
## 2                                                                                0
## 3                                                                                0
## 4                                                                                1
## 8                                                                                1
## 9                                                                                0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 3 ó más vehículo exclusivo
## 1                                                                                      0
## 2                                                                                      0
## 3                                                                                      0
## 4                                                                                      0
## 8                                                                                      0
## 9                                                                                      0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene un vehículo exclusivo
## 1                                                                                 0
## 2                                                                                 0
## 3                                                                                 0
## 4                                                                                 0
## 8                                                                                 0
## 9                                                                                 1
##   X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 1
## 9                                                                 1
##   X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 0
## 9                                                                 1
##   X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.Si
## 1                                                                         1
## 2                                                                         1
## 3                                                                         1
## 4                                                                         1
## 8                                                                         0
## 9                                                                         1
##   X.En.el.hogar.alguien.está.registrado.en.una.red.social.Si
## 1                                                          1
## 2                                                          1
## 3                                                          1
## 4                                                          1
## 8                                                          1
## 9                                                          1
##   Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.Si
## 1                                                                                                                                                     1
## 2                                                                                                                                                     1
## 3                                                                                                                                                     0
## 4                                                                                                                                                     1
## 8                                                                                                                                                     1
## 9                                                                                                                                                     1
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Hasta 3 años de educación superior (incompleta)
## 1                                                                                                    0
## 2                                                                                                    0
## 3                                                                                                    1
## 4                                                                                                    0
## 8                                                                                                    0
## 9                                                                                                    0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Postgrado
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              1
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria completa
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria incompleta
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria completa
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        1
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria incompleta
## 1                                                                          0
## 2                                                                          1
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Sin estudios
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.Si
## 1                                                                                                                                        1
## 2                                                                                                                                        1
## 3                                                                                                                                        1
## 4                                                                                                                                        1
## 8                                                                                                                                        0
## 9                                                                                                                                        1
##   X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.Si
## 1                                                                                                                                                                                                               0
## 2                                                                                                                                                                                                               1
## 3                                                                                                                                                                                                               0
## 4                                                                                                                                                                                                               0
## 8                                                                                                                                                                                                               1
## 9                                                                                                                                                                                                               1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Empleados de oficina
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       0
## 9                                                                       0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Fuerzas Armadas
## 1                                                                  1
## 2                                                                  1
## 3                                                                  0
## 4                                                                  0
## 8                                                                  0
## 9                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Inactivos
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Oficiales operarios y artesanos
## 1                                                                                  0
## 2                                                                                  0
## 3                                                                                  0
## 4                                                                                  1
## 8                                                                                  0
## 9                                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Operadores de instalaciones y máquinas
## 1                                                                                         0
## 2                                                                                         0
## 3                                                                                         0
## 4                                                                                         0
## 8                                                                                         0
## 9                                                                                         0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Personal directivo de la Administración Pública y de empresas
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                0
## 8                                                                                                                0
## 9                                                                                                                0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Profesionales científicos e intelectuales
## 1                                                                                            0
## 2                                                                                            0
## 3                                                                                            0
## 4                                                                                            0
## 8                                                                                            1
## 9                                                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Técnicos y profesionales de nivel medio
## 1                                                                                          0
## 2                                                                                          0
## 3                                                                                          0
## 4                                                                                          0
## 8                                                                                          0
## 9                                                                                          0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador calificados agropecuarios y pesqueros
## 1                                                                                                   0
## 2                                                                                                   0
## 3                                                                                                   0
## 4                                                                                                   0
## 8                                                                                                   0
## 9                                                                                                   0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador de los servicios y comerciantes
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             1
## 4                                                                                             0
## 8                                                                                             0
## 9                                                                                             1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajadores no calificados
## 1                                                                              0
## 2                                                                              0
## 3                                                                              0
## 4                                                                              0
## 8                                                                              0
## 9                                                                              0
##   NSE_2023_CUALIBajo NSE_2023_CUALIMedio Alto NSE_2023_CUALIMedio Bajo
## 1                  0                        0                        0
## 2                  0                        1                        0
## 3                  0                        1                        0
## 4                  0                        0                        0
## 8                  0                        0                        0
## 9                  0                        0                        0
##   NSE_2023_CUALIMedio Típico X.Para.qué.sector.trabaja.Sector privado
## 1                          0                                        0
## 2                          0                                        0
## 3                          0                                        0
## 4                          0                                        1
## 8                          1                                        0
## 9                          0                                        1
##   X.Para.qué.sector.trabaja.Sector público X.Consume.usted.arroz.Si
## 1                                        1                        1
## 2                                        1                        1
## 3                                        1                        1
## 4                                        0                        1
## 8                                        1                        0
## 9                                        0                        1
##   X.Consume.usted.queso.industrial..CON.MARCA.Si X.Consume.frutas.Si
## 1                                              1                   1
## 2                                              1                   1
## 3                                              1                   1
## 4                                              1                   1
## 8                                              1                   1
## 9                                              1                   1
x=model.matrix(`X.Consume.frutas.`~.,data = datos_limpios)
head(x)
##   (Intercept) UBICACIÓNCacha UBICACIÓNCalpi UBICACIÓNChambo UBICACIÓNChunchi
## 1           1              0              0               0                0
## 2           1              0              0               0                0
## 3           1              0              0               0                0
## 4           1              0              0               0                0
## 8           1              0              0               0                0
## 9           1              0              0               0                0
##   UBICACIÓNColta UBICACIÓNCubijíes UBICACIÓNCumanda UBICACIÓNFlores
## 1              0                 0                0               0
## 2              0                 0                0               0
## 3              0                 0                0               0
## 4              0                 0                0               0
## 8              0                 0                0               0
## 9              0                 0                0               0
##   UBICACIÓNGuamote UBICACIÓNGuano UBICACIÓNLicán UBICACIÓNLicto
## 1                0              0              0              0
## 2                0              0              0              0
## 3                0              0              0              0
## 4                0              0              0              0
## 8                0              0              0              0
## 9                0              0              0              0
##   UBICACIÓNLizarzaburu UBICACIÓNMaldonado UBICACIÓNPallatanga UBICACIÓNPenipe
## 1                    0                  0                   0               0
## 2                    0                  0                   0               0
## 3                    0                  0                   0               0
## 4                    0                  0                   0               0
## 8                    0                  0                   0               0
## 9                    0                  0                   0               0
##   UBICACIÓNPungalá UBICACIÓNPunín UBICACIÓNQuimiag UBICACIÓNSan Juan
## 1                0              0                0                 0
## 2                0              0                0                 0
## 3                0              0                0                 0
## 4                0              0                0                 0
## 8                0              0                0                 0
## 9                0              0                0                 0
##   UBICACIÓNSan Luis UBICACIÓNVelasco UBICACIÓNVeloz UBICACIÓNYaruquíes
## 1                 0                1              0                  0
## 2                 0                1              0                  0
## 3                 0                0              0                  1
## 4                 0                1              0                  0
## 8                 0                0              1                  0
## 9                 0                0              1                  0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chambo
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Chunchi
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Colta
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Cumanda
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guamote
## 1                                                          0
## 2                                                          0
## 3                                                          0
## 4                                                          0
## 8                                                          0
## 9                                                          0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Guano
## 1                                                        0
## 2                                                        0
## 3                                                        0
## 4                                                        0
## 8                                                        0
## 9                                                        0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Pallatanga
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Penipe
## 1                                                         0
## 2                                                         0
## 3                                                         0
## 4                                                         0
## 8                                                         0
## 9                                                         0
##   X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.Riobamba
## 1                                                           1
## 2                                                           1
## 3                                                           1
## 4                                                           1
## 8                                                           1
## 9                                                           1
##   Edad.del.encuestado SexoMasculino Estado.civilDivorciado Estado.civilOtro
## 1                  58             1                      0                0
## 2                  28             1                      0                0
## 3                  40             1                      0                0
## 4                  15             1                      0                0
## 8                  23             1                      0                0
## 9                  48             1                      0                0
##   Estado.civilSoltero Estado.civilViudo
## 1                   0                 0
## 2                   0                 0
## 3                   0                 0
## 4                   1                 0
## 8                   1                 0
## 9                   0                 0
##   Cantidad.de.personas.que.conforman.el.hogar
## 1                                           6
## 2                                           3
## 3                                           4
## 4                                           4
## 8                                           6
## 9                                           5
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Hijo o hija
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros no parientes
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Otros parientes
## 1                                                                     0
## 2                                                                     0
## 3                                                                     0
## 4                                                                     0
## 8                                                                     0
## 9                                                                     0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Padres o suegros
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yerno o nuera
## 1                                                                   0
## 2                                                                   0
## 3                                                                   0
## 4                                                                   1
## 8                                                                   1
## 9                                                                   0
##   X.Qué.parentesco.tiene.con.el.representante.del.hogar.Yo soy el representante del Hogar
## 1                                                                                       1
## 2                                                                                       1
## 3                                                                                       1
## 4                                                                                       0
## 8                                                                                       0
## 9                                                                                       1
##   X.Cuál.es.el.tipo.de.vivienda.Choza/Covacha/Otro
## 1                                                0
## 2                                                0
## 3                                                0
## 4                                                0
## 8                                                0
## 9                                                0
##   X.Cuál.es.el.tipo.de.vivienda.Cuarto(s) en casa de inquilinato
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              0
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.tipo.de.vivienda.Departamento en casa o edificio
## 1                                                             0
## 2                                                             1
## 3                                                             0
## 4                                                             0
## 8                                                             1
## 9                                                             0
##   X.Cuál.es.el.tipo.de.vivienda.Mediagua X.Cuál.es.el.tipo.de.vivienda.Rancho
## 1                                      0                                    0
## 2                                      0                                    0
## 3                                      0                                    0
## 4                                      0                                    0
## 8                                      0                                    0
## 9                                      0                                    0
##   X.Cuál.es.el.tipo.de.vivienda.Suite de lujo
## 1                                           0
## 2                                           0
## 3                                           0
## 4                                           0
## 8                                           0
## 9                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña no revestida/ Otros materiales
## 1                                                                                                           0
## 2                                                                                                           0
## 3                                                                                                           0
## 4                                                                                                           0
## 8                                                                                                           0
## 9                                                                                                           0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Caña revestida o bahareque/Madera
## 1                                                                                                         0
## 2                                                                                                         1
## 3                                                                                                         0
## 4                                                                                                         0
## 8                                                                                                         0
## 9                                                                                                         0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Hormigón
## 1                                                                                0
## 2                                                                                0
## 3                                                                                0
## 4                                                                                0
## 8                                                                                0
## 9                                                                                0
##   El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.Ladrillo o bloque
## 1                                                                                         1
## 2                                                                                         0
## 3                                                                                         1
## 4                                                                                         1
## 8                                                                                         1
## 9                                                                                         1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Duela, parquet, tablón o piso flotante
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             0
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Ladrillo o cemento
## 1                                                                         0
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tabla sin tratar
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       1
## 9                                                                       0
##   EL.material.predominante.del.piso.de.la.vivienda.es.de.Tierra/ Caña/ Otros materiales
## 1                                                                                     0
## 2                                                                                     0
## 3                                                                                     0
## 4                                                                                     0
## 8                                                                                     0
## 9                                                                                     0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 1 cuarto de baño exclusivo con ducha
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                1
## 8                                                                                                                1
## 9                                                                                                                0
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 2 cuartos de baño exclusivos con ducha
## 1                                                                                                                  0
## 2                                                                                                                  0
## 3                                                                                                                  1
## 4                                                                                                                  0
## 8                                                                                                                  0
## 9                                                                                                                  1
##   X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.Tiene 3 o más cuartos de baño exclusivos con ducha
## 1                                                                                                                        1
## 2                                                                                                                        1
## 3                                                                                                                        0
## 4                                                                                                                        0
## 8                                                                                                                        0
## 9                                                                                                                        0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo ciego
## 1                                                                          0
## 2                                                                          0
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a pozo séptico
## 1                                                                            0
## 2                                                                            0
## 3                                                                            0
## 4                                                                            0
## 8                                                                            0
## 9                                                                            0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarConectado a red pública de alcantarillado
## 1                                                                                             1
## 2                                                                                             1
## 3                                                                                             1
## 4                                                                                             1
## 8                                                                                             0
## 9                                                                                             1
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarLetrina
## 1                                                           0
## 2                                                           0
## 3                                                           0
## 4                                                           0
## 8                                                           1
## 9                                                           0
##   Tipo.de.servicio.higiénico.con.que.cuenta.este.hogarSin Marca
## 1                                                             0
## 2                                                             0
## 3                                                             0
## 4                                                             0
## 8                                                             0
## 9                                                             0
##   X.Cuenta.con.servicio.de.internet.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuenta.con.computadora.de.escritorio.Si
## 1                                         1
## 2                                         1
## 3                                         0
## 4                                         1
## 8                                         1
## 9                                         1
##   X.Cuenta.con.computadora.portátil.Si
## 1                                    1
## 2                                    1
## 3                                    1
## 4                                    1
## 8                                    1
## 9                                    1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 1 celular
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 2 celulares
## 1                                                                   0
## 2                                                                   1
## 3                                                                   0
## 4                                                                   0
## 8                                                                   1
## 9                                                                   0
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 3 celulares
## 1                                                                   0
## 2                                                                   0
## 3                                                                   1
## 4                                                                   1
## 8                                                                   0
## 9                                                                   1
##   X.Cuántos.celulares.activados.tiene.en.este.hogar.Tiene 4 ó más celulares
## 1                                                                         1
## 2                                                                         0
## 3                                                                         0
## 4                                                                         0
## 8                                                                         0
## 9                                                                         0
##   X.Tiene.su.hogar.servicio.de.teléfono.convencional.Si
## 1                                                     1
## 2                                                     1
## 3                                                     1
## 4                                                     1
## 8                                                     1
## 9                                                     1
##   X.Tiene.en.su.hogar.cocina.con.horno.Si X.Tiene.refrigeradora.Si
## 1                                       1                        1
## 2                                       0                        1
## 3                                       1                        1
## 4                                       1                        1
## 8                                       1                        1
## 9                                       1                        1
##   X.Tiene.lavadora.Si X.Tiene.equipo.de.sonido.Si
## 1                   1                           1
## 2                   1                           1
## 3                   0                           1
## 4                   0                           1
## 8                   1                           1
## 9                   1                           1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 1 TV a color
## 1                                                            0
## 2                                                            1
## 3                                                            1
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 2 TV a color
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            1
## 8                                                            0
## 9                                                            1
##   X.Cuántas.TV.a.color.tienen.en.este.hogar.Tiene 3 ó más TV a color
## 1                                                                  1
## 2                                                                  0
## 3                                                                  0
## 4                                                                  0
## 8                                                                  1
## 9                                                                  0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 2 vehículo exclusivo
## 1                                                                                1
## 2                                                                                0
## 3                                                                                0
## 4                                                                                1
## 8                                                                                1
## 9                                                                                0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene 3 ó más vehículo exclusivo
## 1                                                                                      0
## 2                                                                                      0
## 3                                                                                      0
## 4                                                                                      0
## 8                                                                                      0
## 9                                                                                      0
##   X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.Tiene un vehículo exclusivo
## 1                                                                                 0
## 2                                                                                 0
## 3                                                                                 0
## 4                                                                                 0
## 8                                                                                 0
## 9                                                                                 1
##   X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 1
## 9                                                                 1
##   X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.Si
## 1                                                                 1
## 2                                                                 1
## 3                                                                 1
## 4                                                                 1
## 8                                                                 0
## 9                                                                 1
##   X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.Si
## 1                                                                         1
## 2                                                                         1
## 3                                                                         1
## 4                                                                         1
## 8                                                                         0
## 9                                                                         1
##   X.En.el.hogar.alguien.está.registrado.en.una.red.social.Si
## 1                                                          1
## 2                                                          1
## 3                                                          1
## 4                                                          1
## 8                                                          1
## 9                                                          1
##   Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.Si
## 1                                                                                                                                                     1
## 2                                                                                                                                                     1
## 3                                                                                                                                                     0
## 4                                                                                                                                                     1
## 8                                                                                                                                                     1
## 9                                                                                                                                                     1
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Hasta 3 años de educación superior (incompleta)
## 1                                                                                                    0
## 2                                                                                                    0
## 3                                                                                                    1
## 4                                                                                                    0
## 8                                                                                                    0
## 9                                                                                                    0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Postgrado
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              1
## 8                                                              0
## 9                                                              0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria completa
## 1                                                                      0
## 2                                                                      0
## 3                                                                      0
## 4                                                                      0
## 8                                                                      0
## 9                                                                      0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Primaria incompleta
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        0
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria completa
## 1                                                                        0
## 2                                                                        0
## 3                                                                        0
## 4                                                                        0
## 8                                                                        1
## 9                                                                        0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Secundaria incompleta
## 1                                                                          0
## 2                                                                          1
## 3                                                                          0
## 4                                                                          0
## 8                                                                          0
## 9                                                                          0
##   X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.Sin estudios
## 1                                                                 0
## 2                                                                 0
## 3                                                                 0
## 4                                                                 0
## 8                                                                 0
## 9                                                                 0
##   X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.Si
## 1                                                                                                                                        1
## 2                                                                                                                                        1
## 3                                                                                                                                        1
## 4                                                                                                                                        1
## 8                                                                                                                                        0
## 9                                                                                                                                        1
##   X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.Si
## 1                                                                                                                                                                                                               0
## 2                                                                                                                                                                                                               1
## 3                                                                                                                                                                                                               0
## 4                                                                                                                                                                                                               0
## 8                                                                                                                                                                                                               1
## 9                                                                                                                                                                                                               1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Empleados de oficina
## 1                                                                       0
## 2                                                                       0
## 3                                                                       0
## 4                                                                       0
## 8                                                                       0
## 9                                                                       0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Fuerzas Armadas
## 1                                                                  1
## 2                                                                  1
## 3                                                                  0
## 4                                                                  0
## 8                                                                  0
## 9                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Inactivos
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            0
## 8                                                            0
## 9                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Oficiales operarios y artesanos
## 1                                                                                  0
## 2                                                                                  0
## 3                                                                                  0
## 4                                                                                  1
## 8                                                                                  0
## 9                                                                                  0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Operadores de instalaciones y máquinas
## 1                                                                                         0
## 2                                                                                         0
## 3                                                                                         0
## 4                                                                                         0
## 8                                                                                         0
## 9                                                                                         0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Personal directivo de la Administración Pública y de empresas
## 1                                                                                                                0
## 2                                                                                                                0
## 3                                                                                                                0
## 4                                                                                                                0
## 8                                                                                                                0
## 9                                                                                                                0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Profesionales científicos e intelectuales
## 1                                                                                            0
## 2                                                                                            0
## 3                                                                                            0
## 4                                                                                            0
## 8                                                                                            1
## 9                                                                                            0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Técnicos y profesionales de nivel medio
## 1                                                                                          0
## 2                                                                                          0
## 3                                                                                          0
## 4                                                                                          0
## 8                                                                                          0
## 9                                                                                          0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador calificados agropecuarios y pesqueros
## 1                                                                                                   0
## 2                                                                                                   0
## 3                                                                                                   0
## 4                                                                                                   0
## 8                                                                                                   0
## 9                                                                                                   0
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajador de los servicios y comerciantes
## 1                                                                                             0
## 2                                                                                             0
## 3                                                                                             1
## 4                                                                                             0
## 8                                                                                             0
## 9                                                                                             1
##   X.Cuál.es.la.ocupación.del.Representante.del.hogar.Trabajadores no calificados
## 1                                                                              0
## 2                                                                              0
## 3                                                                              0
## 4                                                                              0
## 8                                                                              0
## 9                                                                              0
##   NSE_2023_CUALIBajo NSE_2023_CUALIMedio Alto NSE_2023_CUALIMedio Bajo
## 1                  0                        0                        0
## 2                  0                        1                        0
## 3                  0                        1                        0
## 4                  0                        0                        0
## 8                  0                        0                        0
## 9                  0                        0                        0
##   NSE_2023_CUALIMedio Típico X.Para.qué.sector.trabaja.Sector privado
## 1                          0                                        0
## 2                          0                                        0
## 3                          0                                        0
## 4                          0                                        1
## 8                          1                                        0
## 9                          0                                        1
##   X.Para.qué.sector.trabaja.Sector público X.Consume.usted.arroz.Si
## 1                                        1                        1
## 2                                        1                        1
## 3                                        1                        1
## 4                                        0                        1
## 8                                        1                        0
## 9                                        0                        1
##   X.Consume.usted.queso.industrial..CON.MARCA.Si X.Consume.usted.huevos.Si
## 1                                              1                         1
## 2                                              1                         1
## 3                                              1                         1
## 4                                              1                         0
## 8                                              1                         0
## 9                                              1                         1
tr=round(nrow(datos_limpios)*0.7)
set.seed(04283882)
muestra=sample.int(nrow(datos_limpios), tr)
train=datos_limpios[muestra,]
val=datos_limpios[-muestra,]
train

NAIVE BAYES

library(naivebayes)
## Warning: package 'naivebayes' was built under R version 4.3.2
## naivebayes 0.9.7 loaded
library(e1071)
## Warning: package 'e1071' was built under R version 4.3.2
fitbayes <- naiveBayes(`X.Consume.usted.arroz.`~., data=train)
summary(fitbayes)
##           Length Class  Mode     
## apriori    2     table  numeric  
## tables    37     -none- list     
## levels     2     -none- character
## isnumeric 37     -none- logical  
## call       4     -none- call
#predict output
predictedBayes=predict(fitbayes,val)
library(caret)
## Warning: package 'caret' was built under R version 4.3.2
## Loading required package: lattice
matrizNB<- confusionMatrix(val$X.Consume.usted.arroz., predictedBayes)
matrizNB
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  No  Si
##         No   0   3
##         Si   6 106
##                                           
##                Accuracy : 0.9217          
##                  95% CI : (0.8566, 0.9636)
##     No Information Rate : 0.9478          
##     P-Value [Acc > NIR] : 0.9216          
##                                           
##                   Kappa : -0.036          
##                                           
##  Mcnemar's Test P-Value : 0.5050          
##                                           
##             Sensitivity : 0.00000         
##             Specificity : 0.97248         
##          Pos Pred Value : 0.00000         
##          Neg Pred Value : 0.94643         
##              Prevalence : 0.05217         
##          Detection Rate : 0.00000         
##    Detection Prevalence : 0.02609         
##       Balanced Accuracy : 0.48624         
##                                           
##        'Positive' Class : No              
## 
fitbayes <- naiveBayes(`X.Consume.usted.queso.industrial..CON.MARCA.`~., data=train)
summary(fitbayes)
##           Length Class  Mode     
## apriori    2     table  numeric  
## tables    37     -none- list     
## levels     2     -none- character
## isnumeric 37     -none- logical  
## call       4     -none- call
#predict output
predictedBayes=predict(fitbayes,val)
library(caret)
matrizNA<- confusionMatrix(val$X.Consume.usted.queso.industrial..CON.MARCA., predictedBayes)
matrizNA
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction No Si
##         No 39 23
##         Si 11 42
##                                           
##                Accuracy : 0.7043          
##                  95% CI : (0.6121, 0.7858)
##     No Information Rate : 0.5652          
##     P-Value [Acc > NIR] : 0.001513        
##                                           
##                   Kappa : 0.4147          
##                                           
##  Mcnemar's Test P-Value : 0.059230        
##                                           
##             Sensitivity : 0.7800          
##             Specificity : 0.6462          
##          Pos Pred Value : 0.6290          
##          Neg Pred Value : 0.7925          
##              Prevalence : 0.4348          
##          Detection Rate : 0.3391          
##    Detection Prevalence : 0.5391          
##       Balanced Accuracy : 0.7131          
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 92.17%, lo que indica que el 92.17% de las predicciones hechas por el modelo son correctas. Además, la matriz de confusión muestra que el modelo tiende a predecir bien la clase “Sí”, con una cantidad relativamente alta de verdaderos positivos (106 de 109 casos) pero tiene dificultades para predecir la clase “No”, ya que no ha acertado ninguna de las instancias de esta clase.

fitbayes <- naiveBayes(`X.Consume.usted.huevos.`~., data=train)
summary(fitbayes)
##           Length Class  Mode     
## apriori    2     table  numeric  
## tables    37     -none- list     
## levels     2     -none- character
## isnumeric 37     -none- logical  
## call       4     -none- call
#predict output
predictedBayes=predict(fitbayes,val)
library(caret)
matrizNC<- confusionMatrix(val$X.Consume.usted.huevos., predictedBayes)
matrizNC
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction No Si
##         No  4  6
##         Si  7 98
##                                           
##                Accuracy : 0.887           
##                  95% CI : (0.8145, 0.9384)
##     No Information Rate : 0.9043          
##     P-Value [Acc > NIR] : 0.7909          
##                                           
##                   Kappa : 0.3189          
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.36364         
##             Specificity : 0.94231         
##          Pos Pred Value : 0.40000         
##          Neg Pred Value : 0.93333         
##              Prevalence : 0.09565         
##          Detection Rate : 0.03478         
##    Detection Prevalence : 0.08696         
##       Balanced Accuracy : 0.65297         
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 88.7%, lo que indica que el 88.7% de las predicciones hechas por el modelo son correctas. Al igual que en el caso anterior, el modelo tiene dificultades para predecir la clase “No”, con un número significativo de falsos negativos (6 de 10 casos). Sin embargo, en la clase “Sí”, tiene un buen número de predicciones correctas (98 de 105 casos).

fitbayes <- naiveBayes(`X.Consume.frutas.`~., data=train)
summary(fitbayes)
##           Length Class  Mode     
## apriori    2     table  numeric  
## tables    37     -none- list     
## levels     2     -none- character
## isnumeric 37     -none- logical  
## call       4     -none- call
#predict output
predictedBayes=predict(fitbayes,val)
library(caret)
matrizND<- confusionMatrix(val$X.Consume.frutas., predictedBayes)
matrizND
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction No Si
##         No  2 12
##         Si  7 94
##                                           
##                Accuracy : 0.8348          
##                  95% CI : (0.7541, 0.8975)
##     No Information Rate : 0.9217          
##     P-Value [Acc > NIR] : 0.9994          
##                                           
##                   Kappa : 0.0869          
##                                           
##  Mcnemar's Test P-Value : 0.3588          
##                                           
##             Sensitivity : 0.22222         
##             Specificity : 0.88679         
##          Pos Pred Value : 0.14286         
##          Neg Pred Value : 0.93069         
##              Prevalence : 0.07826         
##          Detection Rate : 0.01739         
##    Detection Prevalence : 0.12174         
##       Balanced Accuracy : 0.55451         
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 83.48%, lo que indica que el 83.48% de las predicciones hechas por el modelo son correctas. En este caso, el modelo tiene dificultades para predecir ambas clases, con un número significativo de falsos negativos para la clase “No” (12 de 14 casos) y algunos falsos positivos para la clase “Sí” (7 de 101 casos).

RANDOM FOREST

library(randomForest)
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## The following object is masked from 'package:gridExtra':
## 
##     combine
## The following object is masked from 'package:ggplot2':
## 
##     margin
fitRF<- randomForest(`X.Consume.usted.arroz.`~., data=train, ntree=500)
summary(fitRF)
##                 Length Class  Mode     
## call               4   -none- call     
## type               1   -none- character
## predicted        268   factor numeric  
## err.rate        1500   -none- numeric  
## confusion          6   -none- numeric  
## votes            536   matrix numeric  
## oob.times        268   -none- numeric  
## classes            2   -none- character
## importance        37   -none- numeric  
## importanceSD       0   -none- NULL     
## localImportance    0   -none- NULL     
## proximity          0   -none- NULL     
## ntree              1   -none- numeric  
## mtry               1   -none- numeric  
## forest            14   -none- list     
## y                268   factor numeric  
## test               0   -none- NULL     
## inbag              0   -none- NULL     
## terms              3   terms  call
#predict output
predictedRF=predict(fitRF,val)
matrizRF1<-confusionMatrix(val$X.Consume.usted.arroz.,predictedRF)
matrizRF1
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  No  Si
##         No   0   3
##         Si   0 112
##                                           
##                Accuracy : 0.9739          
##                  95% CI : (0.9257, 0.9946)
##     No Information Rate : 1               
##     P-Value [Acc > NIR] : 1.0000          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 0.2482          
##                                           
##             Sensitivity :      NA         
##             Specificity : 0.97391         
##          Pos Pred Value :      NA         
##          Neg Pred Value :      NA         
##              Prevalence : 0.00000         
##          Detection Rate : 0.00000         
##    Detection Prevalence : 0.02609         
##       Balanced Accuracy :      NA         
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 97.39%, lo que indica que el 97.39% de las predicciones hechas por el modelo son correctas. Sin embargo, es importante notar que el modelo no ha realizado ninguna predicción para la clase “No”. Todas las predicciones hechas fueron para la clase “Sí” y todas fueron correctas. Esto puede indicar un desequilibrio en los datos o un problema con el modelo que solo está prediciendo una clase.

importance(fitRF)
##                                                                                                                                                                                                               MeanDecreaseGini
## UBICACIÓN                                                                                                                                                                                                           1.67186515
## X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.                                                                                                                                                                 0.27666943
## Edad.del.encuestado                                                                                                                                                                                                 1.35564614
## Sexo                                                                                                                                                                                                                0.12770924
## Estado.civil                                                                                                                                                                                                        0.34948941
## Cantidad.de.personas.que.conforman.el.hogar                                                                                                                                                                         0.50629362
## X.Qué.parentesco.tiene.con.el.representante.del.hogar.                                                                                                                                                              1.01791749
## X.Cuál.es.el.tipo.de.vivienda.                                                                                                                                                                                      0.32116633
## El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.                                                                                                                                            0.16070769
## EL.material.predominante.del.piso.de.la.vivienda.es.de.                                                                                                                                                             0.30068719
## X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                              0.46369320
## Tipo.de.servicio.higiénico.con.que.cuenta.este.hogar                                                                                                                                                                0.39736715
## X.Cuenta.con.servicio.de.internet.                                                                                                                                                                                  0.11792727
## X.Cuenta.con.computadora.de.escritorio.                                                                                                                                                                             0.12735886
## X.Cuenta.con.computadora.portátil.                                                                                                                                                                                  0.02752634
## X.Cuántos.celulares.activados.tiene.en.este.hogar.                                                                                                                                                                  0.40568905
## X.Tiene.su.hogar.servicio.de.teléfono.convencional.                                                                                                                                                                 0.15475296
## X.Tiene.en.su.hogar.cocina.con.horno.                                                                                                                                                                               0.17097462
## X.Tiene.refrigeradora.                                                                                                                                                                                              0.01150476
## X.Tiene.lavadora.                                                                                                                                                                                                   0.13080203
## X.Tiene.equipo.de.sonido.                                                                                                                                                                                           0.11403504
## X.Cuántas.TV.a.color.tienen.en.este.hogar.                                                                                                                                                                          0.22712972
## X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                                              0.57833730
## X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.                                                                                                                                                     0.09201488
## X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.                                                                                                                                                     0.13070058
## X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.                                                                                                                                             0.15393339
## X.En.el.hogar.alguien.está.registrado.en.una.red.social.                                                                                                                                                            0.06853694
## Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.                                                                 0.14134306
## X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.                                                                                                                                                               0.55082439
## X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.                                                                              0.13444787
## X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.       0.28637759
## X.Cuál.es.la.ocupación.del.Representante.del.hogar.                                                                                                                                                                 1.55548516
## NSE_2023_CUALI                                                                                                                                                                                                      0.41184721
## X.Para.qué.sector.trabaja.                                                                                                                                                                                          0.17742614
## X.Consume.usted.queso.industrial..CON.MARCA.                                                                                                                                                                        0.18982626
## X.Consume.usted.huevos.                                                                                                                                                                                             0.13548076
## X.Consume.frutas.                                                                                                                                                                                                   0.65162718
fitRF1<- randomForest(`X.Consume.usted.queso.industrial..CON.MARCA.`~., data=train, ntree=500)
summary(fitRF1)
##                 Length Class  Mode     
## call               4   -none- call     
## type               1   -none- character
## predicted        268   factor numeric  
## err.rate        1500   -none- numeric  
## confusion          6   -none- numeric  
## votes            536   matrix numeric  
## oob.times        268   -none- numeric  
## classes            2   -none- character
## importance        37   -none- numeric  
## importanceSD       0   -none- NULL     
## localImportance    0   -none- NULL     
## proximity          0   -none- NULL     
## ntree              1   -none- numeric  
## mtry               1   -none- numeric  
## forest            14   -none- list     
## y                268   factor numeric  
## test               0   -none- NULL     
## inbag              0   -none- NULL     
## terms              3   terms  call
#predict output
predictedRF=predict(fitRF1,val)
matrizRF2<-confusionMatrix(val$X.Consume.usted.arroz.,predictedRF)
matrizRF2
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction No Si
##         No  3  0
##         Si 50 62
##                                           
##                Accuracy : 0.5652          
##                  95% CI : (0.4696, 0.6574)
##     No Information Rate : 0.5391          
##     P-Value [Acc > NIR] : 0.3208          
##                                           
##                   Kappa : 0.0608          
##                                           
##  Mcnemar's Test P-Value : 4.219e-12       
##                                           
##             Sensitivity : 0.05660         
##             Specificity : 1.00000         
##          Pos Pred Value : 1.00000         
##          Neg Pred Value : 0.55357         
##              Prevalence : 0.46087         
##          Detection Rate : 0.02609         
##    Detection Prevalence : 0.02609         
##       Balanced Accuracy : 0.52830         
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 54.78%, lo que indica que el 54.78% de las predicciones hechas por el modelo son correctas. Sin embargo, el modelo tiene un rendimiento deficiente en la clasificación de la clase “Sí”, con un alto número de falsos positivos (52 de 112 casos). Además, aunque haya acertado todas las predicciones de la clase “No”, la cantidad de datos para esta clase es muy baja (3 casos), lo que puede sesgar la interpretación de la precisión del modelo.

importance(fitRF1)
##                                                                                                                                                                                                               MeanDecreaseGini
## UBICACIÓN                                                                                                                                                                                                           22.9077965
## X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.                                                                                                                                                                  6.3409049
## Edad.del.encuestado                                                                                                                                                                                                  6.6325072
## Sexo                                                                                                                                                                                                                 1.4736814
## Estado.civil                                                                                                                                                                                                         2.3660307
## Cantidad.de.personas.que.conforman.el.hogar                                                                                                                                                                          4.2209971
## X.Qué.parentesco.tiene.con.el.representante.del.hogar.                                                                                                                                                               3.7277248
## X.Cuál.es.el.tipo.de.vivienda.                                                                                                                                                                                       5.6026853
## El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.                                                                                                                                             1.6275180
## EL.material.predominante.del.piso.de.la.vivienda.es.de.                                                                                                                                                              5.0936443
## X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                               3.8637594
## Tipo.de.servicio.higiénico.con.que.cuenta.este.hogar                                                                                                                                                                 3.1377901
## X.Cuenta.con.servicio.de.internet.                                                                                                                                                                                   0.5248361
## X.Cuenta.con.computadora.de.escritorio.                                                                                                                                                                              1.5812123
## X.Cuenta.con.computadora.portátil.                                                                                                                                                                                   1.5926184
## X.Cuántos.celulares.activados.tiene.en.este.hogar.                                                                                                                                                                   4.2338955
## X.Tiene.su.hogar.servicio.de.teléfono.convencional.                                                                                                                                                                  1.9626290
## X.Tiene.en.su.hogar.cocina.con.horno.                                                                                                                                                                                1.8173553
## X.Tiene.refrigeradora.                                                                                                                                                                                               0.7160242
## X.Tiene.lavadora.                                                                                                                                                                                                    0.9358702
## X.Tiene.equipo.de.sonido.                                                                                                                                                                                            1.0464658
## X.Cuántas.TV.a.color.tienen.en.este.hogar.                                                                                                                                                                           4.0891957
## X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                                               3.2114990
## X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.                                                                                                                                                      1.1645774
## X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.                                                                                                                                                      0.7443331
## X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.                                                                                                                                              1.1979239
## X.En.el.hogar.alguien.está.registrado.en.una.red.social.                                                                                                                                                             0.8190063
## Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.                                                                  1.2590993
## X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.                                                                                                                                                                7.4726300
## X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.                                                                               2.1921620
## X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.        0.9534721
## X.Cuál.es.la.ocupación.del.Representante.del.hogar.                                                                                                                                                                 12.1713622
## NSE_2023_CUALI                                                                                                                                                                                                       5.7400985
## X.Para.qué.sector.trabaja.                                                                                                                                                                                           3.6373263
## X.Consume.usted.arroz.                                                                                                                                                                                               0.4169314
## X.Consume.usted.huevos.                                                                                                                                                                                              0.6661934
## X.Consume.frutas.                                                                                                                                                                                                    0.9026855
fitRF2<- randomForest(`X.Consume.usted.huevos.`~., data=train, ntree=500)
summary(fitRF2)
##                 Length Class  Mode     
## call               4   -none- call     
## type               1   -none- character
## predicted        268   factor numeric  
## err.rate        1500   -none- numeric  
## confusion          6   -none- numeric  
## votes            536   matrix numeric  
## oob.times        268   -none- numeric  
## classes            2   -none- character
## importance        37   -none- numeric  
## importanceSD       0   -none- NULL     
## localImportance    0   -none- NULL     
## proximity          0   -none- NULL     
## ntree              1   -none- numeric  
## mtry               1   -none- numeric  
## forest            14   -none- list     
## y                268   factor numeric  
## test               0   -none- NULL     
## inbag              0   -none- NULL     
## terms              3   terms  call
#predict output
predictedRF=predict(fitRF2,val)
matrizRF3<-confusionMatrix(val$X.Consume.usted.huevos.,predictedRF)
matrizRF3
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  No  Si
##         No   0  10
##         Si   2 103
##                                           
##                Accuracy : 0.8957          
##                  95% CI : (0.8248, 0.9449)
##     No Information Rate : 0.9826          
##     P-Value [Acc > NIR] : 1.00000         
##                                           
##                   Kappa : -0.0299         
##                                           
##  Mcnemar's Test P-Value : 0.04331         
##                                           
##             Sensitivity : 0.00000         
##             Specificity : 0.91150         
##          Pos Pred Value : 0.00000         
##          Neg Pred Value : 0.98095         
##              Prevalence : 0.01739         
##          Detection Rate : 0.00000         
##    Detection Prevalence : 0.08696         
##       Balanced Accuracy : 0.45575         
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 90.43%, lo que indica que el 90.43% de las predicciones hechas por el modelo son correctas. El modelo tiene un buen rendimiento en la clasificación de la clase “Sí”, con un alto número de verdaderos positivos (104 de 114 casos). Sin embargo, tiene dificultades en la clasificación de la clase “No”, ya que no ha realizado ninguna predicción correcta para esta clase y ha realizado una predicción incorrecta.

importance(fitRF2)
##                                                                                                                                                                                                               MeanDecreaseGini
## UBICACIÓN                                                                                                                                                                                                           10.0566482
## X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.                                                                                                                                                                  4.9060696
## Edad.del.encuestado                                                                                                                                                                                                  5.0281340
## Sexo                                                                                                                                                                                                                 0.9036073
## Estado.civil                                                                                                                                                                                                         1.3949303
## Cantidad.de.personas.que.conforman.el.hogar                                                                                                                                                                          3.1537394
## X.Qué.parentesco.tiene.con.el.representante.del.hogar.                                                                                                                                                               3.0116986
## X.Cuál.es.el.tipo.de.vivienda.                                                                                                                                                                                       2.1739033
## El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.                                                                                                                                             0.9009341
## EL.material.predominante.del.piso.de.la.vivienda.es.de.                                                                                                                                                              2.1656442
## X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                               1.0438301
## Tipo.de.servicio.higiénico.con.que.cuenta.este.hogar                                                                                                                                                                 1.1421691
## X.Cuenta.con.servicio.de.internet.                                                                                                                                                                                   0.7145825
## X.Cuenta.con.computadora.de.escritorio.                                                                                                                                                                              1.3662268
## X.Cuenta.con.computadora.portátil.                                                                                                                                                                                   0.8045800
## X.Cuántos.celulares.activados.tiene.en.este.hogar.                                                                                                                                                                   2.5665843
## X.Tiene.su.hogar.servicio.de.teléfono.convencional.                                                                                                                                                                  0.6688281
## X.Tiene.en.su.hogar.cocina.con.horno.                                                                                                                                                                                0.4367579
## X.Tiene.refrigeradora.                                                                                                                                                                                               0.5709397
## X.Tiene.lavadora.                                                                                                                                                                                                    0.4925937
## X.Tiene.equipo.de.sonido.                                                                                                                                                                                            0.8184748
## X.Cuántas.TV.a.color.tienen.en.este.hogar.                                                                                                                                                                           1.4734530
## X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                                               1.5081946
## X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.                                                                                                                                                      0.9176186
## X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.                                                                                                                                                      0.6912370
## X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.                                                                                                                                              0.7729079
## X.En.el.hogar.alguien.está.registrado.en.una.red.social.                                                                                                                                                             0.3279038
## Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.                                                                  0.9207193
## X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.                                                                                                                                                                3.3113346
## X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.                                                                               1.1103703
## X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.        0.7701963
## X.Cuál.es.la.ocupación.del.Representante.del.hogar.                                                                                                                                                                  6.3592752
## NSE_2023_CUALI                                                                                                                                                                                                       1.7774471
## X.Para.qué.sector.trabaja.                                                                                                                                                                                           1.1174919
## X.Consume.usted.arroz.                                                                                                                                                                                               0.2404090
## X.Consume.usted.queso.industrial..CON.MARCA.                                                                                                                                                                         0.4740676
## X.Consume.frutas.                                                                                                                                                                                                    1.4302029
fitRF3<- randomForest(`X.Consume.frutas.`~., data=train, ntree=500)
summary(fitRF3)
##                 Length Class  Mode     
## call               4   -none- call     
## type               1   -none- character
## predicted        268   factor numeric  
## err.rate        1500   -none- numeric  
## confusion          6   -none- numeric  
## votes            536   matrix numeric  
## oob.times        268   -none- numeric  
## classes            2   -none- character
## importance        37   -none- numeric  
## importanceSD       0   -none- NULL     
## localImportance    0   -none- NULL     
## proximity          0   -none- NULL     
## ntree              1   -none- numeric  
## mtry               1   -none- numeric  
## forest            14   -none- list     
## y                268   factor numeric  
## test               0   -none- NULL     
## inbag              0   -none- NULL     
## terms              3   terms  call
#predict output
predictedRF=predict(fitRF3,val)
matrizRF4<-confusionMatrix(val$X.Consume.frutas.,predictedRF)
matrizRF4
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  No  Si
##         No   1  13
##         Si   0 101
##                                           
##                Accuracy : 0.887           
##                  95% CI : (0.8145, 0.9384)
##     No Information Rate : 0.9913          
##     P-Value [Acc > NIR] : 1.0000000       
##                                           
##                   Kappa : 0.119           
##                                           
##  Mcnemar's Test P-Value : 0.0008741       
##                                           
##             Sensitivity : 1.000000        
##             Specificity : 0.885965        
##          Pos Pred Value : 0.071429        
##          Neg Pred Value : 1.000000        
##              Prevalence : 0.008696        
##          Detection Rate : 0.008696        
##    Detection Prevalence : 0.121739        
##       Balanced Accuracy : 0.942982        
##                                           
##        'Positive' Class : No              
## 

INTERPRETACION: La precisión del modelo es del 87.83%, lo que indica que el 87.83% de las predicciones hechas por el modelo son correctas. El modelo tiene un buen rendimiento en la clasificación de la clase “Sí”, con un alto número de verdaderos positivos (100 de 113 casos). Sin embargo, tiene dificultades en la clasificación de la clase “No”, con un número significativo de falsos negativos (13 de 14 casos) y una predicción incorrecta para la clase “Sí”.

importance(fitRF3)
##                                                                                                                                                                                                               MeanDecreaseGini
## UBICACIÓN                                                                                                                                                                                                            9.0813293
## X.En.qué.cantón.de.la.provincia.de.Chimborazo.vive.                                                                                                                                                                  2.0719898
## Edad.del.encuestado                                                                                                                                                                                                  3.2877523
## Sexo                                                                                                                                                                                                                 0.4711302
## Estado.civil                                                                                                                                                                                                         0.8066543
## Cantidad.de.personas.que.conforman.el.hogar                                                                                                                                                                          2.1553071
## X.Qué.parentesco.tiene.con.el.representante.del.hogar.                                                                                                                                                               0.8645224
## X.Cuál.es.el.tipo.de.vivienda.                                                                                                                                                                                       0.9798709
## El.material.predominante.de.las.paredes.exteriores.de.la.vivienda.es.de.                                                                                                                                             0.4454696
## EL.material.predominante.del.piso.de.la.vivienda.es.de.                                                                                                                                                              1.8328476
## X.Cuántos.cuartos.de.baño.con.ducha.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                               0.7743243
## Tipo.de.servicio.higiénico.con.que.cuenta.este.hogar                                                                                                                                                                 1.6333903
## X.Cuenta.con.servicio.de.internet.                                                                                                                                                                                   0.1729963
## X.Cuenta.con.computadora.de.escritorio.                                                                                                                                                                              0.3873487
## X.Cuenta.con.computadora.portátil.                                                                                                                                                                                   0.3836660
## X.Cuántos.celulares.activados.tiene.en.este.hogar.                                                                                                                                                                   1.6735713
## X.Tiene.su.hogar.servicio.de.teléfono.convencional.                                                                                                                                                                  0.4576873
## X.Tiene.en.su.hogar.cocina.con.horno.                                                                                                                                                                                0.3188581
## X.Tiene.refrigeradora.                                                                                                                                                                                               0.1691976
## X.Tiene.lavadora.                                                                                                                                                                                                    0.7806760
## X.Tiene.equipo.de.sonido.                                                                                                                                                                                            0.3517442
## X.Cuántas.TV.a.color.tienen.en.este.hogar.                                                                                                                                                                           1.1174126
## X.Cuántos.vehículos.de.uso.exclusivo.tiene.este.hogar.                                                                                                                                                               0.7832527
## X.Alguien.en.el.hogar.compra.vestimenta.en.centros.comerciales.                                                                                                                                                      0.4187235
## X.En.el.hogar.alguien.ha.usado.internet.en.los.últimos.6.meses.                                                                                                                                                      0.1975232
## X.En.el.hogar.alguien.utiliza.correo.electrónico.que.no.es.del.trabajo.                                                                                                                                              0.8122785
## X.En.el.hogar.alguien.está.registrado.en.una.red.social.                                                                                                                                                             0.1452951
## Exceptuando.los.libros.de.texto.o.manuales.de.estudio.y.lecturas.de.trabajo.Alguien.del.hogar.ha.leído.algún.libro.completo.en.los.últimos.3.meses.                                                                  0.5382938
## X.Cuál.es.el.nivel.de.instrucción.del.Jefe.del.hogar.                                                                                                                                                                1.8572535
## X.Alguien.en.el.hogar.está.afiliado.o.cubierto.por.el.seguro.del.IESS..general..voluntario.o.campesino..y.o.seguro.del.ISSFA.o.ISSPOL.                                                                               0.3987911
## X.Alguien.en.el.hogar.tiene.seguro.de.salud.privada.con.hospitalización..seguro.de.salud.privada.sin.hospitalización..seguro.internacional.seguros.municipales.y.de.Consejos.Provinciales.y.o.seguro.de.vida.        0.4302474
## X.Cuál.es.la.ocupación.del.Representante.del.hogar.                                                                                                                                                                  3.5847970
## NSE_2023_CUALI                                                                                                                                                                                                       1.1459675
## X.Para.qué.sector.trabaja.                                                                                                                                                                                           0.8371455
## X.Consume.usted.arroz.                                                                                                                                                                                               0.9236936
## X.Consume.usted.queso.industrial..CON.MARCA.                                                                                                                                                                         0.6633162
## X.Consume.usted.huevos.                                                                                                                                                                                              0.9085651