# \donttest{
dat <- t(harborSealWA)
dat <- dat[2:4, ] # remove the year row
# fit a model with 1 hidden state and 3 observation time series
# cross validation here is random, 10 folds
fit <- MARSScv(dat, model = list(
Z = matrix(1, 3, 1),
R = "diagonal and equal"
))
# second, demonstrate passing in pre-specified folds
fold_ids <- matrix(
sample(1:5, size = nrow(dat) * ncol(dat), replace = TRUE),
nrow(dat), ncol(dat)
)
fit <- MARSScv(dat, model = list(
Z = matrix(1, 3, 1),
R = "diagonal and equal"
), fold_ids = fold_ids)
# third, illustrate future cross validation
fit <- MARSScv(dat, model = list(
Z = matrix(1, 3, 1),
R = "diagonal and equal"
), future_cv = TRUE, n_future_cv = 5)
# }
Run the code above in your browser using DataLab