Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ​Moptimize and Multiple equation models- Can I "trick" Moptimize in this way?

    Hi

    I am trying to estimate a finite mixture model with multiple equations by maximum likelihood.
    I use Moptimize to find the optimum of the likelihood function.
    The model takes the following form

    equation parameters covariates # of parameters
    1 b1 X1 k1
    2 u1 l1
    3 b2 X2 k2
    4 u2 l2
    5 prob. associated with the u's

    The u's are actually mass-points (a serie of constants) related to their counterpart equations containing the b's.
    u1 are for example the mass-points for equation 1.


    Although the paremeters for the u's have no covariates they form one group of parameters (in terms of the logic of the model).
    Is it possible to treat this vector of parameters as an equation and to supply a fake matrice of
    covariates which has the same number of columns as the parameter vector in order to trick moptimize?
    Will it affect the way the numerical gradient and hessian are computed?
    I want to avoid to loop over all the elements of u1 in order to feed the initial values and supply u1
    once instead.

    I am thinking of the following code

    Code:
    u1 = ....  // initial values
    eq = 1
    moptimize_init_eq_cons(M,eq,"off")
    moptimize_init_eq_indepvars(M,eq,J(1,cols(u1),0))
    moptimize_init_eq_coefs(M,eq,u1)

    I use Stata 14.1 on Windows 2008 server.

    Best
    Christophe


  • #2
    An alternative would be something like
    Code:
    u1 = ....  // initial values
    moptimize_init_eq_n(M,cols(u1))
    moptimize_init_coefs(M,u1)
    While moptimize_init_coefs() is not documented, it is a convenience that we are using,
    so it will not be going away. We will try to get it documented in the future.

    Comment


    • #3
      Jeff
      Thanks for your tip. It seems to be quite useful. In my case I could avoid the loop by just passing the entire vector of paramaters and the total number of equations.

      I also tried to make a simple example which uses the approach I suggest and it seems to work.
      In my problem I want to mix equations wich have covariates with equations which just contain parameters not related to covariates.

      to be more precise I was thinking of something like
      Code:
      // pass the covariates x1 to equation 1
      eq = 1
      moptimize_init_eq_indepvars(M,eq,x1) // x1 is a matrix of covariates
      moptimize_init_eq_coefs(M,eq,J(1,cols(x1)+1,0))
      
      // pass the mass-points of equation 1 to equation 2
      u1 = ....  // initial values
      eq = 2
      moptimize_init_eq_cons(M,eq,"off")
      moptimize_init_eq_indepvars(M,eq,J(1,cols(u1),0))
      moptimize_init_eq_coefs(M,eq,u1)
      .


      Best
      Christophe

      Comment

      Working...
      X