Announcement

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

  • access to the full set of parameters of one single equation

    Dear Statalist,

    I have a simple question regarding how to get access to the full set of parameters that belong to one single equation. To exemplify, below there is a code that fits a two-equation model using -ml-. What I want to obtain is a row vector containing all of the parameters from the mu equation (3 regressors). Is there any direct way to obtain this using the name of the equation?

    I know that we can access to specific parameters using the following syntax: _b[mu:weight]. Unfortunately, I couldn't find a way to get access to the full set of parameters associated with the mu equation.

    Code:
    *** mynormal1_lf.ado ***
    Code:
    program mynormal1_lf
    version 11
    args lnfj mu sigma
    quietly replace `lnfj' = ln(normalden($ML_y1,`mu',`sigma'))
    end
    




    Code:
    *** runmynormal.do ***
    Code:
    . sysuse auto, clear 
    (1978 Automobile Data)
    
    . ml model lf mynormal1_lf (mu: mpg = weight displacement) (sigma:)
    
    . ml maximize
    
    initial:       log likelihood =     -<inf>  (could not be evaluated)
    feasible:      log likelihood = -10383.274
    rescale:       log likelihood = -292.89564
    rescale eq:    log likelihood = -238.45986
    Iteration 0:   log likelihood = -238.45986  (not concave)
    Iteration 1:   log likelihood = -225.48871  (not concave)
    Iteration 2:   log likelihood = -215.66715  
    Iteration 3:   log likelihood = -199.18204  
    Iteration 4:   log likelihood = -195.29955  
    Iteration 5:   log likelihood =    -195.24  
    Iteration 6:   log likelihood =  -195.2398  
    Iteration 7:   log likelihood =  -195.2398  
    
                                                    Number of obs     =         74
                                                    Wald chi2(2)      =     139.21
    Log likelihood =  -195.2398                     Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    mu           |
          weight |  -.0065671   .0011424    -5.75   0.000    -.0088061   -.0043281
    displacement |   .0052808   .0096674     0.55   0.585    -.0136671    .0242286
           _cons |   40.08452   1.978738    20.26   0.000     36.20627    43.96278
    -------------+----------------------------------------------------------------
    sigma        |
           _cons |   3.385282   .2782684    12.17   0.000     2.839886    3.930678
    ------------------------------------------------------------------------------
    
    . di _b[mu:weight]
    -.00656711
    



    Thanks in advance for your time.
    Álvaro

    Stata 16.1 MP
    Win10/Linux Mint 19.1
    https://alvarogutyerrez.github.io/

  • #2
    Estimation results are stored in e. So you just need to extract the desired vector (coefficients) or matrix (variances).

    Code:
    cap drop mynormal1_lf
    program mynormal1_lf
    version 11
    args lnfj mu sigma
    quietly replace `lnfj' = ln(normalden($ML_y1,`mu',`sigma'))
    end
    sysuse auto, clear
    ml model lf mynormal1_lf (mu: mpg = weight displacement) (sigma:)
    ml maximize
    mat mub = e(b)[1, "mu:"]
    mat muV= e(V)["mu:", "mu:"]
    Res.:

    Code:
    . mat l mub
    
    mu[1,3]
                  mu:           mu:           mu:
              weight  displacement         _cons
    y1    -.00656711     .00528078     40.084522
    
    
    
    . mat list muV
    
    symmetric muV[3,3]
                               mu:           mu:           mu:
                           weight  displacement         _cons
          mu:weight     1.305e-06
    mu:displacement    -9.883e-06     .00009346
           mu:_cons    -.00199045     .01140179      3.915406
    Last edited by Andrew Musau; Yesterday, 07:36.

    Comment


    • #3
      Thank you a lot Andrew Musau. I totally forgot that the e(b) matrix is labeled with equation names!

      Best regards,

      Álvaro
      Stata 16.1 MP
      Win10/Linux Mint 19.1
      https://alvarogutyerrez.github.io/

      Comment

      Working...
      X