── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ tsibble::interval() masks lubridate::interval()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following object is masked from 'package:tsibble':
index
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
######################### Warning from 'xts' package ##########################
# #
# The dplyr lag() function breaks how base R's lag() function is supposed to #
# work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
# source() into this session won't work correctly. #
# #
# Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
# conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
# dplyr from breaking base R's lag() function. #
# #
# Code in packages is not affected. It's protected by R's namespace mechanism #
# Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
# #
###############################################################################
Attaching package: 'xts'
The following objects are masked from 'package:dplyr':
first, last
Loading required package: TTR
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Plot variable not specified, automatically selected `.vars = value`
Warning in geom_line(...): Ignoring unknown parameters: `main`
p1/p2/p3
Looking at CPI, we can straight away see that there is a trend, violating the constant mean assumption.
Looking at Real GDP, we see the same thing: a trend over time, violating the constant mean assumption.
Looking at the unemployment rate, it satisfies the constant mean trend. However, it looks like it might violate the constant variance and covariance assumptions.
ADF
adf.test(cpi$value)
Warning in adf.test(cpi$value): p-value greater than printed p-value
Augmented Dickey-Fuller Test
data: cpi$value
Dickey-Fuller = -0.028283, Lag order = 6, p-value = 0.99
alternative hypothesis: stationary
adf.test(gdp$value)
Augmented Dickey-Fuller Test
data: gdp$value
Dickey-Fuller = -1.0493, Lag order = 4, p-value = 0.9251
alternative hypothesis: stationary
adf.test(unemp$value)
Augmented Dickey-Fuller Test
data: unemp$value
Dickey-Fuller = -2.2659, Lag order = 6, p-value = 0.4638
alternative hypothesis: stationary
In an ADF test, the null hypothesis is non-stationary, and the alternative hypothesis is that the series is stationary. We reject the null (series is stationary) when p-value < 0.05. For cpi, gdp, and unemp, we fail to reject the null hypothesis, meaning they are non-stationary.
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_line()`).
Removed 1 row containing missing values or values outside the scale range
(`geom_line()`).
Removed 1 row containing missing values or values outside the scale range
(`geom_line()`).
ADF To Confirm
adf.test(na.omit(cpi_diff$diff))
Warning in adf.test(na.omit(cpi_diff$diff)): p-value smaller than printed
p-value
Augmented Dickey-Fuller Test
data: na.omit(cpi_diff$diff)
Dickey-Fuller = -4.1292, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary
adf.test(na.omit(gdp_diff$diff))
Warning in adf.test(na.omit(gdp_diff$diff)): p-value smaller than printed
p-value
Augmented Dickey-Fuller Test
data: na.omit(gdp_diff$diff)
Dickey-Fuller = -4.8227, Lag order = 4, p-value = 0.01
alternative hypothesis: stationary
adf.test(na.omit(unemp_diff$diff))
Warning in adf.test(na.omit(unemp_diff$diff)): p-value smaller than printed
p-value
Augmented Dickey-Fuller Test
data: na.omit(unemp_diff$diff)
Dickey-Fuller = -7.0663, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary
Visual and ADF tests prove that the data is stationary because p<.05 for all 3 differenced sets.
For CPI, the ARMA process shows us that we have AR(1) and MA(1). This tells us that today’s CPI depends on the CPI from the previous period and that it took 1 period to adjust from an unexpected shock.
For unemployment, we get ARMA(1,0), meaning that there is only an autoregressive component. This means that today’s GDP depends on the GDP from the previous period
We can determine from the trend that there is constant, long-term growth in GDP. This is consistent with a typical developed country, as there is little wiggle room in the efficient frontier, leading to consistent “low” growth.
Seasonality:
There is obvious seasonality in CPI, but it has grown over time. Seasonality was very week and constantly got stronger. This is consistent with recent consumer trends as the winter season is constantly showing increased spending.
We can determine from the trend that there is no structural change to the unemployment rate, but it can experience upticks and downticks, as we can see from the waves in the data.
Seasonality:
The same goes for unemployment as GDP; there was little seasonality at first, but recently, it has magnified and strengthened.