Announcement

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

  • Bug in Mata's st_view() function with time-series operators?

    I experienced an unexpected behavior of Mata's st_view() function. In the following, I want to obtain the first three observations of the variables w L.w k L.k in Mata. If I specify them as the varlist L(0/1).(w k), the function returns w w k k, without applying the lag operator:
    Code:
    . webuse abdata
    
    . mata: st_view(X=., (1::3), "L(0/1).(w k)")
    
    . mata: X
                      1              2              3              4
        +-------------------------------------------------------------+
      1 |   2.576543331    2.576543331   -.5286502242   -.5286502242  |
      2 |   2.509745598    2.509745598   -.4591824114   -.4591824114  |
      3 |   2.552526474    2.552526474   -.3899362981   -.3899362981  |
        +-------------------------------------------------------------+
    If instead I specify the varlist as L(0/1).w L(0/1).k, with lag operators separately for the two variables, I obtain the desired result:
    Code:
    . mata: st_view(X=., (1::3), "L(0/1).w L(0/1).k")
    
    . mata: X
                      1              2              3              4
        +-------------------------------------------------------------+
      1 |   2.576543331              .   -.5286502242              .  |
      2 |   2.509745598    2.576543331   -.4591824114   -.5286502242  |
      3 |   2.552526474    2.509745598   -.3899362981   -.4591824114  |
        +-------------------------------------------------------------+
    When using the st_data() function instead of st_view(), it behaves nicely as expected in both cases:
    Code:
    . mata: st_data((1::3), "L(0/1).(w k)")
                      1              2              3              4
        +-------------------------------------------------------------+
      1 |   2.576543331              .   -.5286502242              .  |
      2 |   2.509745598    2.576543331   -.4591824114   -.5286502242  |
      3 |   2.552526474    2.509745598   -.3899362981   -.4591824114  |
        +-------------------------------------------------------------+
    
    . mata: st_data((1::3), "L(0/1).w L(0/1).k")
                      1              2              3              4
        +-------------------------------------------------------------+
      1 |   2.576543331              .   -.5286502242              .  |
      2 |   2.509745598    2.576543331   -.4591824114   -.5286502242  |
      3 |   2.552526474    2.509745598   -.3899362981   -.4591824114  |
        +-------------------------------------------------------------+
    Do you agree with me that the first example above is a bug?
    https://twitter.com/Kripfganz

  • #2
    I agree that the documentation in the output of help mf_st_view says that the rowvector j (third argument of st_view()) may be specified in the same way as with st_data() (where it is the second argument). Having done that and gotten different results, I think this bears reporting to Stata Technical Services.

    Comment


    • #3
      I have reported it to Stata Technical Support. The Stata developers are now looking into it.
      https://twitter.com/Kripfganz

      Comment


      • #4
        To close this topic: The bug has been fixed with the 05aug2019 update in Stata 15.
        https://twitter.com/Kripfganz

        Comment

        Working...
        X