Processing math: 100%

Ejemplo con distribución Poisson

Suponga que tenemos una muestra aleatoria X1,...,X10 tal que XjPoisson(θ). Recordemos que

1. Datos

set.seed(10000)
n<-10
X<-rpois(n, 4) #suponemos que theta = 4.
X
##  [1] 4 4 3 4 3 3 5 5 4 1
mean(X)
## [1] 3.6

Tenemos que la verosimilitud es:

L(θ|x)=θnj=1xjenθnj=1xj!

2. Distribución previa no informativa.

θUnif(0,B) donde B va a representar un valor arbitrario muy grande.

La distribución a posteriori es:

π(θ|x)L(θ|x)π(θ)

π(θ|x)θxjenθxj!1Bθnˉxenθ Esto indica que la distribución posterior tiene nucleo de una distribución gamma:

θ|xGamma(nˉx+1,n)

B<-100

alfa1<- n*mean(X)+1
beta1<- n

theta <- seq(0,10,by=0.1)
pi.theta <- dgamma(x=theta,shape=alfa1,rate=beta1)
plot(theta,pi.theta,type="l")
abline(v=mean(X),col=2)
abline(h=1/B,col=3)

La media posterior usando una previa no informativa.

alfa1/beta1
## [1] 3.7

3. Distribución previa informativa.

Suponga que conocemos de antemano información respecto a θ,

π(θ)=βαθα1eβθΓ(α) π(θ|x)=L(θ|x)π(θ)+0L(θ|x)π(θ)L(θ|x)π(θ)=θnˉxenθxj!βαθα1eβθΓ(α) θnˉxenθθα1eβθ=θnˉx+α1eθ(n+β)

Por lo tanto concluimos que θ|xGamma(nˉx+α,n+β).

alfa0 <- 4
beta0 <- 2
  
alfa1<- n*mean(X)+alfa0
beta1<- n+beta0

theta <- seq(0,10,by=0.1)
pi.theta.prior <- dgamma(x=theta,shape=alfa0,rate=beta0)
pi.theta <- dgamma(x=theta,shape=alfa1,rate=beta1)
plot(theta,pi.theta.prior,type="l", ylim=c(0,1))
points(theta,pi.theta,type="l",col=2)
abline(v=mean(X),col=3)

La media posterior usando una previa informativa (depende de la información a priori).

alfa1/beta1
## [1] 3.333333

Recuerde que:

E(θ|x)=nˉx+β(αβ)n+β