Skip to main content
Commonmark migration
Source Link

###Credible intervals and confidence intervals are constructed in different ways and can be different

Credible intervals and confidence intervals are constructed in different ways and can be different

###Conclusion

Conclusion

###About the exception

About the exception

###Additional:

Additional:

###Credible intervals and confidence intervals are constructed in different ways and can be different

###Conclusion

###About the exception

###Additional:

Credible intervals and confidence intervals are constructed in different ways and can be different

Conclusion

About the exception

Additional:

added 81 characters in body
Source Link
Sextus Empiricus
  • 86.6k
  • 6
  • 115
  • 304

The confidence interval is restricted in the way that it draws the boundaries. The confidence interval places these boundaries by considering the conditional distribution $X_\theta$ and will cover $\alpha \%$ independent from what the true value of $\theta$ is (this independence is both the strength and weakness of the confidence interval).

The confidence interval is restricted in the way that it draws the boundaries. The confidence interval places these boundaries by considering the conditional distribution $X_\theta$ and will cover $\alpha \%$ independent from what the true value of $\theta$ is.

The confidence interval is restricted in the way that it draws the boundaries. The confidence interval places these boundaries by considering the conditional distribution $X_\theta$ and will cover $\alpha \%$ independent from what the true value of $\theta$ is (this independence is both the strength and weakness of the confidence interval).

added 276 characters in body
Source Link
Sextus Empiricus
  • 86.6k
  • 6
  • 115
  • 304

See in the image below the expression of conditional probability/chance of containing the parameter for this particular example

Why does a 95% Confidence Interval (CI) not imply a 95% chance of containing the mean?

The $\alpha \%$ confidence interval will correctly estimate/contain the true parameter $\alpha \%$ of the time, for a each parameter $\theta$. But for a given observation $X$ the $\alpha \%$ confidence interval will not estimate/contain the true parameter $\alpha \%$ of the time. (type I errors will occur at the same rate $\alpha \%$ for different values of the underlying parameter $\theta$. But for different observations $X$ the type I error rate will be different. For some observations the confidence interval may be more/less often wrong than for other observations).

The $\alpha \%$ credible interval will correctly estimate/contain the true parameter $\alpha \%$ of the time, for each observation $X$. But for a given parameter $\theta$ the $\alpha \%$ credible interval will not estimate/contain the true parameter $\alpha \%$ of the time. (type I errors will occur at the same rate $\alpha \%$ for different values of the observed parameter $X$. But for different underlying parameters $\theta$ the type I error rate will be different. For some underlying parameters the credible interval may be more/less often wrong than for other underlying parameters).


Code for computing both images:

# parameters
set.seed(1)
n <- 2*10^4
perc = 0.95
za <- qnorm(0.5+perc/2,0,1)

# model
tau <- 1
theta <- rnorm(n,0,tau)
X <- rnorm(n,theta,1)

# plot scatterdiagram of distribution
plot(theta,X, xlab=expression(theta), ylab = "observed X",
     pch=21,col=rgb(0,0,0,0.05),bg=rgb(0,0,0,0.05),cex=0.25,
     xlim = c(-5,5),ylim=c(-5,5)
    )

# confidence interval
t <- seq(-6,6,0.01)
lines(t,t-za*1,col=2)
lines(t,t+za*1,col=2)

# credible interval
obsX <- seq(-6,6,0.01)
lines(obsX*tau^2/(tau^2+1)+za*sqrt(tau^2/(tau^2+1)),obsX,col=3)
lines(obsX*tau^2/(tau^2+1)-za*sqrt(tau^2/(tau^2+1)),obsX,col=3)

# adding contours for joint density
conX <- seq(-5,5,0.1)
conT <- seq(-5,5,0.1)
ln <- length(conX)

z <- matrix(rep(0,ln^2),ln)
for (i in 1:ln) {
  for (j in 1:ln) {
    z[i,j] <- dnorm(conT[i],0,tau)*dnorm(conX[j],conT[i],1)
  }
}
contour(conT,conX,-log(z), add=TRUE, levels = 1:10 )

legend(-5,5,c("confidence interval","credible interval","log joint density"), lty=1, col=c(2,3,1), lwd=c(1,1,0.5),cex=0.7)
title(expression(atop("scatterplot and contourplot of", 
                      paste("X ~ N(",theta,",1)   and   ",theta," ~ N(0,",tau^2,")"))))




# expression succes rate as function of X and theta
# Why does a 95% Confidence Interval (CI) not imply a 95% chance of containing the mean?
layout(matrix(c(1:2),1))
par(mar=c(4,4,2,2),mgp=c(2.5,1,0))
pX <- seq(-5,5,0.1)
pt <- seq(-5,5,0.1)
cc <- tau^2/(tau^2+1)

plot(-10,-10, xlim=c(-5,5),ylim = c(0,1),
     xlab = expression(theta), ylab = "chance of containing the parameter")
lines(pt,pnorm(pt/cc+za/sqrt(cc),pt,1)-pnorm(pt/cc-za/sqrt(cc),pt,1),col=3)
lines(pt,pnorm(pt+za,pt,1)-pnorm(pt-za,pt,1),col=2)
title(expression(paste("for different values ", theta)))

legend(-3.8,0.15,
       c("confidence interval","credible interval"),
       lty=1, col=c(2,3),cex=0.7, box.col="white")


plot(-10,-10, xlim=c(-5,5),ylim = c(0,1),
     xlab = expression(X), ylab = "chance of containing the parameter")
lines(pX,pnorm(pX*cc+za*sqrt(cc),pX*cc,sqrt(cc))-pnorm(pX*cc-za*sqrt(cc),pX*cc,sqrt(cc)),col=3)
lines(pX,pnorm(pX+za,pX*cc,sqrt(cc))-pnorm(pX-za,pX*cc,sqrt(cc)),col=2)
title(expression(paste("for different values ", X)))


text(0,0.3, 
     c("95% Confidence Interval\ndoes not imply\n95% chance of containing the parameter"),
     cex= 0.7,pos=1)

library(shape)
Arrows(-3,0.3,-3.9,0.38,arr.length=0.2)

The $\alpha \%$ confidence interval will correctly estimate/contain the true parameter $\alpha \%$ of the time, for a each parameter $\theta$. But for a given observation $X$ the $\alpha \%$ confidence interval will not estimate/contain the true parameter $\alpha \%$ of the time. (type I errors will occur at the same rate $\alpha \%$ for different values of the underlying parameter $\theta$. But for different observations $X$ the type I error rate will be different. For some observations the confidence interval may be more/less often wrong than for other observations).

The $\alpha \%$ credible interval will correctly estimate/contain the true parameter $\alpha \%$ of the time, for each observation $X$. But for a given parameter $\theta$ the $\alpha \%$ credible interval will not estimate/contain the true parameter $\alpha \%$ of the time. (type I errors will occur at the same rate $\alpha \%$ for different values of the observed parameter $X$. But for different underlying parameters $\theta$ the type I error rate will be different. For some underlying parameters the credible interval may be more/less often wrong than for other underlying parameters).

See in the image below the expression of conditional probability/chance of containing the parameter for this particular example

Why does a 95% Confidence Interval (CI) not imply a 95% chance of containing the mean?

The $\alpha \%$ confidence interval will correctly estimate/contain the true parameter $\alpha \%$ of the time, for a each parameter $\theta$. But for a given observation $X$ the $\alpha \%$ confidence interval will not estimate/contain the true parameter $\alpha \%$ of the time. (type I errors will occur at the same rate $\alpha \%$ for different values of the underlying parameter $\theta$. But for different observations $X$ the type I error rate will be different. For some observations the confidence interval may be more/less often wrong than for other observations).

The $\alpha \%$ credible interval will correctly estimate/contain the true parameter $\alpha \%$ of the time, for each observation $X$. But for a given parameter $\theta$ the $\alpha \%$ credible interval will not estimate/contain the true parameter $\alpha \%$ of the time. (type I errors will occur at the same rate $\alpha \%$ for different values of the observed parameter $X$. But for different underlying parameters $\theta$ the type I error rate will be different. For some underlying parameters the credible interval may be more/less often wrong than for other underlying parameters).


Code for computing both images:

# parameters
set.seed(1)
n <- 2*10^4
perc = 0.95
za <- qnorm(0.5+perc/2,0,1)

# model
tau <- 1
theta <- rnorm(n,0,tau)
X <- rnorm(n,theta,1)

# plot scatterdiagram of distribution
plot(theta,X, xlab=expression(theta), ylab = "observed X",
     pch=21,col=rgb(0,0,0,0.05),bg=rgb(0,0,0,0.05),cex=0.25,
     xlim = c(-5,5),ylim=c(-5,5)
    )

# confidence interval
t <- seq(-6,6,0.01)
lines(t,t-za*1,col=2)
lines(t,t+za*1,col=2)

# credible interval
obsX <- seq(-6,6,0.01)
lines(obsX*tau^2/(tau^2+1)+za*sqrt(tau^2/(tau^2+1)),obsX,col=3)
lines(obsX*tau^2/(tau^2+1)-za*sqrt(tau^2/(tau^2+1)),obsX,col=3)

# adding contours for joint density
conX <- seq(-5,5,0.1)
conT <- seq(-5,5,0.1)
ln <- length(conX)

z <- matrix(rep(0,ln^2),ln)
for (i in 1:ln) {
  for (j in 1:ln) {
    z[i,j] <- dnorm(conT[i],0,tau)*dnorm(conX[j],conT[i],1)
  }
}
contour(conT,conX,-log(z), add=TRUE, levels = 1:10 )

legend(-5,5,c("confidence interval","credible interval","log joint density"), lty=1, col=c(2,3,1), lwd=c(1,1,0.5),cex=0.7)
title(expression(atop("scatterplot and contourplot of", 
                      paste("X ~ N(",theta,",1)   and   ",theta," ~ N(0,",tau^2,")"))))




# expression succes rate as function of X and theta
# Why does a 95% Confidence Interval (CI) not imply a 95% chance of containing the mean?
layout(matrix(c(1:2),1))
par(mar=c(4,4,2,2),mgp=c(2.5,1,0))
pX <- seq(-5,5,0.1)
pt <- seq(-5,5,0.1)
cc <- tau^2/(tau^2+1)

plot(-10,-10, xlim=c(-5,5),ylim = c(0,1),
     xlab = expression(theta), ylab = "chance of containing the parameter")
lines(pt,pnorm(pt/cc+za/sqrt(cc),pt,1)-pnorm(pt/cc-za/sqrt(cc),pt,1),col=3)
lines(pt,pnorm(pt+za,pt,1)-pnorm(pt-za,pt,1),col=2)
title(expression(paste("for different values ", theta)))

legend(-3.8,0.15,
       c("confidence interval","credible interval"),
       lty=1, col=c(2,3),cex=0.7, box.col="white")


plot(-10,-10, xlim=c(-5,5),ylim = c(0,1),
     xlab = expression(X), ylab = "chance of containing the parameter")
lines(pX,pnorm(pX*cc+za*sqrt(cc),pX*cc,sqrt(cc))-pnorm(pX*cc-za*sqrt(cc),pX*cc,sqrt(cc)),col=3)
lines(pX,pnorm(pX+za,pX*cc,sqrt(cc))-pnorm(pX-za,pX*cc,sqrt(cc)),col=2)
title(expression(paste("for different values ", X)))


text(0,0.3, 
     c("95% Confidence Interval\ndoes not imply\n95% chance of containing the parameter"),
     cex= 0.7,pos=1)

library(shape)
Arrows(-3,0.3,-3.9,0.38,arr.length=0.2)
added 341 characters in body
Source Link
Sextus Empiricus
  • 86.6k
  • 6
  • 115
  • 304
Loading
added 341 characters in body
Source Link
Sextus Empiricus
  • 86.6k
  • 6
  • 115
  • 304
Loading
Source Link
Sextus Empiricus
  • 86.6k
  • 6
  • 115
  • 304
Loading