library(rio)
## Warning: package 'rio' was built under R version 4.2.2
data=import("dataAdmit.csv")
str(data)
## 'data.frame':    400 obs. of  4 variables:
##  $ admitido : chr  "no" "si" "si" "si" ...
##  $ gre      : int  380 660 800 640 520 760 560 400 540 700 ...
##  $ gpa      : num  3.61 3.67 4 3.19 2.93 3 2.98 3.08 3.39 3.92 ...
##  $ prestigio: chr  "Bajo" "Bajo" "MuyAlto" "MuyBajo" ...

Cambiamos a factor y numèrica

data$gre=as.numeric(data$gre)

data$admitido=as.factor(data$admitido)
h1=formula(admitido~gre)
rlog1=glm(h1, data=data,family = binomial)
modelrl=list('Ser Voluntario (I)'=rlog1)
library(modelsummary)
modelsummary(modelrl,
             #fmt=f,
             #exponentiate = T, 
             #statistic = 'conf.int',
             title = "Regresión Logística",
             stars = TRUE,
             output = "kableExtra")
Regresión Logística
Ser Voluntario (I)
(Intercept) −2.901***
(0.606)
gre 0.004***
(0.001)
Num.Obs. 400
AIC 490.1
BIC 498.0
Log.Lik. −243.028
F 13.199
RMSE 0.46
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
h2=formula(admitido~gre + gpa)
rlog2=glm(h2, data=data,family = binomial)
h3=formula( admitido~gre + gpa +prestigio)
rlog3=glm(h3, data=data,family = binomial)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

library(lmtest)

lrtest(rlog1,rlog2, rlog3) %>% kable(caption = “Tabla LRT para comparar modelos”)%>%kableExtra::kable_styling(full_width = FALSE) ```