logLikNB {linelistBayes}R Documentation

Compute Log-Likelihood for a Right-Truncated Negative Binomial Model

Description

This function calculates the log-likelihood of observing the given data under a right-truncated negative binomial distribution. It is used to assess the fit of a model involving delay times in reporting cases, where each case has a delay modeled by a negative binomial distribution that is truncated at a specified maximum delay.

Usage

logLikNB(delay_vec, x12, disp, betaplus, maxdelay)

Arguments

delay_vec

NumericVector representing the observed delay times for each case.

x12

NumericMatrix of covariates used to model the mean of the negative binomial distribution. Each row corresponds to a case and columns correspond to covariates including time since onset and others.

disp

NumericVector indicating the dispersion parameter for each case. This can affect the distribution of counts and is used to model heterogeneity in reporting delays.

betaplus

NumericVector containing current estimates of the model parameters, which may include coefficients for covariates and additional parameters.

maxdelay

Integer specifying the maximum reporting delay, truncating the distribution at this value.

Details

This function computes the log-likelihood by calculating the likelihood of each observed delay under the specified model parameters, considering the truncation at 'maxdelay'. The parameters 'disp' and 'betaplus' allow for flexibility in modeling different types of heterogeneity and covariate effects.

Value

Double representing the log-likelihood of the data given the model parameters. This value measures how well the model with the current parameter estimates fits the observed data.

Examples

# Example usage with arbitrary data:
delay_vec <- rnorm(100, mean=10, sd=3)  # Simulated delay times
x12 <- matrix(rnorm(300), ncol=3)       # Simulated covariates
disp <- rep(1, 100)                     # Dispersion parameter, constant for simplicity
betaplus <- runif(4)                    # Simulated parameter estimates
maxdelay <- 15                          # Maximum delay for truncation
loglik_value <- logLikNB(delay_vec, x12, disp, betaplus, maxdelay)

[Package linelistBayes version 1.0 Index]