base_class

View page source

cppad_mixed: Public Declarations

These cppad_mixed class declarations are public . They are part of the user API and can be used by a derived class object mixed_object .

Cppad Mixed Types

The following Cppad Mixed types are extended into the cppad_mixed class:

    // scalar types
    typedef CppAD::mixed::a1_double      a1_double;
    // vector types
    typedef CppAD::mixed::s_vector       s_vector;
    typedef CppAD::mixed::d_vector       d_vector;
    typedef CppAD::mixed::a1_vector      a1_vector;
    // sparse types
    typedef CppAD::mixed::sparse_rc      sparse_rc;
    typedef CppAD::mixed::d_sparse_rcv   d_sparse_rcv;
    typedef CppAD::mixed::a1_sparse_rcv  a1_sparse_rcv;

User Defined Functions

The following are cppad_mixed pure virtual functions. Each one has a default definition that may be replaced by the user’s derived class:

ran_likelihood

This function is necessary if there are random effects in the model.

    virtual a1_vector ran_likelihood(
        const a1_vector& fixed_vec  ,
        const a1_vector& random_vec )
    {  return a1_vector(0); }

See ran_likelihood .

fix_likelihood

This function should be used if there is a prior on the fixed effects, or there is data that does not depend on the random effects.

    virtual a1_vector fix_likelihood(
        const a1_vector& fixed_vec )
    {  return a1_vector(0); }

See fix_likelihood .

fix_constraint

This function is used to define constraints that only depend on the fixed effects.

    virtual a1_vector fix_constraint(
        const a1_vector& fixed_vec )
    {  return a1_vector(0); }

See fix_constraint .

fatal_error

This routine displays an error message and then exits the program. Its default definition below can be replaced by a user definition. Note that if NDEBUG is not defined, this generates an assert, otherwise it exits.

    virtual void fatal_error(const std::string& error_message)
    {  std::cerr << "cppad_mixed error: " << error_message << std::endl;
        assert(false);
        exit(1);
    }

warning

This routine displays a warning message and then returns. Its default definition below can be replaced by a user definition.

    virtual void warning(const std::string& warning_message)
    {  std::cerr << "cppad_mixed warning: " << warning_message << std::endl;
    }

constructor

User Defined Class Derived From cppad_mixed.

    // BEGIN_CPPAD_MIXED_CTOR
    cppad_mixed(
        size_t               n_fixed       ,
        size_t               n_random      ,
        bool                 quasi_fixed   = false           ,
        bool                 bool_sparsity = false           ,
        const d_sparse_rcv&  A_rcv         = d_sparse_rcv()  ,
        bool                 trace_init    = false
    );
    // END_CPPAD_MIXED_CTOR

destructor

    virtual ~cppad_mixed(void);

initialize

Initialization After Constructor

    std::map<std::string, size_t> initialize(
        const d_vector&  fixed_vec   ,
        const d_vector&  random_vec
    );

optimize_random

Optimize Random Effects.

    d_vector optimize_random(
        const std::string& options      ,
        const d_vector&    fixed_vec    ,
        const d_vector&    random_lower ,
        const d_vector&    random_upper ,
        const d_vector&    random_in
    );

optimize_fixed

Optimize Fixed Effects.

    CppAD::mixed::fixed_solution optimize_fixed(
        const std::string& fixed_ipopt_options   ,
        const std::string& random_ipopt_options  ,
        const d_vector&    fixed_lower           ,
        const d_vector&    fixed_upper           ,
        const d_vector&    fix_constraint_lower  ,
        const d_vector&    fix_constraint_upper  ,
        const d_vector&    fixed_scale           ,
        const d_vector&    fixed_in              ,
        const d_vector&    random_lower          ,
        const d_vector&    random_upper          ,
        const d_vector&    random_in             ,
        const CppAD::mixed::warm_start_struct&  warm_start =
            CppAD::mixed::warm_start_struct()
    );

hes_fixed_obj

Compute the Hessian of The Fixed Effects Objective.

    d_sparse_rcv hes_fixed_obj(
        const d_vector& fixed_vec  ,
        const d_vector& random_opt
    );

hes_random_obj

Compute the Hessian of The Random Effects Objective.

    d_sparse_rcv hes_random_obj(
        const d_vector& fixed_vec  ,
        const d_vector& random_vec
    );

sample_fixed

Sample Posterior for Fixed Effects.

    std::string sample_fixed(
        d_vector&                            sample               ,
        const d_sparse_rcv&                  information_rcv      ,
        const CppAD::mixed::fixed_solution&  solution             ,
        const d_vector&                      fixed_lower          ,
        const d_vector&                      fixed_upper          ,
        double&                              rcond                ,
        double                               cov_factor = 1.0
    );
    std::string sample_fixed(
        d_vector&                            sample               ,
        const d_sparse_rcv&                  information_rcv      ,
        const CppAD::mixed::fixed_solution&  solution             ,
        const d_vector&                      fixed_lower          ,
        const d_vector&                      fixed_upper          )
    {  double rcond;
        return sample_fixed(
            sample, information_rcv, solution, fixed_lower, fixed_upper, rcond
        );
    }

sample_random

Simulation the Posterior Distribution for Random Effects.

    std::string sample_random(
        d_vector&            sample               ,
        const std::string&   random_ipopt_options ,
        const d_vector&      fixed_vec            ,
        const d_vector&      random_lower         ,
        const d_vector&      random_upper         ,
        const d_vector&      random_in            ,
        double               cov_factor = 1.0
    );

information_mat, Deprecated 2020-03-22

Compute the Observed Information For Fixed Effects.

    d_sparse_rcv information_mat(
        const CppAD::mixed::fixed_solution&  solution             ,
        const d_vector&                      random_opt
    );

Contents