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
}
Run tests Fama
3 messages · Bastian Offermann, Patrick Burns, Charles Ward
I would think that any difference in the details of the definition would be inconsequential. Something like: rle(sign(ret)) should do. Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User")
Bastian Offermann wrote:
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
}
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20081031/de826eb7/attachment.pl>