Learn R Programming

gctsc (version 0.1.3)

sim_gctsc: Simulate from Gaussian Copula Time Series Models

Description

These functions simulate time series data from Gaussian copula models with various discrete marginals and an ARMA dependence structure.

Usage

sim_poisson(mu, tau, arma_order, nsim = 100, seed = NULL)

sim_negbin(mu, dispersion, tau, arma_order, nsim = 100, seed = NULL)

sim_zip(mu, pi0, tau, arma_order, nsim = 100, seed = NULL)

sim_binom(prob, size, tau, arma_order, nsim = 100, seed = NULL)

sim_bbinom(prob, rho, size, tau, arma_order, nsim = 100, seed = NULL)

sim_zib(prob, pi0, size, tau, arma_order, nsim = 100, seed = NULL)

sim_zibb(prob, rho, pi0, size, tau, arma_order, nsim = 100, seed = NULL)

Value

A list with components:

  • y: Simulated time series data.

  • z: Latent Gaussian process values.

  • marginal: Marginal distribution name.

  • parameters: List of parameters used.

  • cormat: ARMA structure.

Arguments

mu

Mean parameter(s):

  • For Poisson, ZIP, and negative binomial: \(\mu > 0\).

  • Scalar or vector of length nsim.

tau

Numeric vector of ARMA coefficients, ordered as c(phi_1, ..., phi_p, theta_1, ..., theta_q). ARMA(0,0) is not supported.

arma_order

Integer vector c(p, q) giving AR and MA orders.

nsim

Positive integer; number of time points to simulate.

seed

Optional integer to set the random seed.

dispersion

Overdispersion parameter for negative binomial marginals (\(\kappa > 0\) in \(\mathrm{Var}(Y) = \mu + \kappa \mu^2\)).

pi0

Zero-inflation probability for ZIP, ZIB, and ZIBB marginals: \(0 \le \pi_0 < 1\), scalar or length nsim.

prob

Probability parameter(s) for binomial-type marginals: \(0 < p < 1\), scalar or length nsim.

size

Number of trials for binomial-type marginals; positive integer (scalar).

rho

Intra-cluster correlation for beta-binomial and ZIBB marginals (\(0 < \rho < 1\) in \(\mathrm{Var}(Y) = n p (1-p) [1 + (n-1)\rho]\)) where \(n\) is the number of trials.

Details

Marginal types:

  • Poisson: Counts with mean \(\mu\).

  • Negative binomial (NB): Overdispersed counts with mean \(\mu\) and dispersion parameter \(\kappa\).

  • Binomial: Number of successes in \(n\) trials with success probability \(p\).

  • Beta–-binomial (BB): Binomial with success probability \(p\) following a beta distribution, allowing intra-cluster correlation \(\rho\).

  • Zero--inflated Poisson (ZIP): Poisson with extra probability \(\pi_0\) of an excess zero.

  • Zero--inflated binomial (ZIB): Binomial with extra probability \(\pi_0\) of an excess zero.

  • Zero--inflated beta–binomial (ZIBB): Beta–binomial with extra probability \(\pi_0\) of an excess zero.

Parameterization notes:

  • Negative binomial uses dispersion (\(\kappa\)) to model overdispersion: larger dispersion increases variance for a fixed mean.

  • Beta--binomial and ZIBB use rho as the overdispersion parameter: \(\rho\) is the intra-class correlation, with \(\rho \to 0\) giving the binomial model.

  • Zero--inflated marginals include a separate pi0 parameter that controls the extra probability mass at zero.

Examples

Run this code
# Poisson example
sim_poisson(mu = 10, tau = c(0.2, 0.2), arma_order = c(1, 1), nsim = 100, seed = 42)

# Negative Binomial example
sim_negbin(mu = 10, dispersion = 2, tau = c(0.5, 0.5), arma_order = c(1, 1))

# Beta-Binomial example with seasonal covariates
n <- 100
xi <- numeric(n)
zeta <- rnorm(n)
for (j in 3:n) {
  xi[j] <- 0.6 * xi[j - 1] - 0.4 * xi[j - 2] + zeta[j]
}
prob <- plogis(0.2 + 0.3 * sin(2 * pi * (1:n) / 12) +
             0.5 * cos(2 * pi * (1:n) / 12) + 0.3 * xi)
sim_zibb(prob, rho = 1/6, pi0 = 0.2, size = 24, tau = 0.5, arma_order = c(1, 0))

Run the code above in your browser using DataLab