Skip to content

Instantly share code, notes, and snippets.

@Shreyes2010
Shreyes2010 / R_codes_bond_kaggle.R
Created January 31, 2012 21:56
So far what I got with dealing with the NA's
############################################################################################
####################### READING THE RELEVANT FILES #########################################
train.data <- read.csv("train_sample.csv")
## Set seed for reproducing the random numbers
set.seed(10001)
## This is to confirm the selection of trade_price_last{1-10}
@Shreyes2010
Shreyes2010 / GARCH.R
Created February 8, 2012 23:19
GARCH MLE codes
# Specifying functions:
CalcResiduals <- function(th, data) {
# Calculates the e_t and h_t for the GARCH(1, 1) model with given parameters.
#
# Argumentss:
# th: Parameters
# th[1] -> mean
# th[2] -> alpha.0
# th[3] -> alpha.1
@Shreyes2010
Shreyes2010 / IFE_Assignment.r
Created March 10, 2012 09:58
IFE_Assignment
data <- read.csv("IFE_Update.csv")
# Plotting the foreign reserves of all the countries
png("IR_Relative.png", height = 800, width = 1000)
par(mfrow = c(3, 2)) ## This is to specify the number of rows and columns you want for the plots
# India
plot(data$Index, (data$India.Millions/max(data$India.Millions[!is.na(data$India.Millions)])),
type="l", xlab= "Months", ylab= "Foreign reserves (in $ millions)", col="green", lwd = 2,
main ="India's foreign reserves since 2002")
@Shreyes2010
Shreyes2010 / MOM_YOY.R
Created April 12, 2012 15:50
MOM vs YOY rates in inflation
a <- read.csv("Data.csv")
# Pretty functions to compute the MOM and YOY inflation rates
mom.inf <- function(series){
x <- rep(NA,length(series))
for(i in 2:length(series))x[i] <- ((series[i] - series[i-1])/series[i-1])*100
return(x)
}
@Shreyes2010
Shreyes2010 / Result.R
Created May 31, 2012 19:10
Results from the adf.test()
Augmented Dickey-Fuller Test
data: Full sample
Dickey-Fuller = -2.4901, Lag order = 4, p-value = 0.3734
alternative hypothesis: stationary
Augmented Dickey-Fuller Test
data: First 80 obs
Dickey-Fuller = -2.9479, Lag order = 4, p-value = 0.1882
@Shreyes2010
Shreyes2010 / Persistence.r
Created July 25, 2012 11:55
Persistence measure : Rolling regression
## Reading the relevent files
install.packages("zoo")
library(zoo)
ife <- read.csv("CPI_Data.csv")
ife_wpi <- read.csv("WPI_Data_1.csv")
# Function to compute Y-o-Y inflation rate