Description Usage Arguments Details Value Examples
Takes in five parameters, and test whether there is causality between two variables.
1 |
x |
A vector represents a time sequence |
y |
A vector represents another sequence |
lag.max |
Max time lag |
alpha |
Significant level |
sampleTimes |
The times of permutation sample for second order test |
First order test is to test whether the ccfvalue is different from zero. Second Test is to test whether the ccfvalue satisfies the 3-sigma test
When pho < 0, it will return a sentence for no causality. When first order test is unsatisfied, it will return a sentence. When the second order test is unsatisfied, it will return a sentence and list of Q and sampleQ vector. When all the test is passed, it will return Q
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | data("BMData")
i=8
u<-BMData[[i]]$u
y<-BMData[[i]]$y
resultw<-testCCF(u,y,lag.max=97,alpha = 0.05,sampleTimes=10000)
resultq<-testCCF(u,y,lag.max=97,alpha = 0.05,sampleTimes=1000)
resultb<-testCCF(u,y,lag.max=97,alpha = 0.05,sampleTimes=100)
datab<-cbind(ccf=resultb[[2]],sampleTime=rep(100,100))
dataq<-cbind(ccf=resultq[[2]],sampleTime=rep(1000,1000))
dataw<-cbind(ccf=resultw[[2]],sampleTime=rep(10000,10000))
data<-rbind(datab,dataq,dataw)
data<-as.data.frame(data)
data$sampleTime<-as.factor(data$sampleTime)
library(plyr)
cdata <- ddply(data, "sampleTime", summarise, ccf.mean=mean(ccf),
ccf.3sigma=mean(ccf)+3*sd(ccf))
library(ggplot2)
ggplot(data) + geom_density(aes(x = ccf,
colour = sampleTime),
size=1)+labs(x=expression(paste("C"[pi],""^"CCF")))+
labs(y=expression(paste("p","(C"[pi],""^"CCF",")")))+
labs(title = "2nd order system")+
geom_vline(data=cdata, aes(xintercept=ccf.3sigma, colour=sampleTime),
linetype="dashed", size=1)+
geom_vline(aes(xintercept=result[[1]]),
linetype="dashed", size=1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.