130 likes | 206 Views
Presentation of Question 3. Sun Jie U093351B. pv = seq (0.00001,0.05,0.00001) xv=51; nv =8197 logf1= (xv-.5)*log( pv )+(nv-xv-.5)*log(1-pv) f2= exp (logf1-max(logf1)) intf2=sum(f2)*( pv [2]- pv [1]) post=f2/intf2 prior= dbeta (pv,.5,.5) plot( pv , prior,col ="red", ylim =range(0:500))
E N D
Presentation of Question 3 Sun Jie U093351B
pv=seq(0.00001,0.05,0.00001) • xv=51; nv=8197 • logf1= (xv-.5)*log(pv)+(nv-xv-.5)*log(1-pv) • f2=exp(logf1-max(logf1)) • intf2=sum(f2)*(pv[2]-pv[1]) • post=f2/intf2 • prior=dbeta(pv,.5,.5) • plot(pv, prior,col="red",ylim=range(0:500)) • points(pv,post) Prior1: Be(.5,.5)
pmean=sum(pv*post)/sum(post) • pcdf=cumsum(post)/sum(post) • pmedian=.5*(max(pv[pcdf<.5])+min(pv[pcdf>.5])) • pmode=pv[which.max(post)] Point Estimate
CI1=c(max(pv[pcdf<.025]),min(pv[pcdf>.975])) • threshold=max(post) • coverage=0 • for(i in seq(.999,.001,-.001)) • { • threshold=i*max(post) • within=which(post>=threshold) • coverage=pcdf[max(within)]-pcdf[min(within)] • if(coverage>=.95)break() • } • CI2=pv[range(within)] Interval Estimate
> pmean [1] 0.00628202 • > pmedian [1] 0.006235 • > pmode [1] 0.00616 • > CI1 [1] 0.00468 0.00810 • > CI2 [1] 0.00461 0.00802
pv=seq(0.00001,0.05,0.00001) • xv=51; nv=8197 • logf1= xv*log(pv)+(nv-xv)*log(1-pv)-(pv-.015)^2/(2*.0025^2) • f2=exp(logf1-max(logf1)) • intf2=sum(f2)*(pv[2]-pv[1]) • post=f2/intf2 • prior=dnorm(pv,mean=.015,sd=.0025) • plot(pv, prior,col="red",ylim=range(0:500)) • points(pv,post) Prior2: N(1.5%, .25%)
> pmean[1] 0.007414297 • > pmedian[1] 0.007375 • > pmode[1] 0.00731 • > CI1 • [1] 0.00565 0.00936 • > CI2 • [1] 0.00559 0.00930
pv=seq(0.00001,0.05,0.00001) • xv=51; nv=8197 • logf1= xv*log(pv)+(nv-xv)*log(1-pv)-100*pv • f2=exp(logf1-max(logf1)) • intf2=sum(f2)*(pv[2]-pv[1]) • post=f2/intf2 • prior=dexp(pv,rate=100) • plot(pv, prior,col="red",ylim=range(0:500)) • points(pv,post) Prior3: Exp(100)
> pmean • [1] 0.006266297 • > pmedian • [1] 0.006225 • > pmode • [1] 0.00615 • > CI1 • [1] 0.00467 0.00807 • > CI2 • [1] 0.00461 0.00799 Prior3: Exp(100)
Prior1: Be(.5,.5) Prior3: Exp(100) Prior2: N(1.5%, .25%) • > pmean[1] 0.007414297 • > pmedian[1] 0.007375 • > pmode[1] 0.00731 • > CI1 • [1] 0.00565 0.00936 • > CI2 • [1] 0.00559 0.00930 • > pmean[1] 0.006266297 • > pmedian [1] 0.006225 • > pmode [1] 0.00615 • > CI1 [1] 0.00467 0.00807 • > CI2 [1] 0.00461 0.00799 • > pmean [1] 0.00628202 • > pmedian [1] 0.006235 • > pmode [1] 0.00616 • > CI1 [1] 0.00468 0.00810 • > CI2 [1] 0.00461 0.00802 Comparison
Thank you. Questions?