# Tag Info

19

A stationary process is one where the mean and variance don't change over time. This is technically "second order stationarity" or "weak stationarity", but it is also commonly the meaning when seen in literature. In first order stationarity, the distribution of $(X_{t+1}, ..., X_{t+k})$ is the same as $(X_{1}, ..., X_{k})$ for all values of $(t, k)$. ...

10

There are a number of different tests that are generally used to compare samples to different distributions, such as Jarque-Bera, Anderson-Darling, and Kolmogorov–Smirnov (see this related question). In your case, with just the standard deviation and mean, there isn't a whole lot to say. You need to assume a distribution (e.g. normal). You would be able ...

9

The main problem in your code is this line: rowSums(coef(model) * frame[, -1]) I'm not sure exactly what is does, perhaps some matrix multiplication, but definitely not what you expect it to do. Try to replace it with manual multiplication spread <- frame[,1] - (coef(model)[1]*frame[,2] + coef(model)[2]*frame[,3] + coef(model)[3]*frame[,4] + ...

8

There are many different methods for this. Most people rely on a unit root test. Rmetrics has collected the most common unit root tests into the fUnitRoots package, which primarily provides a wrapper for Bernhard Pfaff's urca package. These include: Augmented Dickey–Fuller (ADF) test Elliott–Rothenberg–Stock test KPSS unit root test Phillips–Perron ...

6

A very excellent discussion of stationarity as it relates to trading can be found in Sherry's (Sherrys'?) Mathematics of Technical Analysis (poorly organized, but very useful book). As he puts it, if the price changes of a stock, etc., are stationary over a time period, the underlying rules generating the price changes are effectively unchanged. The ...

6

A process is defined here and is simply a collection of random variables indexed (in general) by time. Otherwise I know the concept stated by Shane under the name of "weak stationarity", strong stationary processes are those that have probability laws that do not evolve through time. More formally let $X_t$ be a given process, then let's call $P_X$ the ...

4

Simple...because you are interested in deviations from a metric, and not whether it deviates above or below. The very definition of volatility is a "measure of deviation". Squaring returns or using the absolute values just eases the calculation to arrive at a deviation measure. Otherwise volatility would have to be calculated in other ways as positive and ...

4

To simplify, consider the errors rather than the returns. The variance is effectively the average of the squared errors, while absolute deviation is the average of the absolute errors. So plotting the squared errors or absolute errors over time could give an indication of whether the variance or absolute deviation is constant over time. Since variance is ...

3

Here is a possible explanation. Consider $X_t \sim N(0,1)$ and $Y_t \sim N(1,1)$. Then $(X_t)_0^n$ and $(Y_t)_0^n$ are realizations from stationary time series and I would expect the null hypothesis of stationarity not to be rejected (compatibly with the size of your test). Instead, the sample $(Z_t)_1^{2n} = (X_1, \dots, X_n, Y_1, \dots, Y_n)$ is drawn from ...

3

@Sergey correctly identified the problem. The explanation is that coef(model) is a vector, frame is a data.frame, and element-by-element multiplication takes place in column-major order. The shorter vector (coef(model)) is recycled along the longer vector (each column in frame). For example: frame <- data.frame(V1=1:5) frame$V2 <- 2 frame$V3 <- ...

2

You should de-trend to whatever frequency scale you are testing. I.e. 1 min means de-trend 1 min data. Merely by moving to higher frequency data, you are eliminating much of the systematic bias present at higher scales -- as 1) you have many more samples to compare (minimizing standard error) 2) At smaller intervals, the drift component also shrinks ...

2

Yet another alternative are wavelet based tests. With comparable size, they often have higher power, especially for very near unit root alternatives. An example is here (free pre-print versions of this paper are available, too).

2

The tseries package has GARCH models. Here is some simple code: library(quantmod) library(tseries) getSymbols("MSFT") ret <- diff.xts(log(MSFT\$MSFT.Adjusted))[-1] arch_model <- garch(ret, order=c(0, 3)) garch_model <- garch(ret, order=c(3, 3)) plot(arch_model) plot(garch_model) ...

1

In answer to your question 2, you should detrend over the entire range of the back test period. The purpose of the detrending is to satisfy/create the null hypothesis for the boot strap test (it's not strictly necessary for the permutation test). This hypothesis is that the return from your strategy is zero. To create this zero null hypthesis you have to 1) ...

Only top voted, non community-wiki answers of a minimum length are eligible