Page 1 of 1
CCF and Q-stats
Posted: Tue Jun 30, 2009 1:29 pm
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
Re: CCF and Q-stats
Posted: Tue Jun 30, 2009 8:14 pm
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.
Re: CCF and Q-stats
Posted: Wed Jul 01, 2009 10:53 am
by MST
Thank you!
Re: CCF and Q-stats
Posted: Tue Oct 20, 2009 3:48 pm
by MST
Can someone please provide me with the code to get the standard errors of the cross correlation functions?
Thanks!
Re: CCF and Q-stats
Posted: Wed Oct 21, 2009 1:27 pm
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.
Re: CCF and Q-stats
Posted: Thu Oct 22, 2009 10:49 am
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
Re: CCF and Q-stats
Posted: Fri Oct 23, 2009 9:57 am
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.