brglm2
brglm2 copied to clipboard
Step{stat} function does not pick the the model with the lowest AIC
Hello,
I fit a model with the glm function (setting method="brglmFit"). When I implemented the step function from the stats package, the trace showed that the model with the lowest AIC value is not chosen. I do not want to share the data but I can share the trace. Please let me know if there is more information you need.

Hi. I appreciate you cannot share the data but a reproducible example would really help. Perhaps you can use one of the datasets already in brglm2, or simulate from your model fit (use the simulate() method) to get simulated response values which you can add in a data frame along with the covariates of your model.
Here is an example you can use and reproduce the result. Let me know if that does not work.
Below is the code you can run to get the same issue.
library(brglm) library(brglm2) library(tidyverse)
my_data<- read_csv("brglm_Step_issue.csv", col_types = cols( .default = col_factor() ))
formula_my<- formula(Q14_1_Binary ~ Q5_Binary + Q6_Binary + Q7_Binary + Q8_Binary + Q9_Binary + Q12_6_Binary + Q12_10_Binary + Q19_Binary + Q22_Binary)
my_model_brglm<- glm(formula_my, data = na.omit(my_data), family = binomial(link = "logit"), method = "brglmFit") # Omitting NA values
step_example<- step(my_model_brglm) summary(step_example)
I just wanted to follow up to see if there was anything else you needed from me.
Thanks, @jamiahuswalton: no I think I have enough to investigate this. I plan to do it early in the new year when the new brglm2 release is prepared