p_value: Calculate p-value(s)

Description Usage Arguments Details Value Examples

View source: R/wrappers.R

Description

p_value returns the vector of p-values (dependent on the true \mjseqnH_0 proportions) and its maximum of the test for non-inferiority of two proportions specified by method.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
p_value(
  x_E.,
  x_C.,
  n_E,
  n_C,
  method,
  delta = NULL,
  size_acc = 3,
  better = c("high", "low"),
  calc_method = c("uniroot", "grid search")
)

Arguments

x_E.

Number of events in experimental group.

x_C.

Number of events in control group.

n_E

Sample size in experimental group.

n_C

Sample size in control group.

method

Specifies the effect measure/test statistic. One of "RD", "RR", or "OR".

delta

Non-inferiority margin.

size_acc

Accuracy of grid

better

"high" if higher values of x_E favour the alternative hypothesis and "low" vice versa.

calc_method

"grid search" or "uniroot"

Details

If higher values of \mjseqnx_E favour the alternative hypothesis (better = "high"), we are interested in testing the null hypothesis \mjsdeqnH_0: e(p_E, p_C) \le \delta , where \mjseqne is one of the effect measures risk difference (method = "RD"), risk ratio (method = "RR"), or odds ratio (method = "OR"). The test statistic for risk difference is \mjsdeqnT_\mboxRD, \delta(x_E, x_C) = \frac\hatp_E - \hat p_C - \delta\sqrt\frac\tilde p_E(1 - \tilde p_E)n_E + \frac\tilde p_C(1 - \tilde p_C)n_C, where \mjseqn\tilde p_C = \tilde p_C(x_E, x_C) is the MLE of \mjseqnp_C and \mjseqn\tilde p_E = \tilde p_C + \delta is the MLE of \mjseqnp_E under \mjseqnp_E - p_C = \delta. High values of \mjseqnT_\mboxRD, \delta favour the alternative hypothesis. The test statistic for risk ratio is \mjsdeqnT_\mboxRR, \delta(x_E, x_C) = \frac\hat p_E - \delta \cdot \hat p_C\sqrt\frac\tilde p_E(1 - \tilde p_E)n_E + \delta^2\frac\tilde p_C(1 - \tilde p_C)n_C, where \mjseqn\tilde p_C = \tilde p_C(x_E, x_C) is the MLE of \mjseqnp_C and \mjseqn\tilde p_E = \tilde p_C + \delta is the MLE of \mjseqnp_E under \mjseqnp_E / p_C = \delta. High values of \mjseqnT_\mboxRR, \delta favour the alternative hypothesis. The test statistic for Odds Ratio \mjsdeqn T_\mboxOR, \delta = 1-(1 - F_\mboxncHg(X_E+X_C, n_E, n_C, \delta)(x_E-1)) is based on Fisher's non-central hypergeometric distribution with density \mjsdeqn f_\mboxncHg(s, n_E, n_C, \delta)(k) = \frac\binomn_Ek\cdot \binomn_Cs-k\cdot \delta^k\sum\limits_l \in A_s, n_E, n_C \binomn_El\cdot \binomn_Cs-l\cdot \delta^l, where \mjseqnA_s, n_E, n_C = {\max(0, s-n_C), ..., \min(n_E, s)}. The density is zero if \mjseqnk < \max(0, s-n_C) or \mjseqnk > \min(n_E, s). High values of \mjseqnT_\mboxOR, \delta favour the alternative hypothesis (due to "1-...").

Value

A list with the two elements p_max and p_vec. p_max is the maximum p-value and most likely servers as "the one" p-value. p_vec is a named vector. The names indicate the true proportion pairs \mjseqn(p_E, p_C) with \mjseqne(p_E, p_C) = \delta that underly the calculation of the p-values. It can be used for plotting the p-value versus the true proportions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
p_value(
  x_E. = 3,
  x_C. = 4,
  n_E = 10,
  n_C = 10,
  method = "RD",
  delta = -0.1,
  size_acc = 3,
  better = "high"
)

s-kilian/binary documentation built on Sept. 26, 2021, 6:28 p.m.