recon_vcov: Reconstruct likelihood covariance matrix

Description Usage Arguments Details Value See Also Examples

View source: R/recon_vcov.R

Description

Reconstruct the contrast-level likelihood covariance matrix from prior and posterior covariance matrices. The resulting likelihood covariance matrix can then be used to perform a contrast-level threshold analysis with the function nma_thresh.

Usage

1
2
3
4
5
6
7
recon_vcov(
  post,
  prior.prec = 1e-04,
  prior.vcov = diag(1/prior.prec, dim(post)[1]),
  X = NULL,
  verbose = FALSE
)

Arguments

post

Posterior covariance matrix.

prior.prec

Prior precision. Defaults to .0001 which is a common flat prior for NMA. Not used if prior.vcov is specified.

prior.vcov

Prior covariance matrix. Defaults to a diagonal matrix of the same size as post, with elements 1/prior.prec.

X

Contrast design matrix. If omitted a complete network is assumed.

verbose

Print intermediate matrices? Defaults to FALSE.

Details

Full details of the calculation are given by Phillippo et al. (2018). Briefly, the aim is to recover the contrast-level likelihood covariance matrix V that would have led to the posterior covariance matrix Σ being obtained from a fixed effects NMA, with design matrix X and prior covariance matrix Σ_d for a normal prior on the basic treatment parameters. This is possible in this case via the equation (resulting from conjugacy):

Σ^{-1} = X^TV^{-1}X + Σ_d^{-1}.

When the treatment network is complete (i.e. fully connected), this equation may be rearranged exactly.

When the treatment network is incomplete (i.e. not all treatments are directly compared), this equation may be solved through the use of non-negative least squares (NNLS).

When NNLS is used, some additional diagnostics are printed (and returned as attributes). Firstly, the residual sum-of-squares (RSS) from the NNLS fit. The RSS is further split into fixed RSS, from structural zeros in the reconstructed posterior according to the design matrix (and hence not fitted) that are non-zero in the true posterior, and fitted RSS, from the other fitted elements. Secondly, the Kullback-Leibler divergence of the reconstructed posterior from the true posterior. Interpreting the KL divergence as a log Bayes factor, values less than 1 indicate negligible differences between the reconstructed posterior from the true posterior, whilst values greater than 3 indicate considerable differences.

Value

A matrix; the reconstructed likelihood covariance matrix. If NNLS is used, the residual sum-of-squares and Kullback-Leibler divergence diagnostics (as printed to the console) are returned as additional attributes rss.total, rss.fixed, rss.free, kl.divergence.

See Also

nma_thresh.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Please see the vignette "Examples" for worked examples including use of
# this function, including more information on the brief code below.

vignette("Examples", package = "nmathresh")

### Contrast level thresholds for Thrombolytic treatments NMA
K <- 6   # Number of treatments

# Contrast design matrix is
X <- matrix(ncol = K-1, byrow = TRUE,
            c(1, 0, 0, 0, 0,
              0, 1, 0, 0, 0,
              0, 0, 1, 0, 0,
              0, 0, 0, 1, 0,
              0, -1, 1, 0, 0,
              0, -1, 0, 1, 0,
              0, -1, 0, 0, 1))

# Reconstruct hypothetical likelihood covariance matrix using NNLS
lik.cov <- recon_vcov(Thrombo.post.cov, prior.prec = .0001, X = X)

nmathresh documentation built on July 8, 2020, 5:17 p.m.