Problems with ADF-test and loops

For questions regarding programming in the EViews programming language.

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

Namazbai
Posts: 7
Joined: Thu Jan 09, 2014 12:56 pm

Problems with ADF-test and loops

Postby Namazbai » Mon Jan 13, 2014 2:03 am

Hi, dear Eviews team! I'm looking for a help, if it doesn't annoy you. I'm trying to write a program that will do these operations:
1) Get data from Excel that contains observations of gdp, unemployment, cpi and nx (net export);
2) make a mean test
3) after makes ADF-test

I can't use series.uroot(options) method at once, because this way needs set parameters - const, trend or none, but to choose one of them I need to make mean test.
So I tried this way:

Code: Select all

subroutine MeanTest(series v) scalar Tstat=(@mean(v)*@(sqr(@obs(v))/@stdev(v) ' calculating t-statistics for serie's mean if Tstat > 1.96 then text Non_Zero_Mean 'I couldn't make a messagebox like in VB.NET to show the result, so I just made a 'text object which name informs me about the result :( else text Zero_Mean endif endsub wfopen "C:\PATH" group Data gdp cpi unemp nx call MeanTest(gdp) gdp.uroot(adf,const,info=sic) .............................. call MeanTest(nx) nx.uroot(adf,const,info=sic)
So, I have following troubles:
1) How to extract the p-value of ADF-test? It must be a concrete number, not vector or matrix, only number to use it like a simple numeric variable. I need this value to make a desision about taking differencies, for example if p-value isn't significant I would add to code something like this: if p-value < 0.05 then take difference (pseudocod)
2) Second problem is making a loop that will make MeanTest and ADF test for all series. I don't want to recall "MeanTest" subroutine and repeat ADF-test for every serie of group. Is it possible to make a loop for this case? Is there a construction similar to foreach loop in C#? I can do simple loops, but I don't know how to make a counter for series. I'd like to write smth like pseudocode:

Code: Select all

foreach (serie Xn in group Data) call MeanTest(Xn) Xn.uroot(adf,const,info=sic)
3) And last question - which command allows to form a group without enumeration of variables. In future my data my change, so I'm looking for command that will create a group of series itself without my manual enumeration like group Data gdp cpi unemp nx.

I'm sorry guys if I annoy you with such simple questions and ugly codes( I'll be glad to get any kind of answer, thank you!

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

Re: Problems with ADF-test and loops

Postby EViews Gareth » Mon Jan 13, 2014 9:11 am

1) Freeze the output of the ADF test into a table, then extract the cell containing the p-value.

2)

Code: Select all

for !i=1 to group.@count %sn = group.@seriesname(!i) call meantest({%sn}) {%sn}.uroot next
3) I don't understand this question.

Namazbai
Posts: 7
Joined: Thu Jan 09, 2014 12:56 pm

Re: Problems with ADF-test and loops

Postby Namazbai » Mon Feb 10, 2014 11:01 pm

Thank you, Gareth for this clear answer! About the last question - I solved this problem, when I found that command " group * " creates a group containing all series from Excel database. So the last question is solved! Thank you! :D


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests