CCF and Q-stats

Questions and discussions on Time Series Analysis
MST
Posts: 4
Joined: Mon Jun 01, 2009 11:06 am

CCF and Q-stats

Unread post by MST »

I am a new user trying to do a bivariate time series analysis, but my commands must be wrong because I keep getting an error message. I am trying to produce a cross-correlation function (with 5 lags) and Q-statistics for the residuals of two pre-whitened series. Any help would be greatly appreciated.

calendar 1960
allocate 2006:1
open data C:\Marie\Research\RAT_30 years later\DATA\RAT Data_nomiss.xls
data(format=xls, org=columns)
log actratio / lact
boxjenk(vcv, diffs=1, ma=2) lact / lactres
boxjenk(vcv, diffs=1, ma=1) robbery / robres
cross(qstats,corrs=rescorrs) robres lactres / 0 5
graph(style=bargraph,qstats, nodates,number=0,key=upright, $ header='cross-correlation - robres and lactres, $
hlabel='lag',max=1.0,min=-1.0) 1
# rescorrs
end
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: CCF and Q-stats

Unread post by TomDoan »

MST wrote:I am a new user trying to do a bivariate time series analysis, but my commands must be wrong because I keep getting an error message. I am trying to produce a cross-correlation function (with 5 lags) and Q-statistics for the residuals of two pre-whitened series. Any help would be greatly appreciated.

Code: Select all

calendar 1960 
allocate 2006:1
open data C:\Marie\Research\RAT_30 years later\DATA\RAT Data_nomiss.xls
data(format=xls, org=columns)
log actratio / lact
boxjenk(vcv, diffs=1, ma=2) lact / lactres
boxjenk(vcv, diffs=1, ma=1) robbery / robres
cross(qstats,corrs=rescorrs) robres lactres / 0 5
graph(style=bargraph,qstats, nodates,number=0,key=upright, $ header='cross-correlation - robres and lactres, $ 
hlabel='lag',max=1.0,min=-1.0) 1
# rescorrs
end
The $'s on the GRAPH instruction are supposed to be at the end of a line to signal a continuation to the next. So you need

Code: Select all

graph(style=bargraph,qstats, nodates,number=0,key=upright, $ 
 header='cross-correlation - robres and lactres', $ 
 hlabel='lag',max=1.0,min=-1.0) 1
(You're also missing a ' at the end of the header string)

Also, there's no need for the END at the end.
MST
Posts: 4
Joined: Mon Jun 01, 2009 11:06 am

Re: CCF and Q-stats

Unread post by MST »

Thank you!
MST
Posts: 4
Joined: Mon Jun 01, 2009 11:06 am

Re: CCF and Q-stats

Unread post by MST »

Can someone please provide me with the code to get the standard errors of the cross correlation functions?

Thanks!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: CCF and Q-stats

Unread post by TomDoan »

MST wrote:Can someone please provide me with the code to get the standard errors of the cross correlation functions?

Thanks!

Code: Select all

open data gas-furnace.txt
data(format=free,org=columns) 1 296 input output
cross(from=-10,to=10,results=cross) input output
*
compute cxynobs=%nobs
corr(number=10,results=xcorrs) input
corr(number=10,results=ycorrs) output
sstats 1 10 %if(t==1,1.0,2.0)*xcorrs*ycorrs>>sumcxy
compute stderr=sqrt(sumcxy/cxynobs)
The last five lines will do the simplified Bartlett calculation, which is done under the assumption that the cross correlations are zero, but the autocorrelations aren't. The sum of cx(i)cy(i) is theoretically over a range to infinity; I wrote this to cut off at the same number of lags as the cross correlations, but you might need to do more than that if the series are rather persistent. If the x and y series are non-stationary, the cross correlations don't have a well-behaved asymptotic distribution.
MST
Posts: 4
Joined: Mon Jun 01, 2009 11:06 am

Re: CCF and Q-stats

Unread post by MST »

Tom,
Thanks for your response. I am trying to get the CCF for two prewhitened series, as well as the standard errors, so that I can determine if the cross correlations are statistically significant. Here is what I have:

calendar 1960
allocate 2006:1
open data C:\Marie\Research\RAT_30 years later\DATA\RAT Data_nomiss.xls
data(format=xls, org=columns)
log actratio / lact
boxjenk(vcv, diffs=1, ma=2) lact / lactres
boxjenk(vcv, diffs=1, ma=1) robbery / robres
cross(qstats,corrs=rescorrs) robres lactres / 0 6
graph(style=bargraph,nodates,number=0,key=upright, $
header='cross-correlation - robres and lactres', $
hlabel='lag',max=1.0,min=-1.0) 1
# rescorrs
compute cxynobs=%nobs
corr(number=10,results=xcorrs) lactres
corr(number=10,results=ycorrs) robres
sstats 1 10 %if(t==1,1.0,2.0)*xcorrs*ycorrs>>sumcxy
compute stderr=sqrt(sumcxy/cxynobs)

Here is the error I am getting:

## OP3. This Instruction Does Not Have An Option RES
>>>>(number=10,results=<<<<

I can't seem to figure out how to get this to run. Thank you so much for your help with this.

MST
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: CCF and Q-stats

Unread post by TomDoan »

MST wrote: Here is the error I am getting:

## OP3. This Instruction Does Not Have An Option RES
>>>>(number=10,results=<<<<

I can't seem to figure out how to get this to run. Thank you so much for your help with this.

MST
Change "results" to "corrs". We changed quite a few option names with version 7 to make instructions more standard, but the old syntax will work as well.
Post Reply