Page 1 of 1

Storing significant AR coefficients

Posted: Mon Jul 07, 2014 2:41 am
by epeter
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!!

Re: Storing significant AR coefficients

Posted: Mon Jul 07, 2014 8:17 am
by EViews Gareth
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.

Re: Storing significant AR coefficients

Posted: Tue Jul 08, 2014 6:48 am
by epeter
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!

Re: Storing significant AR coefficients

Posted: Tue Jul 08, 2014 8:18 am
by EViews Gareth
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.