generate: generate

Description Usage Arguments Details Value See Also Examples

Description

generate

generate

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## S3 method for class 'YuleWalkerCoefficientBlockmatrices'
generate(x, FUN = rnorm,
  n = 100, names = NULL, xprev = NULL, names_x = c("A", "Sigma_u",
  "CCGammaInfo"), nearPD = TRUE, precipitation.indicator = FALSE, ...)

## S3 method for class 'YuleWalkerCoefficientBlockmatricesPerEachMonth'
generate(x,
  FUN = rnorm, year_min = 1961, year_max = 1990, names = NULL,
  xprev = NULL, names_x = c("A", "Sigma_u", "CCGammaInfo"), nearPD = TRUE,
  precipitation.indicator = FALSE, ...)

## S3 method for class 'CCGammaObject'
generate(x, n = 100, names = NULL, xprev = NULL,
  precipitation.indicator = TRUE, ...)

## S3 method for class 'CCGammaObjectListPerEachMonth'
generate(x, year_min = 1961,
  year_max = 1990, names = NULL, xprev = NULL,
  precipitation.indicator = TRUE, ...)

Arguments

x

YuleWalkerCoefficientBlockmatrices S3 object. See CoeffYWeq

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.

xprev

null object or initial condition of the multivariate random process to be generated. Default is NULL.

names_x

names of the elements of a YuleWalkerCoefficientBlockmatrices S3 object. See examples.

nearPD

logical. If TRUE (Default) the function nearPD is applied to the covariance matrix of residuals. If FALSE, the estimated covariance matrix is not verified to be positive definite and error may occur during the function execution.

precipitation.indicator

logical value. Default is FALSE. If it is TRUE, the output is transformed to a number between 0 (no precipitation) and 1 (high precipitation) taking into account the probabability of no occurence and the cumulate probability function referred to FUN.

year_min,year_max

first and last years of generation period

...

additional arguments for FUN

Details

Implementation of generate method for YuleWalkerCoefficientBlockmatrices or CCGammaObject S3 object. It generates a multivarite random series according using a VAR model with coefficient obtained by CoeffYWeq (YuleWalkerCoefficientBlockmatrices S3 object) . Alternatively it generates by applying a first-order Markov Cain from CCGammaObject S3 Object.

Value

a matrix or a data frame object

See Also

CoeffYWeq,CCGammaToBlockmatrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
library(RMRAINGEN)

set.seed(125)
data(trentino)

year_min <- 1961
year_max <- 1990

period <- PRECIPITATION$year>=year_min & PRECIPITATION$year<=year_max
station <- names(PRECIPITATION)[!(names(PRECIPITATION) %in% c("day","month","year"))]
prec_mes <- PRECIPITATION[period,station]

## removing nonworking stations (e.g. time series with NA)
accepted <- array(TRUE,length(names(prec_mes)))
names(accepted) <- names(prec_mes)
for (it in names(prec_mes)) {
		 accepted[it]  <- (length(which(!is.na(prec_mes[,it])))==length(prec_mes[,it]))
}

prec_mes <- prec_mes[,accepted]
## the dateset is reduced!!!
prec_mes <- prec_mes[,1:2]

## Not Run in the examples, uncomment to run the following lines
# coeff <- CoeffYWeq(data=prec_mes,p=1,tolerance=0.001)

# generation <- generate(coeff,n=10,names=names(prec_mes))


## Not Run in the examples, uncomment to run the following lines
# origin <- paste(year_min,1,1,sep="-")


# coeff_monthly <- CoeffYWeq(data=prec_mes,p=1,tolerance=0.001,sample="monthly",origin=origin)


# generation_monthly <- generate(coeff_monthly,year_min=year_min,year_max=year_max,
#					names=names(prec_mes))


###  generation with CCGammaObject

# CCGamma <- CCGamma(data=prec_mes,lag=0,tolerance=0.001,only.matrix=FALSE)

# generation_CCGamma <- generate(x=CCGamma,n=100,names=names(prec_mes))

# CCGamma_monthly <- CCGamma(data=prec_mes,lag=0,tolerance=0.001,only.matrix=FALSE,
#                            sample="monthly",origin=origin)
## generation_CCGamma <- generate(x=CCGamma_monthly,year_min=year_min,year_max=year_max,
##                                names=names(prec_mes))

ecor/RMRAINGEN documentation built on May 15, 2019, 8:53 p.m.