 # How to include significance level stars in a ggplot showing means and confidence intervals of estimates.

Hi!
So I made this glmm-model and I want to visualise the summary in a better way than a table. This is the figure I made showing the estimate of the slope for each of my parameters, with confidence intervals:

Now I want to add to this figure the significance level stars as shown in the summary of my model.

Can anyone please tell me how this is done?

Here is my code:

``````glmm_data <- read.table(file = "/Users/edithbremer/Documents/Master.thesis/Thesis.Data.Analysis/glmm_data.txt", header = TRUE, dec = ".")

glmm_data\$Type <- factor(glmm_data\$Type, levels = c("fallen", "standing"))
library(dplyr)
glmm_data <- filter(glmm_data, Species == "pine")

#Standardizing data
glmm_data <- transform(glmm_data,
Cover = scale(Cover, scale=2*sd(Cover)),
Diam = scale(Diam, scale=2*sd(Diam)),
Decay = scale(Decay, scale=2*sd(Decay)))

library(lme4)
C.glmm<-glmer(Cladonia.presence ~ Cover + Burnt.presence + Diam +
Decay + Type + Cut.presence +(1|Stand),
family = binomial, data = glmm_data)
summary(C.glmm)

# a set of all possible models that can be formed with these variables
library(MuMIn)
options(na.action = "na.fail")
all.C.glmm<-dredge(C.glmm)

# from this set, choose the models with the lowest AIC
# here the limit for deltaAIC is 4; i.e. includes the models that differ from the best one max 4 AIC units
final.C.glmm<-subset(all.C.glmm, delta<4)

# this is the final set of models that will be averaged
final.C.glmm

# model averaging
avg.C.glmm<-model.avg(final.C.glmm, revised.var=TRUE, fit=TRUE)

# here are the model averaged coefficients for each variable
# can also calculate confidence intervals
summary(avg.C.glmm)
avgCI.C.glmm<-confint(avg.C.glmm, level=0.95, full=F)

# plot the results so it's easier to see
# variables can be considered significant if the model averaged coefficient differs from 0
avg.coefs.C.glmm<-as.data.frame(t(avg.C.glmm\$coefficients))
avg.coefs.C.glmm<-cbind(avg.coefs.C.glmm, avgCI.C.glmm)
colnames(avg.coefs.C.glmm)<-c("full", "subset", "CImin", "CImax")
avg.coefs.C.glmm\$variable<-rownames(avg.coefs.C.glmm)

library(ggplot2)
ggplot(avg.coefs.C.glmm, aes(x=variable, y=subset)) +
geom_point(position=position_dodge(width=0.75))+
geom_errorbar(aes(ymin=CImin, ymax=CImax), width=.1, position=position_dodge(width=0.75)) +
geom_abline(intercept = 0, slope = 0, lty=2)+
coord_flip()+
labs(y="Estimate.C.glmm", x=NULL)

``````