Page 1 of 1

RE: AR process with missing lags

Posted: Fri Aug 05, 2011 12:17 am
by nvellodi
Hello,

I want to create a while loop, within which a variable is regressed on all possible permutations of itself lagged 4 times. Rather than writing these 16 combinations out separately, I'd like to write them in a form that uses only one regressor term, like:

Code: Select all

eq1.ls pi pi(1 2 3 4)
Clearly, for this example, I could write

Code: Select all

eq1.ls pi pi(to -4)
But how could I deal with this one...

Code: Select all

eq1.ls pi pi(1 2 4)
... without reverting to two separate regressor terms?

Thanks,

Nikhil

Re: RE: AR process with missing lags

Posted: Fri Aug 05, 2011 7:53 am
by EViews Gareth

Code: Select all

%lags = "" for %l 1 2 4 %lags = %lags + " pi(-" + %l + ")" next eq1.ls pi {%lags}
Or something along those lines.

Re: RE: AR process with missing lags

Posted: Sun Aug 07, 2011 6:00 pm
by nvellodi
Great, that did the trick.

However, I have a follow up question. I should outline my broader objective here, I guess. I'm trying to create a subroutine that performs a load of regressions, and takes as some inputs the lag parameters for the independent variables. As per before, I want a method that can call all possible permutations of up to 4 lags. Before your post, I tried to write something that would do it for the permutations that involved successive numbers (e.g. 1 2 3 4, 3 4, 1 2 etc) by writing something like:

Code: Select all

subroutine regress (matrix aics, series pi, series og, scalar x, scalar y) equation eq1.ls pi pi(1) og(-x to -y) aics(1,1) = @aic endsub
The routine is more complex, with more regressions, but you get the idea. Incidentally, this didn't work; the regressions were only performed for the xth lag. I don't get this, as when I run:

Code: Select all

equation eq1.ls pi pi(1) og(-1 to -4)
it worked fine.
Anyway, do you have any ideas how I could construct my subroutine to cover all possible permutations? I hope I'm making some sense. Failing this, is there a way of fixing my subroutine code above so that it works for the "consecutive" lags type?

Thanks, as ever,

Nikhil

Re: RE: AR process with missing lags

Posted: Mon Aug 08, 2011 10:02 am
by EViews Gareth

Code: Select all

subroutine regress(matrix aics, series pi, series og, scalar x, scalar y) equation eq1.ls pi pi(1) og(-{x} to -{y}) aics(1,1) = @aic endsub