I'm trying to display a plot with several coefficients, some are significant and some are not. Plus, when I try the other configuration of m1, an error is returned.
library("nycflights13")
library(dplyr)
library(dotwhisker)
library(MASS)
flights <- nycflights13::flights
flights<- sample_n (flights, 500)
m1<- glm(formula = arr_delay ~ dep_time + origin+ air_time+ distance , data = flights)
#m1<- glm(formula = arr_delay ~ . , data = flights)
m1<- stepAIC(m1)
summary(m1)
dwplot(m1)
dwplot(m1 + geom_vline(xintercept=0, lty=2)) ## This is meant to add a line on the CI
How can I dedicate different colors to coefficients with or without statistical significance?
EDIT 1 : This code works really great but when I change the paramter to 0.05 i get all results in orange as displayed. Any thoughts?
df <- mtcars
nested_inter <- mtcars %>% group_by(gear) %>%
nest() ## groups all the data by the sub series
nested_inter <- nested_inter %>%
mutate (model = map(data,
~lm(formula = mpg ~ cyl + drat + hp +wt , data = .)))
p<- dotwhisker::dwplot(nested_inter$model[[2]])
#print(p)
z<- p +
geom_vline(xintercept=0, linetype="dashed")+
geom_segment(aes(x=conf.low,y=term,xend=conf.high,
yend=term,col=p.value<0.05)) +
geom_point(aes(x=estimate,y=term,col=p.value<0.05)) +
xlab("standardized coefficient") +
ylab("coefficient") +
ggtitle("coefficients in the model and significance")
print(z)