Getting started with svines

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  warning = FALSE
)
set.seed(2026)
library(svines)

Model layers

An S-vine model combines marginal distributions with a stationary vine copula. The package exposes these two layers separately:

The argument p is the Markov order. An order-one model relates the current observation to the previous observation, while larger values include additional lags.

Fitting a continuous model

The returns data contain daily log returns of 20 companies. We use two series and restrict the candidate families to keep this example short.

data(returns)
x <- returns[1:200, 1:2]

fit <- svine(
  x,
  p = 1,
  margin_families = c("norm", "std"),
  family_set = c("gaussian", "t")
)
fit
summary(fit)

The fitted object contains the marginal models in fit$margins and the copula model in fit$copula. Standard rvinecopulib methods can be applied to the copula component.

Simulation and diagnostics

Without a conditioning history, svine_sim() generates a new stationary time series. Supplying past instead generates paths conditional on the observed history.

sim <- svine_sim(n = 100, rep = 1, model = fit)
dim(sim)

next_obs <- svine_sim(n = 1, rep = 100, model = fit, past = x)
dim(next_obs)

Pseudo-residuals are conditional Rosenblatt transforms. For a fitted model of order p, the result has NROW(x) - p rows.

residuals <- svine_pseudo_residuals(x, fit)
dim(residuals)

Discrete variables

For discrete variables, specify var_types = "d" and restrict margin_families to suitable discrete families. The following model uses two Poisson margins.

counts <- cbind(
  claims = rpois(250, lambda = 2),
  events = rpois(250, lambda = 4)
)

fit_discrete <- svine(
  counts,
  p = 1,
  var_types = c("d", "d"),
  margin_families = "pois",
  family_set = "gaussian"
)
fit_discrete
svine_sim(5, rep = 1, model = fit_discrete)

svine() evaluates both the CDF, F(x), and its left limit, F(x-), and constructs the copula data automatically. When calling svinecop() directly, supply the regular CDF columns first, followed by one left-limit column for each discrete variable.

Copula-only models

When the marginal transformation is handled separately, fit the copula layer directly.

u <- pseudo_obs(x)
copula_fit <- svinecop(
  u,
  p = 1,
  family_set = c("gaussian", "t")
)
copula_fit

Use svinecop_loglik(), svinecop_scores(), and svinecop_hessian() for copula-level inference. The corresponding svine_* functions include the marginal parameters.



Try the svines package in your browser

Any scripts or data that you put into this service are public.

svines documentation built on Sept. 1, 2026, 1:08 a.m.