choc: choc carry out a choc analysis on a multivariate time series

View source: R/choc.R

chocR Documentation

choc carry out a choc analysis on a multivariate time series

Description

choc carry out a choc analysis on a multivariate time series

Usage

choc(mydata, H, timevar, weights = NULL, resolution = 100, ncores = 1)

Arguments

mydata

a data frame or matrix with one column per time series and one row per observation (event). Marginal distributions are assumed to follow a normal distribution

H

either a function from library ks to estimate a bandwith matrix, or directly a bandwith matrix. Exemples of function Hpi or Hscv...

timevar

a vector specifying the time step for each observation. Several observations per time step are required. Observations of a same time step are assumed to be replicates.

weights

weights of the observations

resolution

grid resolution on which the densities of probability will be computed. The resolution does not affect the result: high resolution increases the resolution of final diagrams but increases computation time and memory usage. The number of observations per time step should be roughly similar

ncores

Number of cores used. The parallelization will take place only if OpenMP is supported.

Value

a chocR object, i.e. a list with 5 elements:

  1. list_data the list of data per time step

  2. grid a dafaframe with one row per time series and a column tau that gives the tau of Kendall trend test

  3. cholH the cholesky decomposition of H

  4. list_weights the weights of observation

  5. root_i a transformation of inv(trimatu(cholH))

Examples

#generate artificial data set
#two time series measured on 40 time steps with 100 observations per time step.
#the two series follow a multinormal time series with a tend on means and a constant
#covariance matrix
if (require(MASS) & require(ks)){
  tvar <- rep(1:40,times=100) #times steps
  meansX <-tvar/40 #trend on 1st variable
  meansY <- -0.5*tvar/40 #trend on 2nd variable
  sigma <- matrix(c(1,.1,.1,1),2,2) #covariance matrix
  values <- t(apply(cbind(meansX,meansY),1,function(mu) mvrnorm(1,mu,sigma))) #generate the values
  H <- Hpi #choose the default bandwith
  res_choc <- choc(values,H,tvar)
}


Irstea/chocR documentation built on June 12, 2022, 8:28 p.m.