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

postprob(
  x = 0:23, n = 23, p = 0.60,
  par =
    rbind(
      c(0.6, 0.4),
      c(1, 1)
    ),
  weights = c(0.6, 0.4)
)
#>  [1] 1.610230e-10 8.199326e-09 1.633863e-07 1.979370e-06 1.685148e-05
#>  [6] 1.084654e-04 5.515347e-04 2.281187e-03 7.835363e-03 2.269926e-02
#> [11] 5.614896e-02 1.198178e-01 2.226531e-01 3.637244e-01 5.278774e-01
#> [16] 6.893075e-01 8.226271e-01 9.142057e-01 9.657989e-01 9.891582e-01
#> [21] 9.974047e-01 9.995695e-01 9.999586e-01 9.999988e-01