loglik: Log-likelihood of sensitivity, specificity, and prevalence

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/loglik.R

Description

The function returns the minus log-likelihood value given sensitivity and specificity of at least three testing methods and prevalence of true positives as parameters, and contingency table of testing results of the methods as data.

Usage

1
loglik(param, ntest, ny, tol = 1e-04)

Arguments

param

A vector of 2K + 1 parameter values, corresponding to K sensitivity values, K specificity values, and prevalence of true positives, respectively.

ntest

An integer of the number of tests performed by each method, i.e., sample size for evaluating the likelihood.

ny

A summary counts vector for the contingencies of each combination of test results, must be named according to the 0-1 pattern, e.g., 010 = results from 3 tests are negative, positive, and negative, respectively. names(ny) maybe incomplete and has arbitrary order.

tol

A value of tolerance, default 1e-4. If any param value or marginal probability is too close to 0 or 1, distance less than tol, a log-likelihood value of exp(30) will be returned.

Value

A single value of minus log-likelihood.

Note

This is an internal function for likelihood calculation.

Author(s)

Xia Shen, Yudi Pawitan

References

Yang Z, Xu W, Zhai R, Li T, Ning Z, Pawitan Y, Shen X (2020). Triangulation of analysis strategies links complex traits to specific tissues and cell types. Submitted.

See Also

triangulate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
sens <- c(.5,.6,.7)
spec <- c(.5,.4,.3)
p <- .5
param <- c(sens, spec, p)
ny <- c(123, 456, 789)
names(ny) <- c('010', '110', '111')
ny
# 010 110 111
# 123 456 789

loglik(param, ntest = 3, ny)
# [1] 2844.676

## End(Not run)

xiashen/triangulation documentation built on Aug. 30, 2020, 2:13 a.m.