Skip to contents

This returns a function f(simulations), which maps simulation results to log(likelihood) values. The experiments are used implicitly; simulations is a list as returned by rgsl::r_gsl_odeiv2_outer().

Usage

logLikelihoodFunc(experiments, perExpLLF = NULL, simpleUserLLF = NULL)

Arguments

perExpLLF

(optional) a user supplied function with the interface perExpLLF(p,s,e), where p are the parameters, s are the simulations and e are the experiments (with data). Supply this function if some of your experiments need to be normalized by the other experiments (and other complex cases).

simpleUserLLF

(optional) a user supplied function that is used instead of the default sum of ((y-h)/stdv)^2 terms. The interface is: simpleUserLLF(y,h,stdv,name=NULL), where each of them is an N-M-matrix where N is the dimensionality of the model output and M the number of data time-points. Here, y is t(experiments[[i]]$data) and may contain NA values. This function should also accept an optional name argument (this is the name of the experiment this function is currently called for).

experiment

will be compared tp the simulation results

Value

llf(parMCMC), a closure (function) of the mcmc-variable: parMCMC; returns a scalar log-likelihood value. Alternatively, the user can define such a function: parMCMC -> log(Likelihood(parMCMC)), and use that during sampling. A test simulation of p: y <- simulate(p) will reveal which values the simulator produces. These values will be attached to p during sampling, as an attribute. mcmc_init will attach the same values for the initial Markov chain state. The log-likelihood function can use these attributes.