Showing 3 best models of StepAIC in a Table


How can I display the 3 best models of StepAIC so I can write them on a table?

My models are as follows:

stepboth1=stepAIC(crash.glm,k=2, direction = "both", keep=NULL, scope = list(upper=~.^2,lower=~1))
stepboth2=stepAIC(crash.glm, k=log(nrow(mydata)), direction = "both", keep=NULL,scope = list(upper=~.^2,lower=~1))
stepboth3=stepAIC(crash.glm, k=log(log(nrow(mydata))), direction = "both", keep=NULL, scope = list(upper=~.^2,lower=~1))

Many thanks in advance!!

Would you mind updating your question? Currently, it's not formatting into code chunks, and it's not a reproducible example. Specifically, it refers to data crash.glm that we can't see.

Formatting your code is straightforward on this site, in the composer window, click the little </> button. More info at FAQ: How to format your code

For how to get your code and data into a reproducible example, it's bit of extra work on your part, but makes it easier for people who want to help to diagnose your problem, and suggest a solution. More info at FAQ: What's a reproducible example (`reprex`) and how do I do one?

Also, "display the 3 best models ... on a table?" can be interpreted a few ways (eg should it be a data.frame table, or a table ready to print, is html ok?). So Perhaps offer an example of what you're looking for.

As a suggestion for a package that helps you compare multiple models in a single table for publication. I've been excited about seeing how the gt package can help. gtsummary is an R package that uses gt to help create display tables summarizing one or more models.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.