library(fpp2)
## Loading required package: ggplot2
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
## Loading required package: forecast
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Registered S3 methods overwritten by 'forecast':
## method from
## fitted.fracdiff fracdiff
## residuals.fracdiff fracdiff
## Loading required package: fma
## Loading required package: expsmooth
library(readxl)
FEDFUNDS <- read_excel("C:/Users/Joseph/Downloads/FEDFUNDS.xls")
fedFunds.ts <- ts(FEDFUNDS, frequency = 12)
fedFunds.addDecomp <- decompose(fedFunds.ts, type = 'additive')
fedFunds.multDecomp <- decompose(fedFunds.ts, type = 'multiplicative')
add.Dec <- na.omit(fedFunds.addDecomp$random)
mult.Dec <- na.omit(fedFunds.multDecomp$random)
add.Dec.MSE <- sqrt(mean(abs(add.Dec)^2))
print(paste('MSE for Additive:',add.Dec.MSE))
## [1] "MSE for Additive: 28328.5721394527"
mult.Dec.MSE <- sqrt(mean(abs(mult.Dec)^2))
print(paste('MSE for Multiplicative:',mult.Dec.MSE))
## [1] "MSE for Multiplicative: 0.997075380015727"
fedFunds.ts %>% decompose(type = 'multiplicative') %>%
autoplot() + xlab('year')+
ggtitle('Classical multiplicative decomposition of Fed Funds')

fedFunds.ts %>% decompose(type = 'additive') %>%
autoplot() + xlab('year')+
ggtitle('Classical additive decomposition of Fed Funds')
