Skip to contents

[Experimental]

Compute the posterior probability that the response probability P_E is above a threshold. such that this posterior probability can be expressed as Pr(P_E > p | data). Prior is P_E ~ sum(weights * beta(parE[, 1], parE[, 2])), i.e., a mixture of beta priors. Default is one component only with uniform or beta(1,1).

We observed x successes in n trials.

Posterior is again a mixture of beta priors, with updated mixture weights and beta parameters.

Usage

postprob(x, n, p, parE = c(1, 1), weights, betamixPost, log.p = FALSE)

Arguments

x

(numeric):
number of successes.

n

(number):
number of patients.

p

(number):
threshold that P_E is measured.

parE

(matrix):
the beta parameters matrix, with K rows and 2 columns, corresponding to the beta parameters of the K components.

weights

(vector):
The mixture weights of the beta mixture prior.

betamixPost

(matrix):
optional result of [h_getBetamixPost()] in order to speed up the computations. If supplied, this is directly used, bypassing the other arguments (except p and log.p of course).

log.p

(number):
whether to return the log of the probability

Value

The posterior probability that the response rate P_E is above p.

Examples

# Example taken from Lee and Liu (2008) :
# We observed 16 successes out of 23 patients
# We set a threshold of 0.60
# Assume a beta(0.6,0.4) prior for P_E
# Posterior will be a beta(16.6, 7.4), Pr(P_E > p | data) = 0.836

postprob(x = 16, n = 23, p = 0.60, par = c(0.6, 0.4))
#> [1] 0.8359808

# We could instead specify a mixture prior
# 2 component beta mixture prior :
# i.e., P_E ~ 0.6*beta(0.6,0.4) + 0.4*beta(1,1) and Pr(P_E > p | data) = 0.823
postprob(
  x = 16, n = 23, p = 0.60,
  par =
    rbind(
      c(0.6, 0.4),
      c(1, 1)
    ),
  weights = c(0.6, 0.4)
)
#> [1] 0.8226271