An open source programming language and software environment for statistical computing and graphics.

learn more… | top users | synonyms

34
votes
11answers
12k views

Switching from C++ to R - limitations/applications

I've only recently begun exploring and learning R (especially since Dirk recommended RStudio and a lot of people in here speak highly of R). I'm rather C(++) oriented, so it got me thinking - what are ...
18
votes
3answers
968 views

Tools in R for estimating time-varying copulas?

Are there libraries in R for estimating time-varying joint distributions via copulas? Hedibert Lopes has an excellent paper on the topic here. I know there is an existing packaged called copula but ...
15
votes
6answers
3k views

What tools exist for order book analysis and visualization?

What tools exist for order book analysis and visualization? In particular, if one wanted to examine a limit order book and understand how it changes throughout the day where would you turn for ...
11
votes
3answers
4k views

R: How feasible is it to store — and work with — tick data in a database connected to R?

I'm looking to convert some tickdata .csv files into a database on a local disk and then use R to call the data and do my various analytics and modelling. What are some best practices / ...
11
votes
2answers
3k views

How to derive the implied probability distribution from B-S volatilities?

The general problem I have is visualization of the implied distribution of returns of a currency pair. I usually use QQplots for historical returns, so for example versus the normal distribution: ...
10
votes
2answers
913 views

Simulating Returns

I'll start this off with a rather broad question: I am trying to simulate returns of a large number of assets within a portfolio of different classes - equity and fixed income in a first step, say 100 ...
10
votes
1answer
265 views

Is creating constrained random portfolios a hard problem?

Creating random portfolios with weights $x_i$ can be thought of as sampling from the surface of a simplex given by $$Ex = f$$ and $$Ax \le b$$ Where $E$ and $A$ are constraint matrices for equality ...
10
votes
1answer
286 views

A non parametric study of VaR with kernel density

I'm working in order to compare the calculation of the VaR between the methodology of copulas and kernel density, all this by using the software r. The process that I follow is: Obtain a sample ...
9
votes
1answer
399 views

Has any research used Bayesian networks to estimate risk factor betas?

Is there any published research on estimating the beta of a security with respect to one or more risk factors via Bayesian networks? I'd like to see if this is a promising angle of research.
8
votes
3answers
1k views

Hidden Markov Model & Its Application

I have started reading about HMM it gives an intuitive idea about what HMM is all about. I am looking out for example where its applied to Equity model using R / Excel. The material which I read so ...
8
votes
1answer
601 views

How to compute modified-CVaR in the PerformanceAnalytics package?

My objective is to measure the modified-CVAR for a portfolio given its weights and matrix of security returns. Luckily the wonderful package PerformanceAnalytics has an ES() function that does just ...
8
votes
1answer
203 views

rugarch: Joint estimation leads to different results

I want to fit an ARMA-GARCH model to my data using rugarch package in R. First of all, I look at the acf and pacf: ...
8
votes
2answers
293 views

GBM 3d plot with R

I want to plot the density of the GBM in a 3d plot. So I have on one axis the stock price, on the other the time and on the z axis the density. At the end I want to produce this graph. The formula I ...
7
votes
2answers
2k views

robust portfolio optimization re-balancing with transaction costs

The optimal re-balancing strategy takes account of factors including i) objective function, ii) current portfolio weights, iii) expected return vector containing updated views/alpha forecasts, iv) ...
7
votes
2answers
1k views

Is there a technique for using xts or zoo objects with options data (i.e., many entries per date) in R?

I am starting to work with options data from optionmetrics. I use data frames, but it seems like xts or zoo objects are the way to go for features and speed. I can't figure out the best work-around to ...
7
votes
3answers
1k views

R: Fast and efficient way of running a multivariate regression across a (really) large panel (First pass of Fama MacBeth)

I am attempting to run a rolling multivariate regression (14 explanatory variables) across a panel of 5000 stocks: For each of the 5000 stocks, I run 284 regressions (by rolling over my sample ...
7
votes
1answer
760 views

Why does the following data fail my cointegration test?

I have some closing price data for two Australian banks which track each other very closely. http://dl.dropbox.com/u/12337149/stat/CBA.csv http://dl.dropbox.com/u/12337149/stat/WBC.csv Code from ...
7
votes
0answers
656 views

Tools/R code for predicting Dragon-Kings

The theory of the so called Dragon-Kings, esp. by Didier Sornette (ETH Zürich), basically states that financial crises and crashes are predictable (contrary to the theory of black swans). The ...
6
votes
3answers
2k views

R code for Ornstein-Uhlenbeck process

Can any one help me with some R code to run Ornstein-Uhlenbeck process?
6
votes
1answer
995 views

Forecasting using rugarch package

I want to do one step ahead in-sample forecasts. My data can be found here. This is just a data frame with the date as the rownames. I specify my model and do the fit and show the plots with ...
6
votes
2answers
756 views

How do I replicate John Hussman's recession forecasting methodology?

John Hussman has a recession forecasting methodology he often posts about on his blog, and I am trying to replicate it using publicly available data. I would like to assess his accuracy in predicting ...
5
votes
3answers
6k views

Calculating log returns using R

I am trying to calculate the log returns of a dataset in R using the usual log differencing method. However, the calculated data is simply a vector of zeroes. I can't see what I'm doing wrong. Here ...
5
votes
2answers
2k views

Using variance ratios to test for mean reversion

Can you use the variance ratio test to determine whether or not a time series is mean reverting? I'm using the Lo.Mac function in the ...
5
votes
2answers
1k views

Quantmod: what's the difference between ROC(Cl(SPY)) and ClCl(SPY)

I feel like I'm missing something fundamental here, but I can't shake the feeling that these two series should be equivalent. /edit: there is also dailyReturn(Cl(SPY)). I've seen all 3 of these ...
5
votes
1answer
382 views

Are there any tools or useful algos for identifying corner portfolios?

Let's say I am performing mean-variance optimization subject to some weight constraints. I'd like to identify the set of corner portfolios so that I can interpolate the entire efficient frontier. A ...
5
votes
0answers
556 views

Alternative to Block Bootstrap for Multivariate Time Series

I currently use the following process for bootstrapping a multivariate time series in R: Determine block sizes - run the function b.star in the np package which produces a block size for each series ...
4
votes
2answers
602 views

Use Trades as Input for PerformanceAnalytics

I'd like to use the PerformanceAnalytics R package to view various metrics from a list of trades with profit values. From looking at the documentation from the PerformanceAnalytics package that most ...
4
votes
1answer
184 views

Definition of gearings, spreads and curve in RQuantLib's Floating Rate Bond function

Consider the RQuantLib package function FloatingRateBond(). This takes as inputs gearings ...
4
votes
1answer
307 views

analyze strategy performance with given matrix of weights/time and weekly returns in R

I have a matrix of 259 weekly returns, 50 assets and a portfolio composition for each of the 259 weeks. I would like to test the performance of the portfolio during 52 weeks, rebalancing every 12 ...
4
votes
1answer
593 views

Cointegrating relationships - Johansen in R

I read the posts, How to interpret results of Johansen Test? and How to interpret the eigenmatrix from a Johansen cointegration test? But still I am quite confused by the output. I have a project with ...
3
votes
2answers
1k views

GJR-GARCH Model In R

Any idea how to estimate GJR-GARCH models in R? Is there any particular library like fGarch that supports such models?
3
votes
2answers
5k views

How to fit ARMA+GARCH Model In R?

I am currently working on ARMA+GARCH model using R. I am looking out for example which explain step by step explanation for fitting this model in R. I have time series which is stationary and I am ...
3
votes
2answers
510 views

Using the termstrc package in R

I am attempting to use the function estim_nss from the termstrc package in R to find the spot curve from constant maturity rates published by the Fed. I am using this package because I will need to ...
3
votes
3answers
552 views

Generate tick data from candlestick

Is there software (or Python / R / ... scripts) to generate (pseudo) tick data from candlestick data. I have candlestick data (CSV format) from monthly timeframe (MN) to minute timeframe (M1) but ...
3
votes
1answer
7k views

How to interpret results of Johansen Test?

I have two time-series a & b. The objective is to find out whether two series are cointegrated or not. I am using Johansen Test in R to find this out. I am using urca package of R. Here is the ...
3
votes
1answer
412 views

How can I get intra-day prices via API into R?

I am able to retrieve prices for IVV using this code library(quantmod) getSymbols("IVV") names(IVV) [1] "IVV.Open" "IVV.High" "IVV.Low" "IVV.Close" ...
3
votes
1answer
942 views

Valuing Total Return Swaps

In my quest for simulated data, I am trying to generate prices for Total Return Swaps by calculating the NPVs of the fixed and floating leg. My problem: Given the fixed leg, how do I set the spread on ...
3
votes
2answers
485 views

Fitting distributions to financial data using volatility model to estimate VaR

I want to fit a distribution to my financial data using a volatility model to estimate the VaR. So in case of a normal distribution, this would be very easy, I assume the returns to follow a normal ...
3
votes
1answer
946 views

How do I backtest a convertible bond arbitrage strategy in R/Matlab?

Since no one was able to answer my previous question, I am going to try to backtest a modern convertible bond arbitrage strategy myself (perhaps I'll report the results back here, if you're lucky :)). ...
3
votes
1answer
154 views

quantiative risk measure how they are implemented in R and their use

So far I have just theoretical knowledge of risk measure and never used them in application. Therefore I have some basic question how risk measures are used in reality and how they are implemented in ...
3
votes
1answer
159 views

Calculating and interpreting cumulative returns is R

I have buy and sell signals,and accordingly, I artificially generate a signal series,for which,I assign 1 to every buy and -1 to every sell: ...
3
votes
0answers
443 views

What is the best solution to use QuantLib within Excel?

Excel is likely the most widespread instrument across all not-only-quants desks; in addition, we have to keep in mind that Bloomberg and Reuters allow to easily import real time data in Excel, and ...
3
votes
0answers
228 views

Definition of risk factors for market risk scenario testing

I am doing a research for stress testing in market risk. The usual process I found out for scenario testing is: Define risk factors upon the portfolio Define the desired scenarios Vary the risk ...
3
votes
0answers
124 views

RQuantLib: any difference between FixedRateBond() and FixedRateBondPriceByYield() with flat term structure?

Please, consider the following functions from RQuantLib package: FixedRateBond() ...
3
votes
0answers
288 views

How to balance two Forex crosses correctly to do a linear regression?

I have two cross and an account in EUR: EUR/USD GBP/USD I would like to do a balanced linear regression using R. With "balanced" I mean that I would like to normalize it by calculating the ...
2
votes
2answers
616 views

ROC: difference between discrete and continuous?

Using the ROC function in the R package TTR, there is a choice between continuous (the default) and discrete, but with no guidance on which you choose when. In the code the difference is: ...
2
votes
2answers
282 views

Loading HF stock data into excel

Are there any free, open source VBA addins or R packages that can be linked using the yahoo finance/Google finance/other data sources api to continuously download intraday data into excel or R? ...
2
votes
2answers
497 views

RQuantLib, Hoadley and Bloomberg YAS: fixed rate bond pricing differences?

I'm trying to price a fixed rate bond one year from now on. The bond is the PEUGOT 7 ⅜ 03/06/18, whose ISIN code is FR0011439975. I'm using such a specific example because in this way everyone can ...
2
votes
2answers
722 views

backtesting options strategies in R

I would like to backtest an options strategy in R. I require the ability to delta hedge and rebalance to options in the portfolio at different frequencies (daily, monthly,etc.) What packages are the ...
2
votes
1answer
548 views

ADF test in R yielding perfect cointegration. How is this possible?

I am using the famous conintegrated pairs tutorial to just different stocks for cointegration. The adf.test yeilds perfect cointegration, which I feel must be incorrect. Here is why: When I run ...