Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

preddist

Predictive Distributions for Mixture Distributions


Description

Predictive distribution for mixture of conjugate distributions (beta, normal, gamma).

Usage

preddist(mix, ...)

## S3 method for class 'betaMix'
preddist(mix, n = 1, ...)

## S3 method for class 'normMix'
preddist(mix, n = 1, sigma, ...)

## S3 method for class 'gammaMix'
preddist(mix, n = 1, ...)

Arguments

mix

mixture distribution

...

includes arguments which depend on the specific prior-likelihood pair, see description below.

n

predictive sample size, set by default to 1

sigma

The fixed reference scale of a normal mixture. If left unspecified, the default reference scale of the mixture is assumed.

Details

Given a mixture density (either a posterior or a prior)

p(θ,w,a,b)

and a data likelihood of

y|θ ~ f(y|θ),

the predictive distribution of a one-dimensional summary y_n of $n$ future observations is distributed as

y_n ~ \int p(u,w,a,b) \, f(y_n|u) du .

This distribution is the marginal distribution of the data under the mixture density. For binary and Poisson data y_n = ∑_{i=1}^n y_i is the sum over future events. For normal data, it is the mean\bar{y}_n = 1/n ∑_{i=1}^n y_i.

Value

The function returns for a normal, beta or gamma mixture the matching predictive distribution for y_n.

Methods (by class)

  • betaMix: Obtain the matching predictive distribution for a beta distribution, the BetaBinomial.

  • normMix: Obtain the matching predictive distribution for a Normal with constant standard deviation. Note that the reference scale of the returned Normal mixture is meaningless as the individual components are updated appropriatley.

  • gammaMix: Obtain the matching predictive distribution for a Gamma. Only Poisson likelihoods are supported.

Supported Conjugate Prior-Likelihood Pairs

Prior/Posterior Likelihood Predictive Summaries
Beta Binomial Beta-Binomial n, r
Normal Normal (fixed σ) Normal n, m, se
Gamma Poisson Gamma-Poisson n, m
Gamma Exponential Gamma-Exp (not supported) n, m

Examples

# Example 1: predictive distribution from uniform prior.
bm <- mixbeta(c(1,1,1))
bmPred <- preddist(bm, n=10)
# predictive proabilities and cumulative predictive probabilities
x <- 0:10
d <- dmix(bmPred, x)
names(d) <- x
barplot(d)
cd <- pmix(bmPred, x)
names(cd) <- x
barplot(cd)
# median
mdn <- qmix(bmPred,0.5)
mdn

# Example 2: 2-comp Beta mixture

bm <- mixbeta( inf=c(0.8,15,50),rob=c(0.2,1,1))
plot(bm)
bmPred <- preddist(bm,n=10)
plot(bmPred)
mdn <- qmix(bmPred,0.5)
mdn
d <- dmix(bmPred,x=0:10)

n.sim <- 100000
r <-  rmix(bmPred,n.sim)
d
table(r)/n.sim


# Example 3: 3-comp Normal mixture

m3 <- mixnorm( c(0.50,-0.2,0.1),c(0.25,0,0.2), c(0.25,0,0.5), sigma=10)
print(m3)
summary(m3)
plot(m3)
predm3 <- preddist(m3,n=2)
plot(predm3)
print(predm3)
summary(predm3)

RBesT

R Bayesian Evidence Synthesis Tools

v1.6-1
GPL (>= 3)
Authors
Novartis Pharma AG [cph], Sebastian Weber [aut, cre], Beat Neuenschwander [ctb], Heinz Schmidli [ctb], Baldur Magnusson [ctb], Yue Li [ctb], Satrajit Roychoudhury [ctb], Trustees of Columbia University [cph] (R/stanmodels.R, configure, configure.win)
Initial release
2020-05-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.