Page 1 of 1

choosing lag value based on minimum aic for multiple regressors

Posted: Sat Oct 27, 2018 5:55 am
by adarshad
matrix(3,28) pv
matrix(3,28) coefs
matrix(3,28) tstats
vector(28) r2s
vector(28) aic
vector(28) rbar

'create empty equation to be used inside the loop
equation eq
!rowcounter=1

'variable to store the minimum AIC. Initialise it to a large number
!aic = 99999999

'variable saying how many lags to go up to
!maxlags = 5

'Variable to store the "best" number of lags
!bestlag = 0

'set sample to be the !maxlag'th value onwards
smpl @first+!maxlags @last
for !j=1 TO 28
eq.ls y!j X!jA X!jB c
for !i=1 to !maxlags
eq.ls y!j X!jA(1TO -!i) X!jB(1 TO -!i) c 'run regression of Y on a constant and lagged values UPTO MAX LAG of X1A AND X1B BOTH to the iTH lag.
if eq.@aic < !aic then
!bestlag = !i 'if this lag specification has the best AIC, then store this lag as !bestlag.

!aic = eq.@aic
!j= !bestlag
endif
next


colplace(coefs, eq!j.@coefs, !j)
colplace(tstats, eq!j.@tstats, !j)
r2s(!rowcounter) = eq!j.@r2
aic(!rowcounter) = eq!j.@aic
rbar(!rowcounter) = eq!j.@rbar2

!rowcounter = !rowcounter+1
matrix pvalue = @transpose(pv)
matrix coef = @transpose(coefs)
matrix tstat = @transpose(tstats)
next


i am writing this program to calculate aic for each x! regressors of y! .however it gives error.
i want program to run loop regression for respective yi to check for minimum aic for four lags of all respective xi(independent variables) by trying all possible combinations. the program should select equation having minimum aic and run the regression for respective yi .Then the loop runs again to perform same for yi=28 i.e 28 times and output selected regression results
But i think i couldnot do it for multiple regerros ON X SIDE.i want somebody to suggest , should i do rolling or i can do wit this type or someone can correct this

Re: choosing lag value based on minimum aic for multiple regressors

Posted: Sun Oct 28, 2018 4:48 am
by adarshad
help required

Re: choosing lag value based on minimum aic for multiple regressors

Posted: Sun Oct 28, 2018 5:25 am
by adarshad
the aim is to select every regression for y!, minimum aic value is computed by interchanging all possible values of lags of xa and xb and comparing them for maximum lags here.is it possible by this technique;or i have to devise rolling code.any idea or any suggestion

Re: choosing lag value based on minimum aic for multiple regressors

Posted: Mon Oct 29, 2018 9:32 am
by EViews Matt
Hello,

You can select a "best" lag by minimizing AIC. It appears you've already made sure to use the same sample size for all lag lengths, which is good. I did notice that you have two lines with equation specifications, "eq.ls y!j X!jA X!jB c" and "eq.ls y!j X!jA(1TO -!i) X!jB(1 TO -!i)", the first of which isn't being used for anything, so you can remove it. Also, in the lag specifications, do you mean "X!jA(-1TO -!i)" instead of "X!jA(1TO -!i)"?

Re: choosing lag value based on minimum aic for multiple regressors

Posted: Tue Oct 30, 2018 7:39 am
by adarshad
sir thanks for reply;;but can i compare five regerossors in one loop ;;i mean how can i interchange values between x1a, x1b, x1c , x1d;;;i dono know how to write loop for comparing so that it utilises values for all possible lags and for all x.i have tried but still i cannot capture minimum value impying all possible lag combinations and all multiple x regressors

Re: choosing lag value based on minimum aic for multiple regressors

Posted: Tue Oct 30, 2018 7:51 am
by EViews Gareth
As mentioned in your other posts, nobody is going to write your program for you. You have been given plenty of examples, with documentation, of similar operations. You need to read through those examples and the documentation, understand them, then attempt to write your own program. Randomly copy and pasting other programs together is not the same as understanding them and modifying them to your needs.