rlinear-regressionforest-plots

Forest plot univariable in R (finalfit | or_plot)


I want to create a forest plot of the OR using univariable regression. Preferably with an outcome like the or_plot() from the finalfit package. However, this does not support univariable analysis. Can someone help me with an alternative? Or a method to combine the univariable outcome of finalfit(dependent, explanatory)?

Finalfit example using finalfit

Multivariable

The last figure creates a forest plot, but for multivariable only. I would like such a plot for univariable.

Hopefully someone can help me with this question.

I tried creating a ggplot from the finalfit results table, but this is not in the desired format and styling as I would prefer.


Solution

  • Yes, you can do this.

    library(finalfit)
    library(gridExtra)
    
    explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
    dependent = "mort_5yr"
    
    fit_uni = colon_s %>% 
      glmuni(dependent, explanatory)
    
    p_uni = colon_s %>%
      or_plot(dependent, explanatory, suffix = " (univariable)", remove_ref = TRUE, 
        glmfit = fit_uni)
    p_multi = colon_s %>%
      or_plot(dependent, explanatory, suffix = " (multivariable)", remove_ref = TRUE)
    
    grid.arrange(p_uni, p_multi)
    

    OR plots