I am practicing structural changes in a time series with strucchange
package but I want to plot and customize it with ggplot. so I choose autoplot function from package forecast
.
library(strucchange)
library(tidyverse)
library(forecast)
data= monthly_ts #monthly time series data
tt = 1: length(monthly_ts)
bpoint_ts = breakpoints(monthly_ts ~ tt, h=0.1)
autoplot(breakpoints(bpoint_ts,break=6),data=monthly_ts) #this portion runs perfectly
autoplot(breakpoints(bpoint_ts,break=6),data=monthly_ts) + autolayer(fitted(bpoint_ts , breaks = 6),size=0.6 ) #showing error while adding autolayer()
#it is showing "Error: Invalid input: date_trans works with objects of class Date only"
also, everything works perfectly while using same time series but annually averaged .