[R-SIG-Finance] Run tests Fama
Bastian Offermann
bastian2507hk at yahoo.co.uk
Fri Oct 31 06:14:36 CET 2008
Hello list,
is anyone of you familiar with Fama's run tests in his 1965 behaviour of
stock market prices dissertation? I am not quite sure if I understand
the concept of "runs" correctly. He says *"A run is defined as a
sequence of price changes of the same sign. For example, a plus run of
length i is a sequence of i consecutive positive price changes preceded
and followed by either negative or zero changes."* So far so good.
-1 +5 +6 + 7 -2
So, 5,6,7 should be a plus run of length 3. The total number of runs is
thus 1 plus, 0 minus, 0 unchanged.
From a different source I get the impression that the runs are counted
differently. E.g.
0,-10,1,1,-12,1,-10,-5,1,4,-4,1,0,-11,3,-12,-10,-1,0,1
13 runs. It does not really say how many of each, confusing me.
Any my code does not really match the result for the long vector. Thanks
for your input.
Regards
rsp500 <- c(0,-10,1,1,-12,1,-10,-5,1,4,-4,1,0,-11,3,-12,-10,-1,0,1)
rsp500 <- c(-1,5,6,7,-2)
pos <- rsp500[rsp500>0]
neg <- rsp500[rsp500<0]
m <- (length(rsp500)^2 + length(rsp500) - length(pos)^2 -
length(neg)^2)/length(rsp500) # no. of expected runs
runplus <- 0
runminus <- 0
runequal <- 0
i <- 1
while(i <(length(rsp500)-1)) {
if(rsp500[i+1] > 0 & rsp500[i] < 0) runplus
<- runplus + 1
if(rsp500[i+1] < 0 & rsp500[i] > 0) runminus
<- runminus + 1
if(rsp500[i+1] < 0 & rsp500[i] < 0 &
rsp500[i+1] == rsp500[i]) runequal <- runequal + 1
if(rsp500[i+1] > 0 & rsp500[i] > 0 &
rsp500[i+1] == rsp500[i]) runequal <- runequal + 1
i <- i + 1
}
More information about the R-SIG-Finance
mailing list