--- title: "Getting started with spooky 2.0" author: "Giancarlo Vercellino" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting started with spooky 2.0} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(spooky) ``` ## Overview `spooky` forecasts one or more time features with a compact spectral model. It uses differencing, FFT extrapolation, rolling validation, and jackknife-style resampling to compare candidate sequence lengths and leave-out values. Spooky 2.0 has no runtime dependencies beyond base R packages. ## Numeric forecasting The package includes `time_features`, a small example data set with two numeric series. The following fits one candidate model and keeps the example fast. ```{r numeric} data(time_features) fit <- spooky(time_features, seq_len = 10, lno = 1, n_samp = 1, n_windows = 2, seed = 42) fit fit$best_model$testing_errors head(fit$best_model$preds[[1]]) ``` The `history` component records the candidate settings and validation errors. The `best_model` component contains errors, prediction summaries, and plot objects for each input feature. ## Categorical forecasting Categorical columns are encoded internally, so no dummy-variable package is needed. ```{r categorical} events <- data.frame(state = factor(rep(c("quiet", "active"), 30))) categorical_fit <- spooky(events, seq_len = 2, lno = 1, n_samp = 1, n_windows = 2, seed = 42) categorical_fit$best_model$testing_errors ``` ## Reproducibility Set `seed` to make the random candidate search reproducible. For a larger search, provide ranges for `seq_len` and `lno`, and increase `n_samp`. ```{r search, eval=FALSE} fit <- spooky(time_features, seq_len = c(5, 30), lno = c(1, 10), n_samp = 30, n_windows = 3, seed = 42) ```