fsolt / dotwhisker

Dot-and-Whisker Plots of Regression Results
https://fsolt.org/dotwhisker/
Other
57 stars 10 forks source link

conf level incorrect when using tidy data frame #93

Closed zhiyzuo closed 3 years ago

zhiyzuo commented 4 years ago

Following the example on https://cran.r-project.org/web/packages/dotwhisker/vignettes/dotwhisker-vignette.html. The output image does not change if we alter the conf.level in the following example:

by_trans <- mtcars %>% 
    group_by(am) %>%                                         # group data by trans
    do(tidy(lm(mpg ~ wt + cyl + disp + gear, data = .))) %>% # run model on each grp
    rename(model=am) %>%                                     # make model variable
    relabel_predictors(c(wt = "Weight",                      # relabel predictors
                     cyl = "Cylinders",          
                     disp = "Displacement",
                     gear = "Gear"))

If we use conf.level=0.999:

dwplot(by_trans, conf.level=0.999,
       vline = geom_vline(xintercept = 0, colour = "grey60", linetype = 2)) + # plot line at zero _behind_ coefs
    theme_bw() + xlab("Coefficient Estimate") + ylab("") +
    ggtitle("Predicting Gas Mileage by Transmission Type") +
    theme(plot.title = element_text(face="bold"),
          legend.position = c(0.007, 0.01),
          legend.justification = c(0, 0),
          legend.background = element_rect(colour="grey80"),
          legend.title.align = .5) +
    scale_colour_grey(start = .3, end = .7,
                      name = "Transmission",
                      breaks = c(0, 1),
                      labels = c("Automatic", "Manual"))

We will have: image

Changing conf.level to 0.7 gives me the same output: image

sammo3182 commented 3 years ago

Fixed by eaac2062668bcbf14bc2fab6cfc6fea445f94ffe; adding the ci option.