Encuesta Asi Vamos 2022
Diccionario:
Pregunta CP3_1 : Cuantos aƱos cumplidos tienes?
Pregunta P96_2 : Las mujeres tienen un mayor riesgo de ser agredidas que los hombres
Pregunta P96_3 : Las mujeres comparten la responsabilidad de ser agredidas por su forma de vestir.
library(foreign)
library(ggplot2)
library(MASS)
library(openxlsx)
evidencia2 <-read.xlsx("evidencia2.xlsx")
head(evidencia2)
## edad riesgo respmujeres
## 1 30 1 0
## 2 65 1 1
## 3 68 1 0
## 4 56 1 1
## 5 62 1 1
## 6 49 1 1
evidencia2$riesgo<-factor(evidencia2$riesgo, levels = c(0,1), labels = c("No","Si"))
dis=lda(riesgo~edad, data=evidencia2)
dis
## Call:
## lda(riesgo ~ edad, data = evidencia2)
##
## Prior probabilities of groups:
## No Si
## 0.2691851 0.7308149
##
## Group means:
## edad
## No 62.98147
## Si 61.98927
##
## Coefficients of linear discriminants:
## LD1
## edad 0.002462945
evidencia2$respmujeres<-factor(evidencia2$respmujeres, levels = c(0,1), labels = c("No","Si"))
dis2=lda(respmujeres~edad, data=evidencia2)
dis2
## Call:
## lda(respmujeres ~ edad, data = evidencia2)
##
## Prior probabilities of groups:
## No Si
## 0.5428843 0.4571157
##
## Group means:
## edad
## No 57.69716
## Si 67.67100
##
## Coefficients of linear discriminants:
## LD1
## edad 0.002463128
nuevo.dato=rbind(c(63))
colnames(nuevo.dato)=colnames(evidencia2[1])
nuevo.dato=data.frame(nuevo.dato)
predict(dis,newdata = nuevo.dato)
## $class
## [1] Si
## Levels: No Si
##
## $posterior
## No Si
## 1 0.2691857 0.7308143
##
## $x
## LD1
## 1 0.001831555
nuevo.dato2=rbind(c(63))
colnames(nuevo.dato2)=colnames(evidencia2[1])
nuevo.dato2=data.frame(nuevo.dato2)
predict(dis2,newdata = nuevo.dato2)
## $class
## [1] No
## Levels: No Si
##
## $posterior
## No Si
## 1 0.5428796 0.4571204
##
## $x
## LD1
## 1 0.001831692