## ERRORHELP

For questions regarding programming in the EViews programming language.

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

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

### Re: ERRORHELP

Code: Select all

`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. `

here i want to select either of the pv values less than 0.1 but having minimum AIC

IS CODE RIGHT ?

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

### Re: ERRORHELP

SECONDLY MY preference is to select values less than 0.1.it should do that and if there are any values than it choose less aic.because here i fear that it tries to make all three conditions true.i;e. if equation has less pvs but aic is greater than aic of a lag which has no pv less than required, it will return no value as no condition is true

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

### Re: ERRORHELP

There's an error because you've used [] brackets instead of () parentheses to indicate subexpressions.

The combined logic of those three if clauses effectively ignores the p-values. As long as the AIC of the equation is better than any previously seen, one of the three clause conditions will be true. What you also need is a way to record how many p-values (0, 1, or 2) must be less than 0.1 before you consider the AIC. For example, once you've found an equation with one of the p-values less than 0.1, then any future equation with no p-values less than 0.1 cannot be the best, regardless of whether its AIC is better or not (if I understand your requirements correctly). Similarly, once you've found an equation with two p-values less than 0.1, any future equations with one or no p-values less than 0.1 cannot be the best.

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

### Re: ERRORHELP

You got correct in last paragraph.my aim is to find pv less than 0.1 regardless of aic.
I still donot know how to execute it as it includes min aic in it.

Even if I just get two options.either it should select two pvalues less than 0.1 .if no then use aic min for all others .in case there are many pairs for two pv values less than 0.1, it should choose the pair with min ac of multiple solutions of pvs.

I think i donot account for multiple pv pairs less than 0.1 for my question, where i derived that it should look for min aic for lags combinations with pvs.

But instead it there also adds min aic as basic requirement which i donot want.

So solution is first choose min pv less than 0.1 .this is solution i want.if there are many, choose that pv which has min aic

If there are no min two pvs, it should choose min aic.

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

### Re: ERRORHELP

I HOPE YOU can help me in this case because i tried but i am not coming with a code.i want tow pvs less than 0.1 OR ANYTHING;I AM NOT ABLE TO FIT THE MIN AIC IN A RIGHT WAY IN CODE; I WANT IT TO USE ONLY IF THERE IS CONFLICT IN SOLUTION OR THERE IS NO SOLUTION;

please help me in that

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

### Re: ERRORHELP

Code: Select all

`matrix(5,28) pvmatrix(28,30) RESULTSvector(28) aic!maxlags = 4!bestlag_a = 0!bestlag_b = 0!bestlag_c = 0 for !i=1 to 2 !aic_1 = 99999999 !aic_2 = 99999999 !aic_3 = 99999999!pval_C = 0.1!pval_D = 0.1for !lag_a = 0 to !maxlags   for !lag_b = 0 to !maxlags   for !lag_c = 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) X{!i}C(0 to -!lag_c) IF ( eq{!i}.@pval(2) < !pval_C and eq{!i}.@pval(3) < !pval_D ) or (eq{!i}.@pval(2) < !pval_C and eq{!i}.@pval(3) < !pval_D  and eq{!i}.@aic < !aic_1 )THEN        !aic = eq{!i}.@aic   !bestlag_a = (!lag_a)   !bestlag_b = (!lag_b)   !bestlag_c = (!lag_c)ELSE IF  eq{!i}.@aic < !aic_2 THEN     !aic = eq{!i}.@aic   !bestlag_a = (!lag_a)   !bestlag_b = (!lag_b)   !bestlag_c = (!lag_c)ENDIFENDIFEQUATION eq{!i}.ls   Y{!i} c X{!i}A(-!bestlag_a  ) X{!i}B(-!bestlag_b  ) Y{!i}(-1) X{!i}C(-!bestlag_C) colplace(pv, eq!i.@pval, !i)aic(!i) = eq!i.@aicmatrix PVALUE = @transpose(pv)   results.setwidth 25matplace(results,PVALUE,1,1)colplace(RESULTS,AIC,21)SHOW RESULTSNEXTnext   nextNEXT`

just choose tco options but i dont know how to make skip calculations if pvs are found

i hope to see some help;;i tried all foul things i can imagine but could not;;if else while etc everything but cannot make any solution;;;;

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

### Re: ERRORHELP

You could explicitly record which of those three cases (0, 1, or 2 p-values < 0.1) you're in, and the logic to transition between them, but lets try a little numerical trick. Replace all of the if logic with,

Code: Select all

`!fake_aic = eq{!i}.@aic - 1000 * ((eq{!i}.@pval(2) < !pval_C) + (eq{!i}.@pval(3) < !pval_D))if !fake_aic < !aic then   !aic = !fake_aic   !bestlag_a = !lag_a   !bestlag_b = !lag_b   !bestlag_c = !lag_cendif`

The idea above is to create a score for the estimation, which I've called "fake_aic". The score is based on the AIC, but the score gets better as more p-values are less than the 0.1 threshold. If neither p-value is less then 0.1, then the score will just be the AIC. If only one p-value is less than 0.1, then the score will be the AIC - 1000, which will be better than all the possible scores for an estimation with no p-values less than 0.1. Similarly, if both p-values are less then 0.1, then the score will be AIC - 2000, which is better than all the possible scores for an estimation with one or no p-values less than 0.1. Defining the score this way allows you to preference more p-values less than 0.1 and use AIC as the tie-breaker.

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

### Re: ERRORHELP

Code: Select all

`Dependent Variable: Y1      Method: Least Squares      Date: 12/09/18   Time: 14:37   Sample (adjusted): 1/13/2013 12/31/2017   Included observations: 260 after adjustments                        Variable   Coefficient   Std. Error   t-Statistic   Prob.                          C   -0.001191   0.000306   -3.895746   0.0001X1A(-1)   5.54E-05   1.55E-05   3.563423   0.0004X1B(-1)   0.005620   0.003237   1.736433   0.0837Y1(-1)   -0.117793   0.056815   -2.073278   0.0392X1C(-1)   3.02E-12   1.28E-12   2.349282   0.0196                        R-squared   0.248544       Mean dependent var   0.001195Adjusted R-squared   0.236757       S.D. dependent var   0.002091S.E. of regression   0.001827       Akaike info criterion   -9.753117Sum squared resid   0.000851       Schwarz criterion   -9.684642Log likelihood   1272.905       Hannan-Quinn criter.   -9.725589F-statistic   21.08534       Durbin-Watson stat   1.793625Prob(F-statistic)   0.000000                                 `

For the max_lag=2 , the program misses out this combination and shows pvalues as only one less than 0.1 , as it should have selected this combination . if you can sort this out
test_program.prg
(1.27 KiB) Downloaded 25 times

dataprojct.wf1
(1.29 MiB) Downloaded 21 times
and its a small problem to be sorted out for this great achievement

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

### Re: ERRORHELP

That combination of lags isn't one that your program evaluates, so of course the program cannot identify it as the best. Take a close look at your primary estimation line, the line beginning with "equation eq{!i}.ls".

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

### Re: ERRORHELP

EViews Matt wrote:That combination of lags isn't one that your program evaluates, so of course the program cannot identify it as the best. Take a close look at your primary estimation line, the line beginning with "equation eq{!i}.ls".

i am trying but i couldn't understand what are you pointing at.can you make the correction?. as for my primary equation, it uses these combination of lags as y{i} in dependent value is fixed to -1 while else values range from 0 TO -2 ? AND THESE ARE ALL -1; i couldn't understand why its not possible? can you explain whats wrong in my primary line as it should estimate all lags from zero to -lag AND IF ITS WRONG , i guess even all previous estimations were wrong too.my idea was using zero(negative zero is just zero too) to negative two lags ; PLEASE elaborate and leet me whats wrong; your logic was absolute class; a true progammer

Code: Select all

` equation eq{!i}.ls Y{!i} c X{!i}A(-!lag_a) X{!i}B(-!lag_b) Y{!i}(-1) X{!i}C(-!lag_C)`

SHOULD I write primary estimation as above?

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

### Re: ERRORHELP

My point is that the estimates you're evaluating to find the best combination of lags (the "equation eq{!i}.ls" line) and the estimate you're using to record the results for the best combination (the "show eq{!i}.ls" line) do not match. In the former you use the "to" lag range operator, but in the latter you do not, so the results will not be the same. For example, if the best combination of lags was !bestlag_a = 1, !bestlag_b = 1, !bestlag_c = 2, that would have been determined by the estimation:

Code: Select all

`equation eq{!i}.ls Y{!i} c X{!i}A(0 to -1) X{!i}B(0 to -1) Y{!i}(-1) X{!i}C(0 to -2)`

Which is equivalent to:

Code: Select all

`equation eq{!i}.ls Y{!i} c X{!i}A(0) X{!i}A(-1) X{!i}B(0) X{!i}B(-1) Y{!i}(-1) X{!i}C(0) X{!i}C(-1) X{!i}C(-2)`

Buy you'd record the results for:

Code: Select all

`equation eq{!i}.ls Y{!i} c X{!i}A(-1) X{!i}B(-1) Y{!i}(-1) X{!i}C(-2)`

That last estimation is different than the preceding two. Choose whether you want to the lag ranges (0 to ...) or not, and be consistent in the way you perform your estimations.

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

### Re: ERRORHELP

sir i have cleared all your suggestions but finally one more thing .
can you help me to modify this code if either it calculates two pvalues jiontly successfully( if there are many options for two significant values, then picks the minimum aic solution) or else it
simply calculates results on the basis of minimum aic for a lagged equation. just two options.

is it possible to do that because it will help me to find consistent results and improved techniques.
just minor changes to this method i guess

can you help me for that

thanks

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

### Re: ERRORHELP

If I understand you correctly, you now want only two cases: 0 or 1 p-values < 0.1, and 2 p-values < 0.1, correct? A small change to the previous !fake_aic calculation can accomplish that.

Code: Select all

`!fake_aic = eq{!i}.@aic - 1000 * (eq{!i}.@pval(2) < !pval_C and eq{!i}.@pval(3) < !pval_D)`

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

### Re: ERRORHELP

I JUST WANT THAT EITHER IT SHOULD SELECT jiontly TWO significant PVALUES LeSS THAN 0.1

or secondly it should select all other on basis of minimum aic irrespective of any pvalue

so either two pvalues less than 0.1 JIONTLY (if more than one pair then selct pair with min aic)

or choose lag having minimum aic; so no preference for one significant pvalue

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

### Re: ERRORHELP

Okay, that's what my suggested change to !fake_aic should accomplish.

Return to “Programming”

### Who is online

Users browsing this forum: No registered users and 5 guests