Probability density for a truncated Normal distribution with mean equal to location and standard deviation equal to scale.

likelihood(
  biphasic = FALSE,
  param.name = NULL,
  rj.obj,
  values = NULL,
  included.cov = NULL,
  RJ = FALSE,
  lprod = TRUE
)

Arguments

biphasic

Logical. Indicates the type of model for which likelihoods should be calculated.

param.name

Paramter name. Ignored if values is specified.

rj.obj

rjMCMC object.

values

List of proposed values, if available.

included.cov

Boolean vector indicating which contextual covariates are included in the current iteration of the rjMCMC sampler.

RJ

Logical. If TRUE, returns the likelihoods associated with between-model jumps. If FALSE, returns the likelihoods associated with the update step of the Metropolis sampler.

lprod

If TRUE, returns the product of individual likelihoods.

x

Vector of quantiles.

location

Vector of means.

scale

Vector of standard deviations.

log

Logical. If TRUE, probabilities p are given as log(p).

L

Lower limit of the distribution.

U

Upper limit of the distribution. dtnorm <- function(x, location = 0, scale = 1, log = FALSE, L = -Inf, U = Inf) d <- dnorm(x, location, scale, log = TRUE) denom <- log(pnorm(U, location, scale) - pnorm(L, location, scale)) d <- d - denom d(x < L) | (x > U) <- -100000 # When input quantile is outside bounds dis.infinite(d) <- -100000 # When input location is outside bounds if(!log) d <- exp(d) return(d)

#' The Truncated Normal Distribution #' #' Generate random deviates from a truncated normal distribution with mean equal to location and standard deviation equal to scale. #' #' @param n Number of observations. #' @param location Vector of means. #' @param scale Vector of standard deviations. #' @param L Lower limit of the distribution. #' @param U Upper limit of the distribution.

rtnorm <- function(n, location, scale, L, U) location + scale * qnorm(pnorm(L, location, scale) + runif(n)*(pnorm(U, location, scale) - pnorm(L, location, scale)))

d_binom <- function(x, size, prob, log) d <- dbinom(x = x, size = size, prob = prob, log = log) dis.infinite(d) <- -100000 # To avoid Inf that cause numerical issues return(d) Likelihood

Calculate the log-likelihood of a monophasic dose-response model, as required by the rjMCMC sampler.