# Packages list
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.4
## ✔ ggplot2 3.4.3 ✔ stringr 1.5.0
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(bea.R)
## Warning: package 'bea.R' was built under R version 4.3.2
## Loading required package: data.table
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week,
## yday, year
##
## The following object is masked from 'package:purrr':
##
## transpose
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
##
## Note: As of February 2018, beaGet() requires 'TableName' for NIPA and NIUnderlyingDetail data instead of 'TableID.' See https://github.us-bea/bea.R for details.
library(data.table)
library(ggplot2)
Create account
beakey <- "7DE107FD-6B61-4560-ACCC-41CBD7302E70"
beaSpecs10 <- list(
"UserID" = beakey,
"Method" = "GetData",
"datasetname" = "NIPA",
"TableName" = "T10705",
"Frequency" = "A",
"Year" = "X")
bea_10 <- beaGet(beaSpecs10, asWide = FALSE)
## No encoding supplied: defaulting to UTF-8.
unique(bea_10$LineDescription)
## [1] "Gross domestic product (GDP)"
## [2] "Plus: Income receipts from the rest of the world"
## [3] "Less: Income payments to the rest of the world"
## [4] "Equals: Gross national product"
## [5] "Less: Consumption of fixed capital"
## [6] "Private"
## [7] "Domestic business"
## [8] "Capital consumption allowances"
## [9] "Less: Capital consumption adjustment"
## [10] "Households and institutions"
## [11] "Government"
## [12] "General government"
## [13] "Government enterprises"
## [14] "Equals: Net national product"
## [15] "Less: Statistical discrepancy"
## [16] "Equals: National income"
## [17] "Corporate profits with inventory valuation and capital consumption adjustments"
## [18] "Taxes on production and imports less subsidies"
## [19] "Contributions for government social insurance, domestic"
## [20] "Net interest and miscellaneous payments on assets"
## [21] "Business current transfer payments (net)"
## [22] "Current surplus of government enterprises"
## [23] "Plus: Personal income receipts on assets"
## [24] "Plus: Personal current transfer receipts"
## [25] "Equals: Personal income"
## [26] "Gross domestic income (GDI)"
## [27] "Average of GDP and GDI"
## [28] "Gross national income"
## [29] "Gross national factor income"
## [30] "Net domestic product"
## [31] "Net domestic income"
## [32] "Net national factor income"
## [33] "Net domestic purchases"
## [34] "Statistical discrepancy as a percentage of GDP"
data_2 <- bea_10 %>%
filter(LineDescription == "Gross domestic product (GDP)")
plot(x = data_2$TimePeriod, y = data_2$DataValue,
ylab = "Real GDP",
xlab = "Year",
type = "l",
col = "Red")
I found two drops in the real GDP by year.
The first one in 2008 was due to the financial crisis. The defaults on mortgages loans created pressure on the overall economy. Increased price of lending added pressure to companies as well increasing the unemployment rate. Less employment means less income and hence the decrease in GDP.
The second one was in 2020 due to the COVID-19 pandemic. Many of the businesses shut down, forcing employees to unemployment and the relationship between unemployment and GDP shows that as unemployment increases, GDP decreases.
data_2$TimePeriod <- as.numeric(data_2$TimePeriod)
ggplot(data_2,
aes(x = TimePeriod, y = DataValue)) + geom_line()