- When you rerun the estimation with the best lags (as part of the show command), make sure you use the correct estimation specification.
- It appears that you want to determine the best set of lags for each of the 28 different equations, so you need to think about you're initializing the variables that store the best parameters, e.g., !aic. Think about what happens when !i changes from 1 to 2.
ERRORHELP
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Matt
- EViews Developer
- Posts: 585
- Joined: Thu Apr 25, 2013 7:48 pm
Re: ERRORHELP
Your code is getting closer to what you want. Here are two more tips:
Re: ERRORHELP
FOLLOW NEXT
Last edited by adarshad on Tue Nov 13, 2018 9:00 am, edited 1 time in total.
Re: ERRORHELP
after running the program, i found out that program is not running after loop 12 OR AFTER equation 12
i DONT KNOW WHY IS
The program is selecting multiple lags till eq 12 but afterwards it has same specification
thaks if anyone can solve it is this problem with package? why its not working beyond loop 13 TO LOOP 28
i DONT KNOW WHY IS
Code: Select all
matrix(4,28) pv
matrix(4,28) coef
matrix(4,28) tstat
matrix(28,15) RESULTS
vector(28) r2s
vector(28) aic
vector(28) rbar
!aic = 99999999
!maxlags = 4
!bestlag_a = 0
!bestlag_b = 0
for !i=1 to 28
for !lag_a = 0 to !maxlags
for !lag_b = 0 to !maxlags
equation eq{!i}.ls Y{!i} c X{!i}A(0 to -!lag_a) X{!i}B(0 to -!lag_b) Y{!i}(-1)
if eq{!i}.@aic < !aic then
!bestlag_a =(!lag_a) 'if this lag specification has the best AIC, then store this lag as !bestlag.
!bestlag_b =(!lag_b)
!aic= eq!i.@aic
endif
show eq{!i}.ls Y{!i} c X{!i}A(-!bestlag_a) X{!i}B(-!bestlag_b ) Y{!i}(-1)
colplace(pv, eq!i.@pval, !i)
colplace(coef, eq!i.@coef, !i)
colplace(tstat, eq!i.@tstats, !i)
r2s(!i) = eq!i.@r2
aic(!i) = eq!i.@aic
rbar(!i) = eq!i.@rbar2thaks if anyone can solve it is this problem with package? why its not working beyond loop 13 TO LOOP 28
-
EViews Matt
- EViews Developer
- Posts: 585
- Joined: Thu Apr 25, 2013 7:48 pm
Re: ERRORHELP
The issue is actually occurring earlier in your program, eq4 doesn't have the best lag chosen correctly either. The reason is hinted at in the second bullet point of my previous post. More specifically, what will your program do if the best AIC for an equation is worse (larger) then the best AIC for the previous equation? That's the case between eq3 and eq4, as well as later equations.
Re: ERRORHELP
it means do i need to initialise differrently? you mean that with every loop !aic value should be refreshed like resample=99999 OR USE !rescale=9999 and !redo like code
Re: ERRORHELP
ITS still not working ;;; i tried by reassigning value;;should i resample all or what;;;can you finally end it
-
EViews Matt
- EViews Developer
- Posts: 585
- Joined: Thu Apr 25, 2013 7:48 pm
Re: ERRORHELP
Moving where you initialize !aic to just inside the !i loop should be sufficient.
Re: ERRORHELP
Code: Select all
matrix(4,28) pv
matrix(4,28) coef
matrix(4,28) tstat
matrix(28,15) RESULTS
vector(28) r2s
vector(28) aic
vector(28) rbar
!maxlags = 4
!bestlag_a = 0
!bestlag_b = 0
for !i=1 to 28
!pval_a = 99999999
!pval_b = 99999999
for !lag_a = 0 to !maxlags
for !lag_b = 0 to !maxlags
equation eq{!i}.ls Y{!i} c X{!i}A(0 to -!lag_a) X{!i}B(0 to -!lag_b) Y{!i}(-1)
if eq{!i}.@pval(2) <!pval_a and eq{!i}.@pval(3) <!pval_b then ', SELECT EQUATION IF XA AND XB HAS LEAST PV
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b) ', then store this lag as !bestlag.
endif
show eq{!i}.ls Y{!i} c X{!i}A(-!bestlag_a) X{!i}B(-!bestlag_b ) Y{!i}(-1)
colplace(pv, eq!i.@pval, !i)
colplace(coef, eq!i.@coef, !i)
colplace(tstat, eq!i.@tstats, !i)
r2s(!i) = eq!i.@r2
aic(!i) = eq!i.@aic
rbar(!i) = eq!i.@rbar2
matrix PVALUE = @transpose(pv)
matrix coefs = @transpose(coef)
matrix tstats = @transpose(tstat)
results.setwidth 25
matplace(results,PVALUE,1,1)
matplace(results,coefs,1,5)
matplace(RESULTS,tstats,1,9)
colplace(RESULTS,R2S,13)
colplace(RESULTS,AIC,14)
colplace(RESULTS,RBAR,15)
SHOW RESULTS
NEXT
next
next
can you change an idea little bit o make it prfect o i have follow some else streaM.
ITS FINALLY CONCLUSION OF MY PROJECT
-
EViews Matt
- EViews Developer
- Posts: 585
- Joined: Thu Apr 25, 2013 7:48 pm
Re: ERRORHELP
You can test your code by manually determining which lags should be selected (at least for part of your dataset) and comparing that expectation to the results of your program. That said, just looking at your code I notice that you may not have considered what to do if there isn't a "best" combination of lags. Now that you're minimizing two numbers (p-values), it's possible that there isn't a pair of p-values that is better than all the rest. For example, imagine that there were only four combinations of lags being testing for some equation and the resulting pairs of p-values were (.4, .02), (.05, .01), (.03, .015), and (.008, .02). If you look closely, none of those pairs is better than all the others. So which are you going to select?
Re: ERRORHELP
yep i realised, it didnot select any lags at all.now i have proposed a differrent set of problem set and conditions
these are
first case : it stores pv(1) and pv(2) values WITH both PV <0.1
second case:IF there are many pairs of the condition that BOTH ARE pv< 0.1 ,then CHOOSES with least value of aic
third CASE: it get only one pv value for one variable only having PV <0.1
fouRth case: IF THERE ARE MANY CASES CHOSES ONE WITH LEAST AIC
fifh CASE: there is a case that one or both at same time have NO values less than 0.1 then it should also display equation having WITH LOWEST AIC
i have tried coding BUT AFTER WRITING IT STILL? IT DOESNOT EXECUTES CORRECTLY AS IT ENDS WITH MAXIMUM LAG COMBINATION AND NO SEELCTION IS MADE;
CAN SOMEONE CHECK THE CODE FOR ME
IF ANYONE CAN HELP ME..IT WOULD BE GREAT;;;THANKS FOR YOUR CONSIDERATION
these are
first case : it stores pv(1) and pv(2) values WITH both PV <0.1
second case:IF there are many pairs of the condition that BOTH ARE pv< 0.1 ,then CHOOSES with least value of aic
third CASE: it get only one pv value for one variable only having PV <0.1
fouRth case: IF THERE ARE MANY CASES CHOSES ONE WITH LEAST AIC
fifh CASE: there is a case that one or both at same time have NO values less than 0.1 then it should also display equation having WITH LOWEST AIC
i have tried coding BUT AFTER WRITING IT STILL? IT DOESNOT EXECUTES CORRECTLY AS IT ENDS WITH MAXIMUM LAG COMBINATION AND NO SEELCTION IS MADE;
CAN SOMEONE CHECK THE CODE FOR ME
Code: Select all
matrix(4,28) pv
matrix(4,28) coef
matrix(4,28) tstat
matrix(28,15) RESULTS
vector(28) r2s
vector(28) aic
vector(28) rbar
!maxlags = 4
!bestlag_a = 0
!bestlag_b = 0
for !i=1 to 28
!aic = 99999999
!pval_a = 99999999
!pval_b = 99999999
!pval_C = 0.1
!pval_D = 0.1
for !lag_a = 0 to !maxlags
for !lag_b = 0 to !maxlags
equation eq{!i}.ls Y{!i} c X{!i}A(0 to -!lag_a) X{!i}B(0 to -!lag_b) Y{!i}(-1)
if eq{!i}.@pval(2) <!pval_C and eq{!i}.@pval(3) <!pval_D AND eq{!i}.@aic < !aic then ', SELECT EQUATION IF XA AND XB HAS PV LESS THAN 0.1 AND if it has many pairs of pv<0.1 THEN SELECT PAIR WITH MINIMUM AIC
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b)
', then store this lag as !bestlag.
ELSE IF eq{!i}.@pval(2) <!pval_C OR eq{!i}.@pval(3)<!pval_D AND eq{!i}.@aic < !aic THEN ', SELECT EQUATION IF XA OR XB HAS PV LESS THAN 0.1
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b) ', then store this lag as !bestlag.
ELSE IF eq{!i}.@aic < !aic THEN ', SELECT EQUATION IF MINIMUM AC
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b) ', then store this lag as !bestlag.
endif
ENDIF
ENDIF
show eq{!i}.ls Y{!i} c X{!i}A(-!bestlag_a) X{!i}B(-!bestlag_b ) Y{!i}(-1)
colplace(pv, eq!i.@pval, !i)
colplace(coef, eq!i.@coef, !i)
colplace(tstat, eq!i.@tstats, !i)
r2s(!i) = eq!i.@r2
aic(!i) = eq!i.@aic
rbar(!i) = eq!i.@rbar2
matrix PVALUE = @transpose(pv)
matrix coefs = @transpose(coef)
matrix tstats = @transpose(tstat)
results.setwidth 25
matplace(results,PVALUE,1,1)
matplace(results,coefs,1,5)
matplace(RESULTS,tstats,1,9)
colplace(RESULTS,R2S,13)
colplace(RESULTS,AIC,14)
colplace(RESULTS,RBAR,15)
SHOW RESULTS
NEXT
next
next
IF ANYONE CAN HELP ME..IT WOULD BE GREAT;;;THANKS FOR YOUR CONSIDERATION
Re: ERRORHELP
can somebody help me;;i have done the code but still my code is not working especially for first if loop;;help me redesign it..
THIS IS ANOTHER PROPOSAL FOR SAME PROGRAM BUT I DONT KNOW
Code: Select all
matrix(4,28) pv
matrix(4,28) coef
matrix(4,28) tstat
matrix(28,15) RESULTS
vector(28) r2s
vector(28) aic
vector(28) rbar
!maxlags =2
!bestlag_a = 0
!bestlag_b = 0
for !i=1 to 3
!aic_1 = 99999999
!aic_2 = 99999999
!aic_3 = 99999999
!pval_a = 99999999
!pval_b = 99999999
!pval_C = 0.1
!pval_D = 0.1
for !lag_a = 0 to !maxlags
for !lag_b = 0 to !maxlags
equation eq{!i}.ls Y{!i} c X{!i}A(0 to -!lag_a) X{!i}B(0 to -!lag_b) Y{!i}(-1)
if (eq{!i}.@pval(2) <=!pval_C AND eq{!i}.@pval(3) <=!pval_D AND eq{!i}.@aic <!aic_1 ) or ( eq{!i}.@pval(2) <=!pval_C AND eq{!i}.@pval(3) <=!pval_D ) then ', CHECKS IF THE PVALUES ARE LESS THAN 0.1 AND IF MANY PAIRS EXISTS SELECTS WITH BEST AI
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b)
else if [eq{!i}.@pval(2) <!pval_C or eq{!i}.@pval(3)<!pval_D ] or [{eq{!i}.@pval(2) <!pval_C OR eq{!i}.@pval(3)<!pval_D} and { eq{!i}.@aic <!aic_2 }] then ', SELECT EQUATION IF XA OR XB HAS PV LESS THAN 0.1 AND SELECT MINIMUM AIC EQUATION
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b)
else if eq{!i}.@aic < !aic_3 then
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b)
',
ENDIF
endif
endif
show eq{!i}.ls Y{!i} c X{!i}A(-!bestlag_a) X{!i}B(-!bestlag_b ) Y{!i}(-1)
colplace(pv, eq!i.@pval, !i)
colplace(coef, eq!i.@coef, !i)
colplace(tstat, eq!i.@tstats, !i)
r2s(!i) = eq!i.@r2
aic(!i) = eq!i.@aic
rbar(!i) = eq!i.@rbar2
matrix PVALUE = @transpose(pv)
matrix coefs = @transpose(coef)
matrix tstats = @transpose(tstat)
results.setwidth 25
matplace(results,PVALUE,1,1)
matplace(results,coefs,1,5)
matplace(RESULTS,tstats,1,9)
colplace(RESULTS,R2S,13)
colplace(RESULTS,AIC,14)
colplace(RESULTS,RBAR,15)
SHOW RESULTS
NEXT
next
nextTHIS IS ANOTHER PROPOSAL FOR SAME PROGRAM BUT I DONT KNOW
- Attachments
-
- pv3.prg
- (1.9 KiB) Downloaded 702 times
Last edited by adarshad on Fri Nov 30, 2018 11:15 am, edited 6 times in total.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: ERRORHELP
It is Thanksgiving. Don’t expect any responses for a couple of weeks from EViews staff.
Re: ERRORHELP
Sir i have described all the conditions and tried to solve it but for fist else condition , i donot know how to choose
[significant pv(2) or significant pv(3)] and if there are many choices for both , or one one for each , choose SOLUTION FOR lag value with minimum aic].
the code for this step is no executing. i cannot execute AND OR operator.pls help me in this regard
HERE !pval_C and !pval_D both are less than 0.1;
sir can you help me this expression. i want to select first lag combination that contains pv values less than 0.1;HOWEVER if program finds more than one solution , it should choose lag selection with least aic value. it is that if there is no one obvious solution can be selected , the expression should add aic min value criteria to execute.
furthermore my understanding is , if there is only one solution , automatically its aic value would be minimum.i donot know if i have written right code.it never runs or selects any solution
and simply loops into else if and writes the last lag combination of 4
but this code doesn't execute that.
i donot know and /or implementation problem it is facing
HOW CAN REWRITE OR SPLIT IT TO ACHIEVE THIS FUNCTIONALITY;
if anyone can help PLEASE
thanks
[significant pv(2) or significant pv(3)] and if there are many choices for both , or one one for each , choose SOLUTION FOR lag value with minimum aic].
the code for this step is no executing. i cannot execute AND OR operator.pls help me in this regard
Code: Select all
if eq{!i}.@pval(2) <!pval_C and eq{!i}.@pval(3) <!pval_D AND eq{!i}.@aic < !aic then ' SELECT EQUATION IF XA AND XB HAS PV LESS THAN 0.1 AND if it has many pairs of pv<0.1 THEN SELECT PAIR WITH MINIMUM AIC
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b)sir can you help me this expression. i want to select first lag combination that contains pv values less than 0.1;HOWEVER if program finds more than one solution , it should choose lag selection with least aic value. it is that if there is no one obvious solution can be selected , the expression should add aic min value criteria to execute.
furthermore my understanding is , if there is only one solution , automatically its aic value would be minimum.i donot know if i have written right code.it never runs or selects any solution
and simply loops into else if and writes the last lag combination of 4
but this code doesn't execute that.
i donot know and /or implementation problem it is facing
HOW CAN REWRITE OR SPLIT IT TO ACHIEVE THIS FUNCTIONALITY;
if anyone can help PLEASE
thanks
-
EViews Matt
- EViews Developer
- Posts: 585
- Joined: Thu Apr 25, 2013 7:48 pm
Re: ERRORHELP
Hello,
It appears that all you're missing is to update variable !aic when you find a new best AIC.
If !pval_C and !pval_D are initialized to 0.1, and !aic is initialized to something large, e.g., 99999999, then the above logic should record the combination of lags that minimize AIC and produce p-values less than 0.1. The only unhandled case is if no equation has both p-values less than 0.1.
Also, check your placement of the "next" lines. The code to record information from the best estimation shouldn't be performed until after the best lags have been determined.
It appears that all you're missing is to update variable !aic when you find a new best AIC.
Code: Select all
if eq{!i}.@pval(2) < !pval_C and eq{!i}.@pval(3) < !pval_D and eq{!i}.@aic < !aic then
!aic = eq{!i}.@aic
!bestlag_a = (!lag_a)
!bestlag_b = (!lag_b)
...
Also, check your placement of the "next" lines. The code to record information from the best estimation shouldn't be performed until after the best lags have been determined.
Re: ERRORHELP
Code: Select all
matrix(4,28) pv
matrix(4,28) coef
matrix(4,28) tstat
matrix(28,15) RESULTS
vector(28) r2s
vector(28) aic
vector(28) rbar
!maxlags = 4
!bestlag_a = 0
!bestlag_b = 0
for !i=1 to 28
!aic = 99999999
!pval_a = 99999999
!pval_b = 99999999
!pval_C = 0.1
!pval_D = 0.1
for !lag_a = 0 to !maxlags
for !lag_b = 0 to !maxlags
equation eq{!i}.ls Y{!i} c X{!i}A(0 to -!lag_a) X{!i}B(0 to -!lag_b) Y{!i}(-1)
if eq{!i}.@pval(2) < !pval_C and eq{!i}.@pval(3) < !pval_D and eq{!i}.@aic < !aic then
!aic = eq{!i}.@aic
!bestlag_a = (!lag_a)
!bestlag_b = (!lag_b)
', then store this lag as !bestlag.
ELSE IF( [ eq{!i}.@pval(2) <!pval_C AND eq{!i}.@aic < !aic OR eq{!i}.@pval(3)<!pval_D ] AND [eq{!i}.@aic < !aic] )THEN ', SELECT EQUATION IF XA OR XB HAS PV LESS THAN 0.1
!aic = eq{!i}.@aic
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b) ', then store this lag as !bestlag.
ELSE IF eq{!i}.@aic < !aic THEN ', SELECT EQUATION IF MINIMUM AC
!aic = eq{!i}.@aic
!bestlag_a =(!lag_a) ', then store this lag as !bestlag.
!bestlag_b =(!lag_b) ', then store this lag as !bestlag.
endif
ENDIF
ENDIF
show eq{!i}.ls Y{!i} c X{!i}A(-!bestlag_a) X{!i}B(-!bestlag_b ) Y{!i}(-1)
colplace(pv, eq!i.@pval, !i)
colplace(coef, eq!i.@coef, !i)
colplace(tstat, eq!i.@tstats, !i)
r2s(!i) = eq!i.@r2
aic(!i) = eq!i.@aic
rbar(!i) = eq!i.@rbar2
matrix PVALUE = @transpose(pv)
matrix coefs = @transpose(coef)
matrix tstats = @transpose(tstat)
results.setwidth 25
matplace(results,PVALUE,1,1)
matplace(results,coefs,1,5)
matplace(RESULTS,tstats,1,9)
colplace(RESULTS,R2S,13)
colplace(RESULTS,AIC,14)
colplace(RESULTS,RBAR,15)
SHOW RESULTS
NEXT
next
next
- Attachments
-
- dataloop.wf1
- (1.2 MiB) Downloaded 441 times
Who is online
Users browsing this forum: No registered users and 2 guests
