library(readr)
fdi <- read_csv("~/Zim Projects PHD/Felix Shayamano/fdi.csv")
## Parsed with column specification:
## cols(
## YEAR = col_double(),
## DOMESTIC_INVESTMENTS = col_double(),
## EMPLOYMENT = col_double(),
## ECONOMIC_GROWTH = col_double(),
## TRADE_OPENNES = col_double(),
## EXTERNAL_DEBT = col_double(),
## EXPORTS = col_double(),
## INFLATION = col_double(),
## GDP = col_double(),
## FDI = col_double(),
## HDI = col_double()
## )
View(fdi)
attach(fdi)
names(fdi)
## [1] "YEAR" "DOMESTIC_INVESTMENTS" "EMPLOYMENT"
## [4] "ECONOMIC_GROWTH" "TRADE_OPENNES" "EXTERNAL_DEBT"
## [7] "EXPORTS" "INFLATION" "GDP"
## [10] "FDI" "HDI"
library(lubridate) # for working with dates
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(ggplot2) # for creating graphs
library(scales) # to access breaks/formatting functions
##
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
##
## col_factor
library(gridExtra) # for arranging plots
library(ggthemes)
# plot FDI
fd <- ggplot(fdi,aes(x=YEAR,y=FDI)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Foreign Direct Investiment in Zimbabwe") +
xlab("Year") + ylab("FDI")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
HDI
# plot HDI
fd <- ggplot(fdi,aes(x=YEAR,y=HDI)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("HDI in Zimbabwe") +
xlab("Year") + ylab("HDI")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
GDP
# plot GDP
fd <- ggplot(fdi,aes(x=YEAR,y=GDP)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Gross Domestic Product in Zimbabwe") +
xlab("Year") + ylab("GDP")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
INFLATION
fd <- ggplot(fdi,aes(x=YEAR,y=INFLATION)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Inflation Rate in Zimbabwe") +
xlab("Year") + ylab("INFLATION")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
EXPORTS
fd <- ggplot(fdi,aes(x=YEAR,y=EXPORTS)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Exports Rate in Zimbabwe") +
xlab("Year") + ylab("EXPORTS")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
EXTERNAL_DEBT
fd <- ggplot(fdi,aes(x=YEAR,y=EXTERNAL_DEBT)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("External Debt in Zimbabwe") +
xlab("Year") + ylab("EXTERNAL DEBT")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
TRADE_OPENNES
fd <- ggplot(fdi,aes(x=YEAR,y=TRADE_OPENNES)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Trade Opennes in Zimbabwe") +
xlab("Year") + ylab("TRADE OPENNES")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
ECONOMIC_GROWTH
fd <- ggplot(fdi,aes(x=YEAR,y=ECONOMIC_GROWTH)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Economic Growth in Zimbabwe") +
xlab("Year") + ylab("ECONOMIC GROWTH")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
EMPLOYMENT
fd <- ggplot(fdi,aes(x=YEAR,y=EMPLOYMENT)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Employment Rate in Zimbabwe") +
xlab("Year") + ylab("EMPLOYMENT")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
DOMESTIC_INVESTMENTS
fd <- ggplot(fdi,aes(x=YEAR,y=DOMESTIC_INVESTMENTS)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Domestic Investiments in Zimbabwe") +
xlab("Year") + ylab("DOMESTIC INVESTMENTS")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="green")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
One to One plots
FDI and Economic Growth
fd <- ggplot(fdi,aes(x=ECONOMIC_GROWTH,y=FDI)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Economic Growth and Foreign Direct Investiment") +
xlab("ECONOMIC GROWTH") + ylab("FDI")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="red")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
fd <- ggplot(fdi,aes(x=EMPLOYMENT,y=FDI)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Employment Status and Foreign Direct Investiment") +
xlab("EMPLOYMENT") + ylab("FDI")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="red")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
fd <- ggplot(fdi,aes(x=DOMESTIC_INVESTMENTS,y=FDI)) +
geom_point(na.rm=TRUE, color="purple", size=2) +
ggtitle("Domestic Investiments and Foreign Direct Investiment") +
xlab("DOMESTIC INVESTMENTS") + ylab("FDI")+theme_economist()
# render the plot
trend <- fd+ stat_smooth(colour="red")
trend
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
Time series analys
acf(log(FDI))
acf(diff(log(FDI)))
pacf(diff(log(FDI)))
EMPLOYMENT
acf(log(EMPLOYMENT))
acf(diff(log(EMPLOYMENT)))
pacf(diff(log(EMPLOYMENT)))
ECONOMIC_GROWTH
acf(ECONOMIC_GROWTH)
acf(diff(ECONOMIC_GROWTH))
pacf(diff(ECONOMIC_GROWTH))
DOMESTIC_INVESTMENTS
acf(log(DOMESTIC_INVESTMENTS))
acf(diff(log(DOMESTIC_INVESTMENTS)))
pacf(diff(log(DOMESTIC_INVESTMENTS)))
TRADE_OPENNES
acf(log(TRADE_OPENNES))
acf(diff(log(TRADE_OPENNES)))
pacf(diff(log(TRADE_OPENNES)))
EXTERNAL_DEBT
acf(log(EXTERNAL_DEBT))
acf(diff(log(EXTERNAL_DEBT)))
pacf(diff(log(EXTERNAL_DEBT)))
INFLATION
acf(INFLATION)
acf(diff(INFLATION))
pacf(diff(INFLATION))
GDP
acf(GDP)
acf(diff(GDP))
pacf(diff(GDP))
HDI
acf(log(HDI))
acf(diff(log(HDI)))
pacf(diff(log(HDI)))
(fit <- arima(log(FDI), c(0, 1, 1),seasonal = list(order = c(0, 1, 1), period = 12)))
##
## Call:
## arima(x = log(FDI), order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1),
## period = 12))
##
## Coefficients:
## ma1 sma1
## -0.2272 0.0000
## s.e. 0.5210 65.8373
##
## sigma^2 estimated as 2.497: log likelihood = -13.16, aic = 32.32
fit
##
## Call:
## arima(x = log(FDI), order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1),
## period = 12))
##
## Coefficients:
## ma1 sma1
## -0.2272 0.0000
## s.e. 0.5210 65.8373
##
## sigma^2 estimated as 2.497: log likelihood = -13.16, aic = 32.32
#pred <- predict(fit, n.ahead = 10*12)
#ts.plot(FDI,2.718^pred$pred, log = "y", lty = c(1,3))