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
## 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 |
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
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 |
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
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) | |
} |
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
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") |
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
# 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 |
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
############################################################################################ | |
####################### 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} |
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
# Aggregate demand curve | |
ad.curve <- function(c, A, b, ms, h, k ,y) # We are trying to arrive at a relation between | |
# Prices and output. | |
{ | |
alpha <- 1/(1-c) | |
omega <- (k/h) - (1/alpha*b) | |
P <- (ms/h)/(y*omega + (A/b)) # This is just basic algebra, you substitute "i" in terms of | |
# "P" and "Y" from the IS and LM equations and find a relation between prices and output. | |
return(P) |
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
# IS curve equation | |
# y = output; c = marginal propensity to consume; alpha = 1/(1-c) A = autonomous component; | |
# b = Senstivity to interest rates; i = interest rates | |
# I = I.0 - b*i (investment equation) | |
# y = alpha*A - alpha*b*i | |
IS.curve <- function(c, A, b, i) | |
{ | |
y = (1/(1-c))*A - (1/(1-c))*b*i | |
return(y) |
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
Y = C + I + G + (X - M) | |
Y: Output produced in the economy | |
C: Total consumption demand | |
I: Total investment | |
G: Total govt. spending | |
X: Total value of exports | |
M: Total value of imports | |
We assume a closed economy so the identity boils down to |
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
single.call <- function(limit) { # Another cute function that returns the vector that contains the number of iterations for each number. | |
memo <- rep(-1, limit) | |
memo[1] <- 0 | |
for(i in c(2:limit)) { | |
l <- 0 | |
n <- i | |
while(n >= i) { # Check only so long as "n > i" and not "1" this is basically the optimization we wanted. | |
l <- l + 1 |
NewerOlder