Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata time-series awareness


From   "Schaffer, Mark E" <M.E.Schaffer@hw.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Mata time-series awareness
Date   Mon, 9 Nov 2009 12:36:12 -0000

Hi all.  I have a Mata programming question about time-series data.

The question in brief: what is the best way to work in Mata with lags of
different lengths that respect missing values, gaps in data and the
like?  Is there an alternative to passing Stata time series operators to
st_data() or st_view() as in the manual example, p. 758, st_data(.,
("gnp", "l.gnp"))?

In a litte more detail:

I have a Mata programming problem where I have to loop through all
possible lags.  If I go via Stata's time series operators, passing them
through st_data(), I am guaranteed to get the right lags etc.  But this
is unappealing and may be inefficient.  I would rather call st_data()
once at the beginning to create a Mata matrix, and then loop through
lags extracted from this matrix.  I don't see how I can do this easily,
however.  In particular, I am used to creating Mata matrices with
st_data() where I supply a "touse" select variable, so that missings are
not present in the Mata matrix.  This means, however, that adjacent rows
in the matrix are not necessarily adjacent time periods.

Is there a clever way to track missings/gaps using indices?  Or is Mata
more time-series-aware than I realise?  Or is passing Stata's
time-series operators to st_data() the way to go?

--Mark


-- 
Heriot-Watt University is a Scottish charity
registered under charity number SC000278.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index