Skip to content
Back to skills

Forecast

ASecurity

R forecast package for time series forecasting. Use for ARIMA, ETS, and other forecasting methods.

  • 5 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 8, 2026
data

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill forecast --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Forecast?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Forecast
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-forecast-r-analytics-skill/badge)](https://www.skillsdirectory.com/skills/leolin990405-forecast-r-analytics-skill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: forecast
description: R forecast package for time series forecasting. Use for ARIMA, ETS, and other forecasting methods.
---

# forecast

Forecasting functions for time series.

## Time Series Objects

```r
library(forecast)

# Create ts object
ts_data <- ts(data, start = c(2020, 1), frequency = 12)

# From vector
ts_data <- ts(values, frequency = 4)  # Quarterly
```

## Auto ARIMA

```r
# Automatic ARIMA
fit <- auto.arima(ts_data)

# Forecast
fc <- forecast(fit, h = 12)
plot(fc)

# With options
fit <- auto.arima(ts_data,
  seasonal = TRUE,
  stepwise = FALSE,
  approximation = FALSE)
```

## ETS (Exponential Smoothing)

```r
# Automatic ETS
fit <- ets(ts_data)
fc <- forecast(fit, h = 12)

# Specific model
fit <- ets(ts_data, model = "MAM")  # Multiplicative error, additive trend, multiplicative season
```

## TBATS

```r
# For complex seasonality
fit <- tbats(ts_data)
fc <- forecast(fit, h = 24)
```

## Simple Methods

```r
# Naive
naive(ts_data, h = 12)

# Seasonal naive
snaive(ts_data, h = 12)

# Mean
meanf(ts_data, h = 12)

# Random walk with drift
rwf(ts_data, h = 12, drift = TRUE)
```

## Decomposition

```r
# STL decomposition
stl_fit <- stl(ts_data, s.window = "periodic")
plot(stl_fit)

# Forecast from STL
stlf(ts_data, h = 12)

# MSTL for multiple seasonality
mstl(ts_data)
```

## Accuracy

```r
# Fit accuracy
accuracy(fit)

# Forecast accuracy
accuracy(fc, test_data)

# Cross-validation
tsCV(ts_data, forecastfunction = naive, h = 1)
```

## Diagnostics

```r
# Residual diagnostics
checkresiduals(fit)

# ACF/PACF
Acf(ts_data)
Pacf(ts_data)

# Ljung-Box test
Box.test(residuals(fit), type = "Ljung-Box")
```

## Neural Network

```r
# Neural network autoregression
fit <- nnetar(ts_data)
fc <- forecast(fit, h = 12)
```

## Plotting

```r
# Forecast plot
autoplot(fc)

# With ggplot2
autoplot(fc) +
  autolayer(fitted(fit), series = "Fitted")
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in data →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.