compute_lik_prod: Compute Piece of Likelihood

View source: R/compute_lik_prod.R

compute_lik_prodR Documentation

Compute Piece of Likelihood

Description

This function computes the portion of the likelihood for a given sample i and for a given point in the sample space for lambda_i.

Usage

compute_lik_prod(a, epsilon, beta, x, y, lambda, i, KO_max, use_expit = FALSE)

Arguments

a

A number in [0, 1] that represents the probability of observing a KO given that one of the modules it is included in is present.

epsilon

A number in [0, 1] that represents the probability of observing a KO given that none of the modules it is included in are present.

beta

A matrix with p+1 rows and m columns. The first row are intercepts for each module, and the element in row i and column k represents the coefficient for the covariate x_{i+1} and module k.

x

A design matrix, where the first column contains 1's and the next p columns include the p covariates measured on the n samples.

y

The outcome matrix, with n rows and r columns where the element in row i and column j is 1 if KO j was observed in sample i and 0 otherwise.

lambda

A vector of lambda values representing one point in the sample space in which element k is 1 if module k is present in sample i and 0 otherwise.

i

A number representing the sample being considered.

KO_max

A vector of length r based on the value lambda in which a 1 for element j means that the maximum over all lambda values with indices in the set D_j is 1, and a 0 means that the maximum is 0.

use_expit

If TRUE, then replace a and epsilon with expit(a) and expit(epsilons). Set to FALSE by default.

Value

The likelihood product for the given sample i and lambda vector.

Examples

beta <- matrix(rnorm(4), nrow = 2)
x <- matrix(c(rep(1, 5), rbinom(5, 1, 0.5)), nrow = 5)
y <- matrix(c(rbinom(5*5, 1, 0.5)), nrow = 5)
lambda <- c(1, 0)
KO_max <- c(1, 1, 1, 0, 0)
compute_lik_prod(0.8, 0.1, beta, x, y, lambda, 2, KO_max)


svteichman/ModulePackage documentation built on May 13, 2022, 8:15 p.m.