1pbetap=function(ab,n,s) 2{ 3# 4# PBETAP Predictive distribution of number of successes in future binomial 5# experiment with a beta prior. PRED = PBETAP(AB,N,S) returns a vector 6# PRED of predictive probabilities, where AB is the vector of beta 7# parameters, N is the future binomial sample size, and S is the vector of 8# numbers of successes for which predictive probabilities will be computed. 9#------------------------ 10# Written by Jim Albert 11# albert@bgnet.bgsu.edu 12# November 2004 13#------------------------ 14 15pred=0*s; 16a=ab[1]; b=ab[2]; 17 18lcon=lgamma(n+1)-lgamma(s+1)-lgamma(n-s+1); 19 20pred=exp(lcon+lbeta(s+a,n-s+b)-lbeta(a,b)); 21 22return(pred) 23} 24