Translate

Monday, December 14, 2020

Analyzing Gross Domestic Product (GDP) as of 2020-07-01

 




library(Quandl)
library(ggplot2)
library(tseries);library(timeseries);library(xts);library(forecast)
library (quantmod)
library(psych)
library(plotly) #install.package(plotly)

getSymbols(c('GDPDEF','GDP','PCEC','GPDI','NETEXP','GCE'), src='FRED')

ratio_PCEC=PCEC/GDP*100
ratio_GPDI=GPDI/GDP*100
ratio_NETEXP=NETEXP/GDP*100
ratio_GCE=GCE/GDP*100


basket<-cbind(ratio_PCEC, ratio_GPDI, ratio_NETEXP, ratio_GCE)

summary(basket)

tail(basket)
myColors <- c("red", "darkgreen", "goldenrod", "darkblue")

plot(x = basket, xlab = "Year", ylab = "Percent",
       main = "Percent in GDP", col = myColors, screens = 1, subset = "1980-01-04/")
legend(x = "topleft", legend = c("PCEC", "GDPI", "NETEXP", "GCE"),
       lty = 1, col = myColors)

describe(ratio_GPDI)


plot(ratio_PCEC, main="% of Personal Consumption Expenditure in GDP", ylab="Percent")
lines(mean_PCEC, col='red')

plot(ratio_GPDI, main="% of Gross Private Domestic Investment in GDP")

plot(ratio_NETEXP, main="% of Net Export in GDP")

plot(ratio_GCE, main="% of Government Consumption Expenditure in GDP")





Diff_GDP=Delt(GDP, k=4)*100
Diff_PCEC=Delt(PCEC, k=4)*100
Diff_GPDI=Delt(GPDI, k=4)*100
Diff_NETEXP=Delt(NETEXP, k=4)*100
Diff_GCE=Delt(GCE, k=4)*100



Diff_basket<-cbind(Diff_GDP, Diff_PCEC, Diff_GPDI, Diff_GCE)

myColors <- c("red", "darkgreen", "goldenrod", "darkblue")

plot(x = Diff_basket, xlab = "Year", ylab = "Percent",
     main = "Percent in GDP", col = myColors, screens = 1, subset = "1980-01-04/")
legend(x = "topleft", legend = c("GDP", "PCEC", "GDPI",  "GCE"),
       lty = 1, col = myColors)



Diff_GDPDEF=Delt(GDPDEF, k=4)*100

Real_GDP=Diff_GDP-Diff_GDPDEF

plot(Real_GDP)








No comments:

Post a Comment