Dofor function for Q tests

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
lsal0106

Dofor function for Q tests

Unread post by lsal0106 »

Hi everyone,

I was wondering if someone could assist me with the code to develop a dofor function in order to find the Q stats on the series in the file attached? I want to find the Q stats on each of the 19 series in the file, but I am lost as to how to do it. Apologies if this question seems ridiculously simple.

Thanks in advance.
Attachments
ONEYR.xls
(380 KiB) Downloaded 834 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Dofor function for Q tests

Unread post by TomDoan »

This would do it:

cal(d) 2007:12:14
data(format=xls,org=columns) 2007:12:14 2012:3:30 c1 c2 ... c17
dofor s = c1 to c17
corr(noprint,qstat,number=numberofcorrelations) s
disp %l(s) %qstat
end dofor s
lsal0106

Re: Dofor function for Q tests

Unread post by lsal0106 »

As we say in Australia, you are a legend mate! Thank You!
lsal0106

Re: Dofor function for Q tests

Unread post by lsal0106 »

Also I was just wondering, is there a way of finding the second moment Q-stat also? Would I have to use two doloop functions in order to find this? I have the following code supplementary to the above at the moment

dofor s = C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19
set s2 = (s**2)
corr(noprint,qstat,number=20) s2
disp 'Second moment Q(20) = ' %l(s2) %qstat 'p-value = ' #.######### %signif
end dofor

But the output prints the following;

The Error Occurred At Location 325, Line 3 of loop/block
## REG7. Variance is Zero
## REG7. Variance is Zero
The Error Occurred At Location 325, Line 3 of loop/block
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Dofor function for Q tests

Unread post by TomDoan »

lsal0106 wrote:Also I was just wondering, is there a way of finding the second moment Q-stat also? Would I have to use two doloop functions in order to find this? I have the following code supplementary to the above at the moment

dofor s = C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19
set s2 = (s**2)
corr(noprint,qstat,number=20) s2
disp 'Second moment Q(20) = ' %l(s2) %qstat 'p-value = ' #.######### %signif
end dofor

But the output prints the following;

The Error Occurred At Location 325, Line 3 of loop/block
## REG7. Variance is Zero
## REG7. Variance is Zero
The Error Occurred At Location 325, Line 3 of loop/block
You need to do

set s2 = s{0}**2

to get S treated as a reference to a series in the SET.
Post Reply