---
title: "naive v2: dependency-free empirical extrapolation"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{naive v2: dependency-free empirical extrapolation}
  %\VignetteEngine{knitr::rmarkdown}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(naive)
```

`naive` searches historical windows for recurring patterns and uses similar
windows to form an empirical forecast distribution. The runtime package uses
only base R.

```{r numeric}
set.seed(1)
x <- data.frame(signal = sin(seq(0, 12, length.out = 120)) + rnorm(120, 0, .05))
fit <- naive_fit(x, seq_len = 8, n_windows = 3, n_samp = 4, seed = 42)
print(fit)
plot(fit)
```

The same interface accepts categorical sequences.

```{r categorical}
events <- data.frame(state = factor(rep(c("low", "high", "medium"), 30)))
naive_forecast(events, horizon = 4, seed = 42)$forecast$state
```

Use `naive_metrics()` to compare a forecast against a holdout and compare the
result with a last-value baseline before deploying it.
