lc_loglik: Calculate the log likelihood of left censored lognormal data.

Description Usage Arguments Value Examples

View source: R/LNConditionalMeans.R

Description

Calculate the log likelihood of left censored lognormal data. The log likelihood has two parts – a term for observed values over the detection limit, and term for censored values (where all we know is that the value falls below the detection limit).

Usage

1
lc_loglik(params, cc, flg)

Arguments

params

A two item list or vector containing the mean and sd of the distribution on the log scale (i.e., the parameters of the related normal distribution).

cc

A vector of data values, including both observed values, where they exist, or the detection limits, where data was censored.

flg

A vector of TRUE or FALSE values, of the same length as cc, that indicates which values are detection limits (TRUE) and which are measured values (FALSE)

Value

The calculated log likelihood under a censored lognormal distribution with the specific parameters.

Examples

1
2
3
4
5
6
df <- data.frame(sim = sort(stats::rlnorm(25,2,3)),
                  cens=c(rep.int(TRUE,5), rep.int(FALSE,20)))
df$sim[1:4] <- df$sim[5]
lc_loglik(c(2,5), df$sim, df$cens)
lc_loglik(c(2,3), df$sim, df$cens)
lc_loglik(c(1,3), df$sim, df$cens)

ccb60/LCensMeans documentation built on Oct. 30, 2020, 3:26 a.m.