choosing lag value based on minimum aic for multiple regressors

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

adarshad
Posts: 101
Joined: Wed Sep 05, 2018 10:32 am

choosing lag value based on minimum aic for multiple regressors

Postby adarshad » Sat Oct 27, 2018 5:55 am

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

adarshad
Posts: 101
Joined: Wed Sep 05, 2018 10:32 am

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

Postby adarshad » Sun Oct 28, 2018 4:48 am

help required

adarshad
Posts: 101
Joined: Wed Sep 05, 2018 10:32 am

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

Postby adarshad » Sun Oct 28, 2018 5:25 am

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

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

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

Postby EViews Matt » Mon Oct 29, 2018 9:32 am

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)"?

adarshad
Posts: 101
Joined: Wed Sep 05, 2018 10:32 am

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

Postby adarshad » Tue Oct 30, 2018 7:39 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13305
Joined: Tue Sep 16, 2008 5:38 pm

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

Postby EViews Gareth » Tue Oct 30, 2018 7:51 am

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.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests