I have 12 raster images which I stack them. Then I converted the
rasterstack to a matrix, I remove the NA's from the matrix and I convert
the matrix to monthly time-series matrix. Finally, I run the bfastlite
function, like so:

library(bfast)
library(raster)

wd <- "path"

l <- list.files(paste0(wd), pattern='.tif$',
                all.files=TRUE, full.names=FALSE)

r <- raster::stack(paste0(wd, l))

m <- raster::as.matrix(r)
m <- m[!rowSums(is.na(m)), ]

# convert the matrix to timeseries matrix
tm <- ts(data = m, start = c(2019, 1), end = c(2019, 12), frequency = 12,
class = "ts")
class(tm)

bf <- bfastlite(
  tm,
  formula = response ~ trend + harmon,
  order = 3,
  breaks = "LWZ",
  na.action = na.omit,
  stl = "trend",
  decomp = "stl",
  sbins = 1,
  h = 0.5,
  level = 0.5,
  type = "OLS-MOSUM"
)
And the error:

Error in stats::stl(x, s.window = "periodic") :
  series is not periodic or has less than two periods

I have tried many variations in the parameters of the bfastlite function.

Any ideas what that error means and how I can overcome it? The dataset can
be downloaded from my GoogleDrive (
https://drive.google.com/drive/folders/1V115zpdU2-5fXssI6iWv_F6aNu4E5qA7).

RStudio 2023.12.0+369, R 4.3.2, Windows 11.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to