View source: R/conflict_mahalanobis.R
| conflict_mahalanobis | R Documentation |
Tests joint prior-data conflict across two correlated endpoints using the Mahalanobis distance. Under the null (no conflict) the squared distance follows a chi-squared distribution with degrees of freedom equal to the number of endpoints.
conflict_mahalanobis(
prior_means,
prior_cov,
obs_means,
obs_cov,
alpha = 0.05,
labels = NULL
)
prior_means |
Numeric vector of length k. Prior means for each endpoint. |
prior_cov |
k x k numeric matrix. Prior covariance matrix. |
obs_means |
Numeric vector of length k. Observed data means. |
obs_cov |
k x k numeric matrix. Observed data covariance (Var/n for each diagonal; Cov/n for off-diagonal). |
alpha |
Numeric. Significance level for the chi-squared test.
Default |
labels |
Character vector of length k. Endpoint labels for output. |
Assumptions: This test assumes that the prior and observed summary statistics are approximately multivariate Normal. For proportion endpoints (e.g. response rates), transform to the log-odds scale before entering means and variances. For hazard ratios, use the log scale. Results may be unreliable if the Normal approximation is poor (e.g. for small samples with extreme proportions).
Current limitation: The function is designed for bivariate (k = 2) endpoints. While it will accept k > 2, the Shiny interface currently only exposes two endpoints. Support for k >= 3 is a planned extension.
Distribution family: The Mahalanobis approach is distribution-agnostic at the summary statistic level – it does not require a specific prior family (Beta, Normal, etc.). Any continuous prior whose mean and covariance can be extracted is supported.
A named list of class bayprior_conflict_mv with components:
Mahalanobis distance D.
Squared distance D^2.
Chi-squared p-value (df = p).
Degrees of freedom (number of endpoints, p).
Logical. TRUE if pvalue < alpha.
Named numeric vector of per-parameter marginal z-scores (difference standardised by the marginal predictive SD).
Character. Plain-language summary.
Endpoint labels.
The significance level used.
Mahalanobis, P. C. (1936). On the generalised distance in statistics. Proceedings of the National Institute of Sciences of India, 2, 49–55.
pm <- c(0.35, 0.60)
pcov <- matrix(c(0.010, 0.003, 0.003, 0.015), 2, 2)
om <- c(0.55, 0.58)
ocov <- matrix(c(2e-4, 4e-5, 4e-5, 2e-4), 2, 2)
conflict_mahalanobis(pm, pcov, om, ocov, labels = c("Response rate", "OS rate"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.