brglm2 icon indicating copy to clipboard operation
brglm2 copied to clipboard

Step{stat} function does not pick the the model with the lowest AIC

Open jamiahuswalton opened this issue 4 years ago • 4 comments

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.

Bug_AIC

jamiahuswalton avatar Oct 29 '21 18:10 jamiahuswalton

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.

ikosmidis avatar Nov 03 '21 10:11 ikosmidis

Here is an example you can use and reproduce the result. Let me know if that does not work.

brglm_Step_issue.csv .

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)

jamiahuswalton avatar Nov 03 '21 13:11 jamiahuswalton

I just wanted to follow up to see if there was anything else you needed from me.

jamiahuswalton avatar Dec 16 '21 19:12 jamiahuswalton

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

ikosmidis avatar Dec 21 '21 11:12 ikosmidis