This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Setup | |
rm(list = ls(all = TRUE)) | |
gc(reset=TRUE) | |
set.seed(42) #From random.org | |
#Libraries | |
library(caret) | |
library(devtools) | |
install_github('caretEnsemble', 'zachmayer') #Install zach's caretEnsemble package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list = ls(all = TRUE)) #CLEAR WORKSPACE | |
library(quantmod) | |
#Scrape data from the website | |
library(XML) | |
rawPMI <- readHTMLTable('http://www.ism.ws/ISMReport/content.cfm?ItemNumber=10752') | |
PMI <- data.frame(rawPMI[[1]]) | |
names(PMI)[1] <- 'Year' | |
#Reshape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Setup | |
set.seed(1) | |
library(fpp) # To load the data set a10 | |
HZ <- 12 | |
myControl <- list( minObs=60, | |
stepSize=1, | |
maxHorizon=HZ, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Setup | |
rm(list = ls(all = TRUE)) | |
gc(reset=TRUE) | |
set.seed(1234) #From random.org | |
#Libraries | |
library(caret) | |
library(devtools) | |
install_github('caretEnsemble', 'zachmayer') #Install zach's caretEnsemble package | |
library(caretEnsemble) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Setup | |
rm(list = ls(all = TRUE)) | |
setwd('path.to/cv.ts') | |
#Load Packages | |
require(forecast) | |
require(doParallel) | |
source('R/cv.ts.R') | |
source('R/forecast functions.R') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /Library/Frameworks/R.framework/Resources/lib | |
# for vecLib use | |
ln -sf libRblas.vecLib.dylib libRblas.dylib | |
# for R reference BLAS use | |
ln -sf libRblas.0.dylib libRblas.dylib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multiRF <- function(X, Y, mtry_vector,...) { | |
stopifnot(require(doRNG)) | |
stopifnot(require(randomForest)) | |
stopifnot(is.numeric(mtry_vector)) | |
stopifnot(all(mtry_vector>1)) | |
foreach(i=mtry_vector,.combine=randomForest::combine,.packages='randomForest',.export=c('X','Y'),.inorder=FALSE) %dorng% { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Test</title> | |
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | |
<link rel="apple-touch-icon" href="icon.png"/> | |
<style type="text/css"> | |
body{ margin: 0px;} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Load the dataset, adjust, and convert to monthly returns | |
set.seed(42) | |
library(quantmod) | |
getSymbols('^GSPC', from='1990-01-01') | |
GSPC <- adjustOHLC(GSPC, symbol.name='^GSPC') | |
GSPC <- to.monthly(GSPC, indexAt='lastof') | |
Target <- ClCl(GSPC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Download S&P 500 data, adjust, and conver to monthly | |
set.seed(42) | |
library(quantmod) | |
getSymbols('^GSPC', from='1990-01-01') | |
GSPC <- adjustOHLC(GSPC, symbol.name='^GSPC') | |
GSPC <- to.monthly(GSPC, indexAt='lastof') | |
Target <- ClCl(GSPC) | |
#Calculate some co-variates | |
periods <- c(3, 6, 9, 12) |