## The following is a small illustrative example using the quotes of the
## SP500 index. This example compares two random forests with 500
## regression trees, one applyed in a standard way, and the other using
## a sliding window with a relearn step of every 10 days. The experiment
## uses 10 repetitions of a train+test cycle using 50% of the available
## data for training and 25% for testing.
## Not run:
# library(quantmod)
# library(randomForest)
# getSymbols('^GSPC',from='2008-01-01',to='2012-12-31')
# data.model <- specifyModel(
# Next(100*Delt(Ad(GSPC))) ~ Delt(Ad(GSPC),k=1:10)+Delt(Vo(GSPC),k=1:3))
# data <- as.data.frame(modelData(data.model))
# colnames(data)[1] <- 'PercVarClose'
# spExp <- performanceEstimation(
# PredTask(PercVarClose ~ .,data,'SP500_2012'),
# c(Workflow(wf='standardWF',wfID="standRF",
# learner='randomForest',
# learner.pars=list(ntree=500)),
# Workflow(wf='timeseriesWF',wfID="slideRF",
# learner='randomForest',
# learner.pars=list(ntree=500),
# type="slide",
# relearn.step=10)
# ),
# EstimationTask(
# metrics=c("mse","theil"),
# method=MonteCarlo(nReps=5,szTrain=0.5,szTest=0.25)
# )
# )
# ## End(Not run)
Run the code above in your browser using DataLab