Learn R Programming

RGENERATE (version 1.0)

generate: generate

Description

generate

It generates a multivarite random series according to the model x

Usage

generate(x = NULL, ...)

## S3 method for class 'default': generate(x, FUN = rnorm, n = 100, K = 3, names = NULL, cov = NULL, ...)

## S3 method for class 'varest': generate(x, FUN = rnorm, n = 100, names = NULL, noise = NULL, exogen = NULL, xprev = NULL, ...)

## S3 method for class 'varest2': generate(x, FUN = rnorm, n = 100, names = NULL, noise = NULL, exogen = NULL, xprev = NULL, ...)

## S3 method for class 'GPCAvarest2': generate(x, FUN = rnorm, n = 100, names = NULL, noise = NULL, exogen = NULL, xprev = NULL, extremes = TRUE, type = 3, ...)

Arguments

x
null object or the model used for random generation , e.g. a VAR model as a varest-class or varest2-class object. Default is NULL
FUN
random function of the probability distribution used for noise random generation. Default is rnorm. See http://cran.r-project.org/web/views/Distributions.html
n
number of generations requested
names
null object or string vectors or names of the variables to be generated simultaneously. Default is NULL.
K
number of the variables to be generated simultaneously, i.e. the K parameters of a VAR. It is automatically detected by x, names or cov, if one of these is not NULL.
cov
null object or covariance matrix of the random variables to be generated simultaneously. Default is NULL, not used in case this information can be detected from x.
noise
null object or a generic external noise for x model residuals, e.g. standard white noise, for random generation with the model x. Default is NULL. If NULL the noise is automatically calculated.
exogen
null object or amatrix or data frame with exogeneous variables (predictors) id requested by x. Default is NULL
xprev
null object or initial condition of the multivariate random process to be generated. Default is NULL.
...
further arguments for FUN
extremes,type

Value

  • a matrix or a data frame object

See Also

getVARmodel

Examples

Run this code
library(RGENERATE)

set.seed(122)
NSTEP <- 1000
x <- rnorm(NSTEP)
y <- x+rnorm(NSTEP)
z <- c(rnorm(1),y[-1]+rnorm(NSTEP-1))
df <- data.frame(x=x,y=y,z=z)
var <- VAR(df,type="none")
gg <- generate(var,n=20)

cov <- cov(gg)

ggg <- generate(FUN=rnorm,n=NSTEP,cov=cov)


library(RMAWGEN)
exogen <- as.data.frame(x+5)
gpcavar <- getVARmodel(data=df,suffix=NULL,p=3,n_GPCA_iteration=5,
n_GPCA_iteration_residuals=5,exogen=exogen)
gpcagg <- generate(gpcavar,n=20,exogen=exogen)

Run the code above in your browser using DataLab