Learn R Programming

VARcpDetectOnline (version 0.2.0)

generateVAR: Generate VAR Data

Description

This function generates Vector Auto-Regressive (VAR) data based on the provided parameters.

Usage

generateVAR(n, As, Sig, h, isOldProvided = FALSE, oldxs = NULL)

Value

A data matrix of dimensions p by n.

Arguments

n

Integer. The length of the VAR data to be generated.

As

List. A list containing the transition matrices for the VAR process.

Sig

Matrix. The covariance matrix of errors.

h

Integer. The order of the VAR process.

isOldProvided

Logical. If TRUE, the VAR data will be generated based on the last observations from the previous segment of data. Defaults to FALSE.

oldxs

Matrix. A p by h matrix containing the last observations from the previous segment of data. Required if isOldProvided = TRUE.

Examples

Run this code
# Example usage
As <- list(matrix(c(0.5, 0.2, 0.1, 0.4), 2, 2))
Sig <- diag(2)
data <- generateVAR(n = 100, As = As, Sig = Sig, h = 1)

Run the code above in your browser using DataLab