# Tag Info

7

The clearest and most intuitive article I have seen so far is Kritzman et al., Regime Shifts: Implications for Dynamic Strategies in FAJ (May / June 2012) It not only shows how you can use HMM for financial modelling but it also goes through the actual estimation algorithm (Baum-Welch) step-by-step and even gives full MATLAB-code. From the abstract: ...

6

It only indicates that the null hypothesis of uncorrelated increments is violated. For the sake of simplicity, assume a time series is stationary. Then a sufficient statistic for arbitrary variance ratios is its covariance function. In general, a given deviation from the null can originate from different covariance functions, which in turn, entails that ...

5

I'm familiar with the library, but not with the way it is exported to R. Anyway: gearings are optional multipliers of the LIBOR fixing (some bonds might pay, for instance, 0.8 times the LIBOR) and spreads are the added spreads. In your case, the gearing is 1 and the spread is 0.0140 (that is, 140 bps; rates and spread must be expressed in decimal form). ...

5

It appears that you are re-running the regression with each new data point. Instead, you should use an update/online formula (see an excellent answer by the famous Dr. Huber at stats.se). You can find an implementation in the R package biglm. If it doesn't have all the features you need (no windowing out of old data) you can at least adapt it and use it ...

5

Systematic Investor also did a two part series implementation in R which is also quite helpful as he details the pitfalls too. Post One: http://systematicinvestor.wordpress.com/2012/11/01/regime-detection/ Part Two: http://systematicinvestor.wordpress.com/2012/11/15/regime-detection-pitfalls/

4

You want to set the parameter n.roll to the number of n.ahead, n.roll rolling forecasts you want. (The n.ahead parameter controls how many steps ahead you want to forecast for each roll date.) Thus by setting n.roll to a number almost equal to your sample size, and critically setting the out.sample parameter almost equal to your sample size, you're telling ...

4

I think an extremely interesting strand of research on this topic is represented by extensions of vine copulas with time-varying parameters. For vine copulas in general have a look at this site from the Technische Universität München: Vine Copula Models One of their research projects, which is the most relevant in this context, is:Time varying vine copula ...

3

For R see the following packages: http://cran.r-project.org/web/packages/quantmod/index.html http://cran.r-project.org/web/packages/highfrequency/index.html http://cran.r-project.org/web/packages/TFX/index.html http://cran.r-project.org/web/packages/IBrokers/index.html For a broader overview this might help: ...

3

Your spread does not look similar to the random walk. Many of the observations are the same as the previous observation. This means most of the first differences are zero, which is why the test indicates your series has a unit-root. The current value is very good at explaining what the next value will be.

3

You can create the data using the procedure described in the reference manual on pages 31 and 32. The necessary code is copied below: # The following code may be used to generate an empty data set, # which can then be filled with bond data: ISIN <- vector() MATURITYDATE <- vector() STARTDATE <- vector() COUPONRATE <- vector() PRICE <- ...

3

I don't know how to select ARMA lag length when doing ARMA-GARCH. Perhaps someone can edit it into this answer. For the univariate case you want rugarch package. If you're doing multivariate stuff you want rmgarch. The reason these are better than other packages is threefold; (i) Support for exogenous variables which I haven't seen in any other package, ...

2

Have a look at the following two papers, one from Chris Rogers and Liang Zhang where they introduce a model using HMM which captures stylized facts of financial returns. And the second where we extended this model to risk measures. Implementation in R is strait forward using ML as mentioned in the paper. ...

2

Is it worth it to learn R? Switching from C/C++ to R has increased my productivity and shrunk code line-counts for similar tasks by roughly an order of magnitude. To give a small flavor of why, consider one of the most common patterns of iteration over some collection, selection and action: declare iterator for collection for element in collection ...

2

A great example of kalman filtering is in the Kyle Model. I have attached a presentation on the application of R to the kalman filter in the Kyle Model. http://www.rinfinance.com/RinFinance2009/presentations/microstructure-tutorial.pdf Basically in the Kyle Model, a market maker finds the likelihood an asset is ending up at a certain price given that a ...

2

1.Is it correct, that the coefficients are now different to the coefficients of the arima output? It seems right that the ARMA coefficients are different. Indeed, in the second model, the GARCH component will capture fluctuations that the ARMA component will not have to capture, resulting in different ARMA parameter estimates. 2.This is the acf of ...

2

I believe all you need to cope is: A definition of cointegration from any statistics handbook, wikipedia or the like, An example code for the implementation in R, eg http://quanttrader.info/public/testForCoint.html that is often cited.

2

periodicity calls: p <- median(diff(.index(x))) if (is.na(p)) stop("can not calculate periodicity of 1 observation") p can be NA if x has 1 observation, or if you have missing values in your index (because there's no na.rm=TRUE in the median call. > xx <- xts(1:10, as.POSIXct(c(1:5,NA,7:10),origin='1970-01-01')) > periodicity(xx) Error in ...

2

Let's approximate the time to maturity to be 3 years and 10 months. Assume that coupon is paid on March 6 each year. Let face value $F=100$ and coupon $c=0.07375F$. Let the discount factor be $d(0,T)=e^{−r T}$ where $r=0.06535$. The price of the bond is ce^{−10/12 \bullet r}+ce^{−22/12 \bullet r}+ce^{−34/12 \bullet r}+(F+c)e^{−46/12 \bullet r}=103.24 \; ...

2

Assuming you already have a way to obtain hedge ratios and the like, your best available choice is probably blotter (used to be just quantstrat). You will find that it isn't necessarily oriented toward options. Generally for options backtesting, pros end up making their own or buying commercial software. There are tons of commercial providers, but I ...

2

of course you can use this test to elaborate on this matter. Basically this test measures the ratio of variance of series in period tn to n*variance of t preriod $\frac{Var(tn)}{nVar(t)}$ in short: constant ratio for random walk increasing for series with trend decreasing for mean reverting process, more decreasing (faster) - better mean reversion

1

fopen,fscan are in stdio.h but it looks like Ox has their own include file. For some reason it's commented out in garchOxModelling.ox, uncomment that line only. #include <oxstd.h> //#include <packages/gnudraw/gnudraw.h> I remember I had to change this line as well since I used a newer G@rch distro. It was /Garch42/ , I changed it to ...

1

The two eigenvectors are are ordered by maximum likelihood. The eigenvector is the cointegrating relationship and the weight is their coefficient, if they are used, in for example a VECM. To get the VECM-form, you need to to use the command cajorls()(restricted) or cajoorls()(unrestricted). The vec2var() gives you a level (undifferenced) representation of ...

1

This is definitely not a Kalman filter's issue: if you replace this line of code args <- eapply(env = env, FUN = function(x){ClCl(x)}) with this one args <- eapply(env = env, FUN = function(x){ClCl(x)})[Symbols] eapply() will keep the order of the original Yahoo query from quantmod. You can check and you will see each $\beta_{t}$ matches about ...

1

The standard answer to your question would be to do the maximum likelihood estimation. When you say "plug in $\sigma$" you can show that the sample estimate of $\sigma$ is actually the maximum likelihood estimate of $\sigma$ for the normal distribution. If I can assume that your data are IID then what you do is use your distribution with parameters ...

1

I would recommend using the Johansen-Procedure for determining the cointegration vector, the ca.jo-function from library(urca). After determining the cointegration rank, a normalized cointegration vector is produced by estimating a restricted VECM with the command cajorls().

1

I will start by saying that the paper that recommends the procedure is rather badly written, but since the issue is not of high difficulty I would dare to give a few hints that could suggest the answer. First of all, Michelle was trying to do this estimation of the VaR using a non-parametric procedure based on kernel estimation of the real density of the ...

1

Here is a example of fitting Garch on financial time series. Application for regime switching in trading. http://systematicinvestor.wordpress.com/2012/01/06/trading-using-garch-volatility-forecast/

1

I have written R code for some time-varying bivariate fat-tailed copula functions (ripped off Patton's Matlab code) and played around with various optimizers. You can then use Rsolnp, nloptr, alabama or DEoptim packages to find an optimisation solution. Here is some R code where I play around with different optimisation algorithms. Note that the data2.csv ...

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