# Confidence interval plot for reports

Hi all,

Can anyone help me with producing a confidence interval plot using R, I have some code but it has confused me as I have different a number of variables and no factors. I want to show the probability of predicting something and am unsure how to do this with a dataset of 11 variables but only 7 were significant when I ran my GLMM.

Also, I have a variable with several huge outliers which important for my model, I have tried to log10 transform the variable data to see if it is a better fit, can anyone suggest anything else I could try please?

Thank you so much in advance!!

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.

2 Likes

Try to put the data in this order for replicate this code. You need calculate `up` and `low` in the data.

Maybe you need make a pivot for get better order in the data.

``````# Import ggplot2 library
library("ggplot2")

# Creating Data
data<-round(data.frame(x = 1:30,
y = runif(30, 30, 40),
low = runif(30, 0, 30),
up = runif(30, 40, 50)), 4)

# confindence intervals
ggplot(data, aes(x, y)) + geom_point() +
geom_errorbar(aes(ymin = low, ymax = up))+
labs(title = 'Confidence Intervals')
``````

1 Like

If your model is similar to

``````chdfit <- glm(CHD ~ AGE, data = chdage, family = binomial(link ="logit"))
``````

then confidence intervals can be shown

```````library(MASS)
waldscore <- confint.default(chdfit)`
# or
vmscore <- confint(chdfit)
``````

or

``````library(profileModel)
raoscore <- profConfint(profileModel(chdfit, quantile=qchisq(0.95, 1), objective = "RaoScoreStatistic", X = model.matrix(chdfit)))

``````
1 Like

Thank you all for your help, I am so bad at this, it gives me a headache!!

Whenever that happens to me, I try to step back from the how questions to focus on the what questions. With a glm, it’s identifying the f(x) = y components. Here, x is the model, and y is what you want to know about the model. What actually is the value that the confidence interval brackets? What does the value represent in the model, in the data, in the world?

1 Like

Thank you so much for your help, really appreciate it and wish my brain got R 1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.