Highlight Significant Coefficients in Coefplot

Highlight Significant Coefficients in Coefplot

Is there a way of changing the colour, to red say, of only significant coefficients on the coefplot plot?

For example (plot 2 in coefplot's helpfile),

require(coefplot)
y1 <- rnorm(1000,50,23)
y2 <- rbinom(1000,1,prob=0.72)
x1 <- rnorm(1000,50,2) 
x2 <- rbinom(1000,1,prob=0.63) 
x3 <- rpois(1000, 2) 
x4 <- runif(1000,40,100) 
x5 <- rbeta(1000,2,2) 

longnames <- c("a long name01","a long name02","a long name03",
               "a long name04","a long name05")

fit1 <- lm(y1 ~ x1 + x2 + x3 + x4 + x5)

# plot 2
longnames <- c("(Intercept)", longnames) 
coefplot(fit1, longnames, intercept=TRUE)
1

1 Answer

You don't necessarily need to do that even though it would be nice...If the coefficient plot's 95% confidence interval stretches past zero on either side, then it is not significant at the 5% level. Vice versa, if it does not, then it is statistically significant from 0 at the 5% level. Hope that makes sense!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.