This file contains hidden or 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
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
require(quantmod) | |
require(rugarch) | |
require(xtsExtra) #if you get an error, see first line and install from r-forge | |
getSymbols("DEXJPUS",src="FRED") | |
DEXJPUS<-1/to.weekly(DEXJPUS) | |
ugarch.panel <- function(index,x,type,cex,col,pch,...){ |
This file contains hidden or 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
#plot.xts with horizons | |
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
require(PerformanceAnalytics) | |
require(quantmod) | |
require(xtsExtra) #if you get error, install xtsExtra from r-forge | |
horizon.panel <- function(index,x,...) { | |
#get some decent colors from RColorBrewer | |
#we will use colors on the edges so 2:4 for red and 7:9 for blue |
This file contains hidden or 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
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
require(PerformanceAnalytics) | |
require(xtsExtra) #if you get error, please install xtsExtra from r-forge as shown in the top line | |
require(RColorBrewer) | |
#function add alpha or transparency to colors | |
addalpha <- function(cols,alpha=180) { | |
rgbcomp <- col2rgb(cols) | |
rgbcomp[4] <- alpha |
This file contains hidden or 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
## Corey Chivers, 2012 ## | |
sim_bayes<-function(p=0.5,N=100,y_lim=20,a_a=2,a_b=10,b_a=8,b_b=3) | |
{ | |
## Simulate outcomes in advance | |
outcomes<-sample(1:0,N,prob=c(p,1-p),replace=TRUE) | |
success<-cumsum(outcomes) | |
for(frame in 1:N) | |
{ | |
png(paste("plots/",1000+frame,".png",sep="")) |
This file contains hidden or 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
require(fAssets) | |
require(latticeExtra) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
#my.url will be the location of the zip file with the data | |
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip" | |
#this will be the temp file set up for the zip file | |
my.tempfile<-paste(tempdir(),"\\frenchindustry.zip",sep="") | |
#my.usefile is the name of the txt file with the data |
This file contains hidden or 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
require(RColorBrewer) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
data(managers) | |
#let's do managers from 2002 to 2004 to get positive and negative | |
x <- cumprod(1+managers["2002::2004"])[,1] - 1 | |
#get some decent colors from RColorBrewer |
This file contains hidden or 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
#look at steps in constructing a horizon plot version | |
#of http://www.mebanefaber.com/timing-model/ | |
#do horizon of percent above or below 10 month / 200 day moving average | |
require(lattice) | |
require(latticeExtra) | |
require(quantmod) | |
#since we are focused on the horizon plot, let's just look at one stock |
This file contains hidden or 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
library(twitteR) | |
library(ggplot2) | |
library(grid) | |
# download all that you can | |
pol <- userTimeline('BeijingAir', n=3200) | |
length(pol) | |
# 3200 | |
myGrep <- function(x){ |
This file contains hidden or 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
require(lattice) | |
require(latticeExtra) | |
require(directlabels) | |
require(reshape2) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
data(managers) | |
managers[which(is.na(managers),arr.ind=TRUE)[,1], |
This file contains hidden or 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
digraph G { | |
subgraph cluster_1 { | |
Rscript -> localDir; | |
localDir -> Rscript; | |
Rscript -> Sweave; | |
Sweave -> TeX; | |
TeX -> PDF [ label = "laTeX"] | |
Rscript -> Rmarkdown; | |
RCurl -> Rscript; |