Storing significant AR coefficients

For questions regarding programming in the EViews programming language.

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

epeter
Posts: 16
Joined: Wed May 28, 2014 1:59 am

Storing significant AR coefficients

Postby epeter » Mon Jul 07, 2014 2:41 am

Hi everyone!
After running this simple regression, i would like to store the coefficients of those AR that are significant.
Here is the code:

Code: Select all

for !p = 1 to 6 if !p = 1 then %ar = "ar(1)" else %ar = %ar + "ar(" + @str(!p) + ")" endif equation eq{%name}_ar{!p}.ls {%name} c {%ar} next
Basically i would like to have a code "saying": "If AR(6) is significant (prob<0.05) then store its coefficient, ELSE check if AR(5) is significant then store its coefficient, ELSE check if AR(4) and so on..." :)) i hope you understood despite my poor english.

This is not the first time you help me, thank you very much for your support!!

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

Re: Storing significant AR coefficients

Postby EViews Gareth » Mon Jul 07, 2014 8:17 am

You'll just have to write a new for loop that loops through the coefficients one at a time, checking the p-value each time.

epeter
Posts: 16
Joined: Wed May 28, 2014 1:59 am

Re: Storing significant AR coefficients

Postby epeter » Tue Jul 08, 2014 6:48 am

Thank you Gareth!
Here is what i did:

Code: Select all

for !p = 1 to 6 if !p = 1 then %ar = "ar(1)" else %ar = %ar + "ar(" + @str(!p) + ")" endif matrix(1+!p, !i) coefs_ar!p equation eq_{%name}_ar{!p}.ls {%name} c {%ar} scalar pval= @tdist(eq_{%name}_ar{!p}.@tstat(!p), eq_{%name}_ar{!p}.@regobs - eq_{%name}_ar{!p}.@ncoefs) if pval<0.05 then colplace(coefs_ar!p, eq_{%name}_ar{!p}.@coefs, !i) endif next
The code, however, doesn't store the coefficients i was asking for, because it stores all the coefficients of the regression when there is a pvalue (in that regression) that is significant. However, i would like to have a code that specifically stores the coefficient (starting from the last one, so starting from AR6, then AR5...) when that coefficient is significant.
I hope you understood and i'm very sorry for my english.
Thanks a lot gareth!

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

Re: Storing significant AR coefficients

Postby EViews Gareth » Tue Jul 08, 2014 8:18 am

Rather than using colplace on eq.@coefs (which puts all coefficients from the equation), just put in the !pth coefficient. Something like:

Code: Select all

coefs_ar{!p}(1,1) = eq_{%name}_ar{!p}.@coef(!p)
You'll have to play around to insert it somewhere other than (1,1) element, probably.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest