⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cml.src

📁 GAUSS软件的CML模块
💻 SRC
📖 第 1 页 / 共 3 页
字号:
/*
** cml.src   CML - Maximum Likelihood Estimation with General
**                 Nonlinear Constraints on Parameters
**
** (C) Copyright 1994-1996  Aptech Systems, Inc.
** All Rights Reserved.
**
** This Software Product is PROPRIETARY SOURCE CODE OF APTECH
** SYSTEMS, INC.    This File Header must accompany all files using
** any portion, in whole or in part, of this Source Code.   In
** addition, the right to create such files is strictly limited by
** Section 2.A. of the GAUSS Applications License Agreement
** accompanying this Software Product.
**
** If you wish to distribute any portion of the proprietary Source
** Code, in whole or in part, you must first obtain written
** permission from Aptech Systems.
**
**-------------------**------------------**-------------------**-----------**
**-------------------**------------------**-------------------**-----------**
**
**   Written by Ronald Schoenberg
**
**        CONTENTS                                           LINE
**        --------                                           ----
**        CML procedure                                        39
**        Global Variables                                     89
**        Procedure For Computing Log-likelihood Function     470
**        Source Code                                         536
**
**        CMLPrt                                              644
**        CMLCLPrt                                            797
**        CMLTlimits                                          940
**
**-------------------**------------------**-------------------**-----------**
**-------------------**------------------**-------------------**-----------**
**
*****************************************************************************
**                          CML procedure                                  **
*****************************************************************************
**
**   FORMAT
**          { x,f,g,cov,retcode } = CML(dataset,vars,&fct,start)
**
**   INPUT
**
**    dataset - string containing name of GAUSS data set, or
**              name of data matrix stored in memory
**
**       vars - character vector of labels selected for analysis, or
**              numeric vector of column numbers in data set
**              of variables selected for analysis
**
**        fct - the name of a procedure that returns either
**              the log-likelihood for one observation or a vector of
**              log-likelihoods for a matrix of observations
**
**      start - a Kx1 vector of start values
**
**   OUTPUT
**          x - Kx1 vector, estimated parameters
**          f - scalar, function at minimum (mean log-likelihood)
**          g - Kx1 vector, gradient evaluated at x
**        cov - KxK matrix, covariance matrix of the parameters
**    retcode - scalar, return code:
**
**           0   normal convergence
**           1   forced exit
**           2   maximum number of iterations exceeded
**           3   function calculation failed
**           4   gradient calculation failed
**           5   Hessian calculation failed
**           6   line search failed
**           7   function cannot be evaluated at initial parameter values
**           8   error with gradient
**           9   error with constraints
**          10   secant update failed
**          11   maximum time exceeded
**          12   error with weights
**          13   quadratic program failed
**          20   Hessian failed to invert
**          34   data set could not be opened
**          99   termination condition unknown
**
**-------------------**------------------**-------------------**-----------**
**-------------------**------------------**-------------------**-----------**
**
*****************************************************************************
**                         Global Variables                                **
*****************************************************************************
**
** _cml_Options - character vector, specification of options.  This global
**                   permits setting various CML options in a single
**                   global using identifiers.  For example,
**
**                   _max_Options = { brent newton central file };
**
**                   sets the line search method to BRENT, the descent method
**                   to NEWTON, the numerical gradient method to central
**                   differences, and __OUTPUT = 1.
**
**                   Algorithms:          BFGS, DFP, NEWTON, BHHH
**                   Line Search:         ONE, STEPBT, HALF, BRENT, BHHHSTEP
**                   Covariance Matrix:   NOCOV, INFO, XPROD, HETCON
**                   Gradient method:     CENTRAL, FORWARD
**                   Output method:       NONE, FILE, SCREEN
**
**  ----- Constraints -----
**
**   _cml_A - MxK matrix, linear equality constraint coefficient matrix
**
**   _cml_B - Mx1 vector, linear equality constraint constant vector
**
**         These globals are used to specify linear equality constraints of
**         the following type:
**
**               _cml_A * X = _cml_B
**
**         where X is the Kx1 unknown parameter vector.
**
**   _cml_EqProc - scalar, pointer to a procedure that computes
**                    the nonlinear equality constraints.  For example,
**                    the statement:
**
**                          _cml_EqProc = &eqproc;
**
**                    tells CML that nonlinear equality constraints
**                    are to be placed on the parameters and where the
**                    procedure computing them is to be found.
**                      The procedure must have one input argument, the
**                    Kx1 vector of parameters, and one output argument,
**                    the Rx1 vector of computed constraints that are
**                    to be equal to zero.  For example, suppose that
**                    you wish to place the following constraint:
**
**                       P[1] * P[2] = P[3]
**
**                    The proc for this is:
**
**                         proc eqproc(p);
**                            retp(p[1]*p[2]-p[3]);
**                         endp;
**
**   _cml_EqJacobian - scalar, pointer to procedure computing the
**                   Jacobian of the nonlinear constraints with respect
**                   to each of the parameters.
**
**                        _cml_EqJacobian = &eqj;
**
**                   The procedure has one input argument, the Kx1 vector
**                   of parameters, and one output argument, the MxK vector
**                   of derivatives of the constraints with respect to the
**                   parameters.  For example, if the nonlinear equality
**                   constraint procedure was,
**
**                         proc eqproc(p);
**                            retp(p[1]*p[2]-p[3]);
**                         endp;
**
**                   then the Jacobian procedure would be,
**
**                         proc eqj(p);
**                             retp(p[2]~p[1]~-1);
**                         endp;
**
**
**   _cml_C - MxK matrix, linear inequality constraint coefficient matrix
**   _cml_D - Mx1 vector, linear inequality constraint constant vector
**
**         These globals are used to specify linear inequality constraints of
**         the following type:
**
**                _cml_C * X >= _cml_D
**
**         where X is the Kx1 unknown parameter vector.
**
**   _cml_IneqProc - scalar, pointer to a procedure that computes
**                      the nonlinear inequality constraints.  For example
**                      the statement:
**
**                            _cml_IneqProc = &ineqproc;
**
**                      tells CML that nonlinear equality constraints
**                      are to be placed on the parameters and where the
**                      procedure computing them is to be found.
**                        The procedure must have one input argument, the
**                      Kx1 vector of parameters, and one output argument,
**                      the Rx1 vector of computed constraints that are
**                      to be equal to zero.  For example, suppose that
**                      you wish to place the following constraint:
**
**                         P[1] * P[2] >= P[3]
**
**                      The proc for this is:
**
**                           proc ineqproc(p);
**                              retp(p[1]*[2]-p[3]);
**                           endp;
**
**   _cml_IneqJacobian - scalar, pointer to procedure computing the
**                   Jacobian of the nonlinear constraints with respect
**                   to each of the parameters.
**
**                        _cml_IneqJacobian = &ineqj;
**
**                   The procedure has one input argument, the Kx1 vector
**                   of parameters, and one output argument, the MxK vector
**                   of derivatives of the constraints with respect to the
**                   parameters.  For example, if the nonlinear equality
**                   constraint procedure was,
**
**                         proc ineqproc(p);
**                            retp(p[1]*p[2]-p[3]);
**                         endp;
**
**                   then the Jacobian procedure would be,
**
**                         proc ineqj(p);
**                             retp(p[2]~p[1]~-1);
**                         endp;
**
**   _cml_Bounds - Kx2 matrix, bounds on parameters.  The first column
**                    contains the lower bounds, and the second column the
**                    upper bounds.  If the bounds for all the coefficients
**                    are the same, a 1x2 matrix may be used.
**                       Default = { -1e256 1e256 }
**
**  _cml_Lagrange - vector, created using VPUT.  Contains the Lagrangean
**                     coefficients for the constraints as well as their
**                     covariance matrices, if computed.  They may be extracted
**                     with the VREAD command using the following strings:
**
**                  "lineq"    - Lagrangeans of linear equality constraints,
**                  "nlineq"   - Lagrangeans of nonlinear equality constraints
**                  "linineq"  - Lagrangeans of linear inequality constraints
**                  "nlinineq" - Lagrangeans of nonlinear inequality
**                               constraints
**                  "bounds"   - Lagrangeans of bounds
**                  "eqcov"    - covariance matrix of equality Lagrangeans
**                  "ineqcov"  - covariance matrix of inequality Lagrangeans
**
**            Whenever a constraint is active, its associated Lagrangean
**            will be nonzero.
**
**  ----- Descent ------
**
**   _cml_Algorithm  -  scalar, indicator for optimization method:
**                  = 1,   BFGS (Broyden, Fletcher, Goldfarb, Shanno)
**                  = 2,   DFP (Davidon, Fletcher, Powell)
**                  = 3,   NEWTON (Newton-Raphson)
**                  = 4,   BHHH
**
**  _cml_Switch - 3x1 vector, controls algorithm switching:
**
**            _cml_Switch[1] = algorithm number to switch to
**            _cml_Switch[2] = CML switches if functions changes less
**                             than this amoung
**            _cml_Switch[3] = CML switches if this number of iterations
**                             is exceeded.
**
**   _cml_Delta - scalar, floor for eigenvalues of Hessian in the NEWTON
**              algorithm. This will insure that the Hessian will be
**              positive definite.
**
**  ----- Line Search -----
**
**   _cml_LineSearch  - scalar, indicator determining line search method
**
**              = 1,  steplength = 1
**              = 2,  STEPBT  (default)
**              = 3,  HALF (step-halving)
**              = 4,  BRENT
**              = 5,  BHHHSTEP
**
**              Usually _cml_LineSearch = 2 will be best.  If the
**              optimization bogs down try setting _cml_Step = 1 or 4.
**              _cml_Step = 4 will generate slow iterations but faster
**              convergence and _cml_Step = 1 will generate fast
**              iterations but slower convergence.
**
**   _cml_MaxTry - scalar, maximum number of tries to find step length
**                      that produces a descent
**
**   _cml_Extrap - scalar, extrapolation constant in BRENT.
**
**   _cml_Interp - scalar, interpolation constant in BRENT.
**
**   _cml_UserSearch - scalar, if nonzero and if all other line search
**              methods fail CML will enter an interactive mode in which
**              the user can select a line search parameter.
**
**  ----- Covariance Matrix of Parameters -----
**
**   _cml_CovPar  -  scalar, type of covariance matrix of parameters,
**
**                = 0,  the inverse of the final information matrix from
**                      the optimization is returned in cov (default).
**
**                = 1,  the inverse of the Hessian is returned.
**
**                = 2,  the inverse of the cross-product of the first
**                      derivatives is returned.
**
**                = 3,  the quasi-maximum likelihood covariance matrix
**                      is returned.
**
**   _cml_XprodCov - KxK matrix, when _cml_CovPar is set to 3 the
**                      cross-product matrix covariance matrix of the
**                      parameters will be returned in _cml_XprodCov.
**
**   _cml_HessCov - KXK matrix, when _cml_CovPar is set to 3 the
**              information matrix covariance matrix of the parameters,
**              i.e., the inverse of the matrix of second order partial
**              derivatives of the log-likelihood by observations, will
**              be returned in _cml_HessCov.
**
**   _cml_FinalHess - KxK matrix, the Hessian used to compute the covariance
**              matrix of the parameters will be stored in _cml_FinalHess.
**              This will be most useful if the inversion of the hessian
**              fails, which is indicated when CML returns a
**              missing value for the covariance matrix of the
**              parameters.  An analysis of the Hessian stored in
**              _cml_FinalHess can then reveal the source of the linear
**              dependency responsible for the singularity.
**
**  ----- Gradients -----
**
**   _cml_GradMethod  - scalar, method for computing numerical gradient.
**                = 0, central difference
**                = 1, forward difference (default)
**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -