Computes \(\Pr(T_t - T_c \le q)\) (or the upper tail \(\Pr(T_t - T_c > q)\)) for independent location-scale t variables \(T_k = \mu_k + s_k X_k\), where \(X_k\) follows a t distribution with \(\nu_k\) degrees of freedom. This is the posterior (or posterior predictive) probability used for a single continuous endpoint.
Usage
ptdiff(
q,
mu_t,
scale_t,
df_t,
mu_c,
scale_c,
df_c,
method = c("NI", "MM", "MC"),
nMC = 10000L,
lower.tail = TRUE
)Arguments
- q
Numeric vector of quantiles.
- mu_t, scale_t, df_t
Location, positive scale and positive degrees of freedom of the treatment group.
- mu_c, scale_c, df_c
Location, positive scale and positive degrees of freedom of the control group.
- method
One of
"NI"(default),"MM"or"MC".- nMC
Number of Monte Carlo draws per element for
method = "MC".- lower.tail
Logical; if
TRUE(default), probabilities are \(\Pr(T_t - T_c \le q)\), otherwise \(\Pr(T_t - T_c > q)\).
Value
A numeric vector of probabilities. All arguments from q to
df_c are recycled to a common length; each must have length 1 or
the common length.
Details
Three methods are available.
"NI"Numerical integration over the whole real line by adaptive Gauss-Kronrod quadrature (the QUADPACK routine used by
integrate). The integral is taken over the variable of the group with the smaller scale, for example \(\int f_c(u) \Pr(T_t > u + q) \, du\) when \(s_c \le s_t\). The range is split around the peak of the density and around the change of the other factor, and the parts far from the origin are integrated on a logarithmic scale, so that heavy tails and very different scales are handled. The absolute error is below \(10^{-9}\) in the tests, which include scale ratios from \(10^{-9}\) to \(10^3\) and degrees of freedom from 0.5 toInf."MM"The moment-matching approximation of Yamaguchi, Homma, Takeda and Maruo (submitted, Theorem 1), which replaces the difference by a single t distribution with matched second and fourth moments. It requires \(\nu_t > 4\) and \(\nu_c > 4\), is evaluated in closed form, and is the fastest method.
"MC"Monte Carlo simulation with
nMCdraws for each element, using the random number generator of R.
Degrees of freedom may be Inf (normal distributions). For the lower
tail, the upper tail of \(T_c - T_t\) at \(-q\) is computed, so both
tails are accurate near 0.
References
Yamaguchi, Y., Homma, G., Takeda, K. and Maruo, K. (submitted). Moment-matching approximation for t-differences in clinical trials with continuous endpoints.
See also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
pbetadiff(),
phazardratio(),
psurvdiff(),
rdirichlet()
