Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: recursive variable

From   ulio Glogowsky <>
Subject   st: recursive variable
Date   Fri, 31 Aug 2012 11:15:49 +0200

Dear Statalist,

I am trying to create two variables which are dependent on its lagged
values and on a lagged value of a second variable:

y = b1*y(t-1)+b2*x(t-1)+u
x = b1*x(t-1)+b2x(t-1)+u

I am familiar with the 'one variable solution' posted by Nick Cox, as
well as with the paper by Roger Newson's useful Stata Tip in Stata
Journal 4(4) 2004:

//tsset group time
//gen x = y
//replace x = constant * L.x

//gen x = y
//bysort group (time): replace x = constant * x[_n-1] if _n > 2

If anyone has an idea on how to do this with more than 1 variable, I
would be most grateful.

In addition I'm trying to generalize the solution to the 'variable lag
case'. For this purpose I would like to use coefficient vectors and

Illustrative Example
gen local `list' "y(t-1) x(t-1)"
B = (b1, b2)

replace y = B'* `list' +U

Would it be possible to multiply vectors with variable lists (e.g. in Mata?)?

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index