library(MASS)
data(menarche)
model <- glm(cbind(Menarche, Total - Menarche) ~ Age,
             data = menarche, family = binomial())
summary(model)
## 
## Call:
## glm(formula = cbind(Menarche, Total - Menarche) ~ Age, family = binomial(), 
##     data = menarche)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -21.22639    0.77068  -27.54   <2e-16 ***
## Age           1.63197    0.05895   27.68   <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: 3693.884  on 24  degrees of freedom
## Residual deviance:   26.703  on 23  degrees of freedom
## AIC: 114.76
## 
## Number of Fisher Scoring iterations: 4
new_data <- data.frame(Age = c(11, 12, 13))
predicted_probabilities <- predict(model, newdata = new_data, type = "response")
cat("Predicted Probabilities:", predicted_probabilities, "\n")
## Predicted Probabilities: 0.03644789 0.1620879 0.4972984