plot(spy_pr$adjusted, type = "l", lwd = 2) lines(fitted(fit), lty = "dashed", lwd = 2, col = "green") lines(tsSmooth(fit), lty ="dotted", lwd = 2, col = "blue")
Runs as expected output here
However, when the exact same code is run from Notebooks or rmarkdown it gives a succession of errors at every attempt at change or adjustment to try and debug from errors list.
The data above for the example is generated below
spy_pr <- tq_get("SPY", get = "stock.prices", from = " 2020-01-01") fit <- StructTS(spy_pr$adjusted, type = "level")
NB. The issue is not the data format I have tried tibbles, dataframes, ts, xts etc. It works best with Matt Dancho's Tidyquant data.