I have dataframe in R that contains the the true value of a parameter, and its corresponding lower and upper values for confidence interval. The codes are as follows:

n = 100*c(1:10)

lambda = 0.1

Ilambda = #formula excluded

varI = Ilambda^(-1/2)/sqrt(n)

upper = lambda+1.96*varI

lower = lambda-1.96*varI

index = rep(lambda,length(n))

data = data.frame(n,lower,upper,index)

data = as_tibble(data)

ggplot(data)+

geom_line(aes(n, index),cex = 1)+

geom_ribbon(aes(ymin = lower, ymax = upper), fill = "grey")

Attached figure is how I pictured it with some shading towards the line y = 0.1, like an usual shading for confidence interval. I learned that geom_ribbon can do the shading for confidence interval but there is an error message which is

Error: geom_ribbon requires the following missing aesthetics: x or y, xmin and xmax

I am open to other suggestions.

More Razik Ridzuan Mohd Tajuddin's questions See All
Similar questions and discussions