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('ggplot2') | |
library('randomForest') | |
set.seed(2014) | |
rf_predict<-function(rf_object, data){ | |
if (rf_object$type=="classification"){ | |
p <-predict(rf_object, data, type="prob") | |
p<-as.vector(p[,2]) | |
} else { | |
p <-predict(rf_object, 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
##programmer: JEY | |
##2/28/2013 | |
##District-month forecasts | |
##note: this takes about 5 minutes to run. It throws lots of errors due to many all zero time series, but it will eventually complete and build predictions | |
rm(list=ls()) | |
library(foreign) | |
library(forecast) | |
library(sos) | |
data<-read.dta("raw_AFG.dta") |
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
################################# | |
##Programmer: James E. Yonamine | |
##Helpful edits: Peter Li | |
##Date: 9/2/2012 | |
##Random Forest Alpha Cutoff Function | |
################################# | |
##load pacakges and data | |
library(foreign) | |
library(MASS) |
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
################################# | |
##Programmer: James E. Yonamine | |
##Date: 9/12/2012 | |
##Basic introduction to stacking | |
################################# | |
##load pacakges and data | |
library(foreign) | |
library(Zelig) | |
library(MASS) |
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
########################## | |
##r code for greed and grievance replication/extension file | |
##James E. Yonamine | |
##4/13/2012 | |
##data from http://www.apsanet.org/content_29436.cfm | |
##code takes 20 minutes to run on a 2.3 ghz intel core i5 with 4gb ram | |
########################## | |
library(foreign) | |
library(ROCR) |
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
########################## | |
##r code for greed and grievance replication/extension file | |
##James E. Yonamine (worked off of VJD's original code) | |
##2/14/2012 | |
##data from http://www.apsanet.org/content_29436.cfm | |
########################## | |
#if you don't have the packages below, un-comment them out and install. | |
#install.packages("ROCR") | |
#install.packages("fields") |