@(@\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
.
Simulation the Posterior Distribution for Random Effects
Purpose
This routine draws samples from
the asymptotic posterior distribution for the
random effects given the model, the data, and the fixed effects; see
sparse observed information
.
manage_gsl_rng
It is assumed that
get_gsl_rng
will return
a pointer to a GSL random number generator.
mixed_object
We use mixed_object
to denote an object of a class that is
derived from the cppad_mixed base class.
sample
This argument has prototype
CppAD::vector<double>& sample
and its size is a multiple of
n_random
.
The input value of its elements does not matter.
We define
n_sample = sample_size / n_random
If
error_msg
is empty, upon return
for
i = 0 , ..., n_sample-1
,
j = 0 , ..., n_random-1
,
sample[ i * n_random + j ]
is the j-th component of the i-th sample of the
optimal random effects.
The statistics of these samples is specified under
covariance
below.
random_ipopt_options
This argument has prototype
const std::string& random_ipopt_options
and is the ipopt_options
for optimizing the random effects.
random_lower
This argument must have size equal to
n_random
and
specifies the lower limits for the optimization of the
random effects
vector @(@
u
@)@.
The value minus infinity can be used to specify no lower limit.
random_upper
This argument must have size equal to
n_random
and
specifies the upper limits for the optimization of the random effect.
The value plus infinity can be used to specify no lower limit.
random_in
This argument must have size equal to
n_random
and
specifies the initial value used for the optimization of the
random effects
vector @(@
u
@)@.
It must hold that
random_lower[i] <= random_in[i] <= random_upper[i]
for each valid index
i
.
Covariance
Each sample of the random effects is an independent normal.
The mean for this distribution is the
optimal random effects
@(@
\hat{u} ( \theta )
@)@.
The variance of this distribution
is the inverse of the observed information
matrix; i.e.
@[@
f_{uu} [ \theta , \hat{u} ( \theta ) ] ^{-1}
@]@
This normal distribution is censored to be within the limits
random_lower
,
random_upper
.
error_msg
If
error_msg
is empty (non-empty),
sample
values have been calculated (have not been calculated).
If
error_msg
is non-empty,
it is a message describing the problem.
Example
The file sample_random.cpp
is an example
and test of sample_random.
Input File: src/sample_random.cpp