Announcement

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

  • Extract coefficients from a matrix

    Dear all,

    I estimate a model using the user-written command xtdpdqml. Then I stored the estimated coefficients within a matrix object:

    Code:
    . mat list bx
    
    bx[1,56]
            _model:     _model:     _model:     _model:     _model:     _model:
                LD.          D.          D.          D.          D.          D.
        investment        cash       cash2         mtb     eflocal  cs_eflocal
    y1   .43629807   .00364227   .02832072   .00336012   .00547717    -.007783
    
            _model:     _model:     _model:     _model:     _model:     _model:
                 D.          D.          D.          D.          D.          D.
             time2       time3       time4       time5       time6       time7
    y1   .01091878   .00735329   .00882722   .01316997   .01304237   .01639875
    
            _model:     _model:     _model:     _model:     _model:     _model:
                 D.          D.          D.          D.          D.          D.
             time8       time9      time10      time11      time12      time13
    y1   .01628743   .01894632   .00367786    .0142553   .02099019   .01901806
    
            _model:     _model:     _model:     _model:     _model:     _model:
                 D.          D.          D.          D.          D.          D.
            time14      time15      time16      time17      time18      time19
    y1   .01472434   .01633638   .01335646   .00845851   .01146143    .0138188
    
            _model:   _initobs:   _initobs:   _initobs:   _initobs:   _initobs:
                 D.          D.         FD.          D.         FD.          D.
            time20        cash        cash       cash2       cash2         mtb
    y1    .0086074   .00164603  -.04897719   .01524066  -.00358587   .00102967
    
          _initobs:   _initobs:   _initobs:   _initobs:   _initobs:   _initobs:
                FD.          D.         FD.          D.         FD.          D.
               mtb     eflocal     eflocal  cs_eflocal  cs_eflocal       time2
    y1  -.00057571   .00324671   .00191596  -.00575118   .00862258  -.00065353
    
          _initobs:   _initobs:   _initobs:   _initobs:   _initobs:   _initobs:
                 D.          D.          D.          D.          D.          D.
             time3       time4       time5       time6       time7       time8
    y1  -.00089422  -.00064182   .00525141    .0083503   .01099966   .01135225
    
          _initobs:   _initobs:   _initobs:   _initobs:   _initobs:   _initobs:
                 D.          D.          D.          D.          D.          D.
             time9      time10      time11      time12      time13      time14
    y1   .01294235    .0025812   .00548301   .00867464   .02117244    .0159787
    
          _initobs:   _initobs:   _initobs:   _initobs:   _initobs:   _initobs:
                 D.          D.          D.          D.          D.            
            time15      time16      time17      time18      time19       _cons
    y1   .01896074   .00993922   .00168838   .01026795   .00904553   -.0005388
    
          _sigma2e:     _omega:
                               
             _cons       _cons
    y1   .00075504   1.6351193
    I need to extract from the above matrix same specific coefficients, specifically those indicates as _model:D.cash and _model:D.cash2. I tried the following:

    Code:
    mat b1=beta[1,_b[_model:D.cash]]
    but the result is:

    Code:
    mat list b1
    
    symmetric b1[1,1]
        c1
    r1   .
    Do you have any hint about how to extract those coefficients?

    Thanks in advace.

    Dario

  • #2
    Code:
    help matrix extraction
    Your matrix is named "bx", so to extract an element from it:

    Code:
    mat b1= bx[1, "_model:D.cash"]
    or just referencing the row and column:

    Code:
    mat b1= bx[1, 2]
    Last edited by Andrew Musau; 14 Jul 2023, 07:49.

    Comment


    • #3
      Andrew Musau Thanks Andrew. You are right....I made confusion with the name of the matrix. Thanks a lot.

      Comment

      Working...
      X