## Anyone using MatLab, Octave, SciPy, the Language R

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
mojojojo
Roundtable Knight
Posts: 131
Joined: Mon Oct 31, 2005 2:07 pm
I have a quick R question since it seems like we have some users here. Plus you guys are a lot more tolerant of newbie type questions than the R list. I"m having a hard time matching the results up to my reading on the subject.

I'm running OLS regression on interest rates and index prices.

> lmLevel <- lm(index~rates, data=df)

Then run a BP and DW test

> bptest(lmLevel)
studentized Breusch-Pagan test

data: lmLevel
BP = 2.1318, df = 1, p-value = 0.1443

> dwtest(lmLevel)
Durbin-Watson test

data: lmSReturn
DW = 0.3123, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0

re: bptest. With such a high p-value, it's basically stating that there is conditional heteroskedasticity, correct?

re: dwtest. With a low DW number and very low p-value. Positive serial correlation exists, correct?

So I then run a test to correct for both ..

> coeftest(lmLevel,vcoc=vcovHAC(lmLevel))

t test of coefficients:

Estimate Std. Error t value Pr(>|t|)
(Intercept) 1579.9570 34.9740 45.175 < 2.2e-16 ***
rates -124.6063 4.6965 -26.532 < 2.2e-16 ***
---
Signif. codes: 0 â€˜***â€™ 0.001 â€˜**â€™ 0.01 â€˜*â€™ 0.05 â€˜.â€™ 0.1 â€˜ â€™ 1

So are these now valid results?

Macro
Roundtable Fellow
Posts: 70
Joined: Sat Dec 03, 2011 11:22 am
Backtesting with R is a mixed blessing if you're dealing with EOD data because it drastically reduces the odds of curve-fitting via reckless optimization as you are massively disincentivized to even think of optimizing due to time constraints. Absolute nightmare for backtesting with single asset intraday data, much less optimize on a portfolio level. However, the doParallel package has reduced the processing time to more bearable levels, but nowhere near TBLOX's speed: http://cran.r-project.org/web/packages/ ... index.html

I'm hoping R, given its open source nature, would include native parallel processing over subsequent updates, but as far I'm aware, the fastest numerical computing language is Julia: http://julialang.org/

Note: I primarily use the quantstrat package in R for backtesting. Contemplating making the switch to TB.

indigoatlantic
Full Member
Posts: 24
Joined: Fri Nov 02, 2012 4:20 am
Macro,

I am in same boat as you. I user TradingBlox for most of backtesting needs. The data preprocessing and results analysis, I rely more on R.