likelihood_norm: Normally distributed errors likelihood function

Description Usage Arguments Value Examples

View source: R/cost_functions.R

Description

Calculates the likelihood of a given vector of parameters for the provided data. Assumes error is normally distributed where standard deviation is the final argument of the parameter vector. Restrictions on param_table: must be a data frame or matrix with headers: value, lower_bound, upper_bound, use_logistic and use_log. Note that use_logistic and use_log should not both be TRUE. Optimisation direction should be -1 or 1 depending on if we are maximising negative or positive log likelihood. This should be -1 for optim, and +1 for MCMC (-1 for minimisation and +1 for maximisation).

Usage

1
2
likelihood_norm(params, data, param_table = NULL,
  optimisation_direction = -1, MODEL_FUNCTION, ...)

Arguments

params

vector of parameters (ie. theta) for which likelihood is to be evaluated

data

matrix or data frame of the data under evaluation. The first column should be a set of time points, whereas the second column is the values at these times

param_table

optional table to accompany the parameters, specifying options such as log or logistic transformation

optimisation_direction

numeric value taking +1 or -1 to specify whether returned value is a negative or positive log likelihood

MODEL_FUNCTION

a function pointer for the model function that will be used to evaluated the model with the given set of parameters

...

any additional arguments that are required by the model function

Value

returns a numeric value of the total log likelihood of the give set of parameters for the data

Examples

1
2
3
4
5
6
params <- c(2,2)
data <- data.frame(t=seq(1,100,by=1),y=rnorm(100,1,1))
parameter_table <- NULL
optim_direction <- 1
model_function <- rnorm
nll <- llikelihood_norm(params,data,parameter_table,optim_direction,rnorm)

jameshay218/mcmcJH documentation built on May 18, 2019, 11:20 a.m.