# Example with ts objects
x <- ts(c(1:144), start = c(1980, 1), frequency = 12)
y <- ts(c(1:12), start = 1980, frequency = 1)
# msld and mls should give the same results
m1 <- mlsd(x, 0:5, y)
m2 <- mls(x, 0:5, 12)
sum(abs(m1 - m2))
# Example with zooreg
# Convert x to zooreg object using yearmon time index
if (FALSE) {
xz <- zoo::as.zooreg(x)
yz <- zoo::zoo(as.numeric(y), order.by = as.Date(paste0(1980 + 0:11, "-01-01")))
# Heuristic works here
m3 <- mlsd(xz, 0:5, yz)
sum(abs(m3 - m1))
}
Run the code above in your browser using DataLab