简体   繁体   English

如何找到和plot不同的可信区间?

[英]How to find and plot different credible intervals?

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?如果我使用“发现”中的数据,我如何在置信曲线中找到例如 80%、90% 和 95% 的可信区间和 plot 它们?

By using summary(discoveries) i have that mean a = 3.1, sample size n = 310 and standard deviation s =2.5通过使用summary(discoveries) ,我的意思是 a = 3.1,样本量 n = 310 和标准偏差 s =2.5

can I do the following to find 90%?我可以执行以下操作来找到 90% 吗? If so, how can i plot the data i get from several %'s?如果是这样,我怎么能 plot 我从几个%的数据得到? (80%, 90% 95% etc) (80%、90%、95% 等)

a <- 3.1
s <- 2.5
n <- 310
error <- qnorm(0.95)*s/sqrt(n)
left <- a-error
right <- a+error
left
right

You can create a function like this one:您可以像这样创建一个 function:

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
     }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM