I am having trouble with a single plot of 2 time series using the GGfortify package.
I run into a problem on the last line. Is there a correction that can be made?
library(Ecdat)
inflation <- as.numeric(Mishkin[, 1])
data_ts <- ts(inflation,start=c(1950,2), frequency = 12)
AR_data <- arima(data_ts, order = c(1,0,0))
AR_data_fitted <- data_ts - residuals(AR_data)
combined <- cbind(data_ts,AR_data_fitted)
gg <- autoplot(combined, columns = c(1,2),cmain = "Inflation Data")
Use the following code
library(ggfortify)
combined <- cbind(data_ts,AR_data_fitted)
colnames(combined) <- c("Original Data", "AR fitted data")
autoplot(combined,main = "Inflation Data",facets = FALSE)
autoplot(combined,main = "Inflation Data",facets = FALSE)+
scale_color_manual(values=c("blue", "black"))