Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I silence confint in R

Tags:

r

I'm looping through many analyses in an R notebook, and capturing confidence intervals each iteration. Each time, confint emits "Waiting for profiling to be done..." as output that shows up in the notebook. Can I suppress this?

The following code emits the message I'd like to avoid in the console and RStudio. If it matters, I only care about the output to the notebook in RStudio.

y = c(1,2,3,4,5,6,7,8,9,0)
x = c(2,4,6,8,2,4,6,8,2,4)
fit = glm(y ~ x)
ci.05 = confint(fit, level=0.95)["x","2.5 %"]
print(paste("The lower bound of the 95% CI is",ci.05))
like image 270
mightypile Avatar asked Sep 12 '25 23:09

mightypile


1 Answers

@mko's solution is a nice general way to attack problems like these but in this particular case you can get rid of the message by passing a profile object to confint directly. If you use the following line instead of your original code none of the output will be any different but you won't get the message that is annoying you.

ci.05 = confint(profile(fit), level=0.95)["x","2.5 %"]
like image 170
Dason Avatar answered Sep 14 '25 15:09

Dason