Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jamiahuswalton opened this issue Oct 29, 2021 · 4 comments

Comments

@jamiahuswalton
Copy link

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

@ikosmidis
Copy link
Owner

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.

@jamiahuswalton
Copy link
Author

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
Copy link
Author

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

@ikosmidis
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants