1

If i use the data from 'discoveries', how can i find for example 80%, 90% and 95% credible interval and plot them in a confidence curve?

By using summary(discoveries) i have that mean a = 3.1, sample size n = 310 and standard deviation s =2.5

can I do the following to find 90%? If so, how can i plot the data i get from several %'s? (80%, 90% 95% etc)

a <- 3.1
s <- 2.5
n <- 310
error <- qnorm(0.95)*s/sqrt(n)
left <- a-error
right <- a+error
left
right
MrFlick
  • 195,160
  • 17
  • 277
  • 295
Mokoisa
  • 75
  • 1
  • 4

1 Answers1

0

You can create a function like this one:

mu_interval<-function(data, prob){ 
     lower<-mean(data)+qnorm((1-prob)/2,length(data)-1)*sqrt(var(data)/length(data)) 
    upper<-mean(data)+qnorm((1+prob)/2,length(data)-1)*sqrt(var(data)/length(data)) 
    interval<-c(lower,upper)
     interval
     }