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

# Re: st: recursive variable

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: recursive variable Date Fri, 31 Aug 2012 11:01:42 +0100

```It's just a separate -replace- command for each variable.

Nick

On Fri, Aug 31, 2012 at 10:15 AM, ulio Glogowsky
<ulioglogowsky@gmail.com> wrote:
> 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
> lists:
>
> 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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```