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:
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:
When using the st_data() function instead of st_view(), it behaves nicely as expected in both cases:
Do you agree with me that the first example above is a bug?
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 | +-------------------------------------------------------------+
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 | +-------------------------------------------------------------+
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 | +-------------------------------------------------------------+
Comment