Prev Next

@(@\newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\W}[1]{ \; #1 \; }@)@This is cppad_mixed--20220519 documentation: Here is a link to its current documentation .
User Defined Random Likelihood Function

Syntax
mixed_object
Virtual Function
fixed_vec
random_vec
vec
     constant
     Default
Example

Syntax
vec = mixed_object.ran_likelihood(fixed_vecrandom_vec)

mixed_object
We use mixed_object to denote an object of a class that is derived from the cppad_mixed base class.

Virtual Function
The following virtual function may be implemented in the derived class:
     virtual CppAD::vector<a1_double> ran_likelihood(
          const CppAD::vector<a1_double>& 
fixed_vec  ,
          const CppAD::vector<a1_double>& 
random_vec
     )

fixed_vec
This argument has prototype
     const CppAD::vector<a1_double>& 
fixed_vec
It contains a value for the fixed effects vector.

random_vec
This argument has prototype
     const CppAD::vector<a1_double>& 
random_vec
It contains a value for the random effects vector.

vec
This result has prototype
     CppAD::vector<a1_double> 
vec
It is a negative log-density vector corresponding to the random likelihood f(theta, u) where @[@ f( \theta , u) = - \log [ \B{p}( y | \theta, u) \B{p} ( u | \theta ) ] @]@ The Laplace approximation only makes sense if this function is smooth; i.e,
     
vec.size() == 1

constant
Adding or subtracting a constant to vec[0] , that does not depend on the fixed effects @(@ \theta @)@ or the random effects @(@ u @)@, does not affect the optimal estimates for the fixed and random effects.

Default
The base class definition (default) for ran_likelihood returns an empty vector; i.e., vec.size() == 0 . This corresponds to the case where none of the data depends on the random effects; i.e., the data vector y is empty. In this case there random effects vector should also be empty.

Example
The file ran_likelihood.cpp contains an example of defining this virtual function.
Input File: src/ran_likelihood.omh