[R-SIG-Finance] Volatility subsample analysis

dondom dominik.sochin at gmail.com
Wed Dec 1 13:24:17 CET 2010


My problem is the following.  I have applied some filterrules on the SMI to
define points for investment and desinvestment (as in trend analysis). The
aim was to define when upwardstrends and downwardstrends took place.
Afterwards I calculated the volatility for the same dataset and calculated
the mean volatility for each trend (up and down). As expected I found that
uptrends have a lower volatility than downward trends. 
To get to my problem, I would like to analyse now the subsamples for each
trend to get a better insight of this phenomenon. The thing is that I have
now a vector for all upwardtrends and all downwardtrends (vup; vdown). They
look like this. 


vup <- c(0.1,0.2,0.3,0,0,0,0.01,-0.002,0,0,0,0,0,0,0.005,0.1,0.2,0)

Where zeros are placed a downward trend is observed and has to be left out
of the analysis.

This means that for a first subsample I would like to calculate the mean
only for 0.1,0.2 and 0.3. Then for 0.01, -0.002, then for 0.005,0.1,0.2, and
so on


The solution should apply itself to a changing composition of the vector
(because different filterrules are applied)

What I tried is to construct a vector of length vup, with a value 1 where
vup has a value. Then in a second step I wanted to change this vector so
that the first observations are with a 1 after with 2 and so on,... that
would have allowed me to apply the cut or split function in R. Explained in
numbers:

What I have:
x <- c(1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0) 

What I want:

y <- c(1,1,1,0,0,0,2,2,0,0,0,0,0,0,3,3,3,0)


As mentioned with "y" I could apply easily a cut or split function and then
calulate the subsample means.

This might be a very simple thing to do, or maybe a completely better
approach can be used.

Thanks in advance for your help
Dominik
-- 
View this message in context: http://r.789695.n4.nabble.com/Volatility-subsample-analysis-tp3067158p3067158.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list