data<-read.csv('C:/Users/rusoc/OneDrive/Escritorio/TEC/Mineria de datos/segmentation data.csv')
#Modelo logit
modelo_logit = glm(Marital.status~Age,data=data,family=binomial(link="logit"))
summary(modelo_logit)
##
## Call:
## glm(formula = Marital.status ~ Age, family = binomial(link = "logit"),
## data = data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.360554 0.153562 8.860 <2e-16 ***
## Age -0.038493 0.004145 -9.286 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 2772.5 on 1999 degrees of freedom
## Residual deviance: 2679.0 on 1998 degrees of freedom
## AIC: 2683
##
## Number of Fisher Scoring iterations: 4
#Modelo probit
modelo_probit = glm(Marital.status~Age,data=data,family=binomial(link="probit"))
summary(modelo_probit)
##
## Call:
## glm(formula = Marital.status ~ Age, family = binomial(link = "probit"),
## data = data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.830517 0.093675 8.866 <2e-16 ***
## Age -0.023391 0.002509 -9.324 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 2772.5 on 1999 degrees of freedom
## Residual deviance: 2680.2 on 1998 degrees of freedom
## AIC: 2684.2
##
## Number of Fisher Scoring iterations: 4
#Estimamos los criterios de información para cada modelo
CIA_Logit = AIC(modelo_logit)
CIA_Probit = AIC(modelo_probit)
CIA_Logit
## [1] 2683.008
CIA_Probit
## [1] 2684.179
Modelo con mejor ajuste con base al CIA es el logit al tener un valor menor.
#Predicciones
predict(modelo_logit, data.frame(Age = mean(data$Age)), type="response")
## 1
## 0.4945746