CCGamma: This function extends 'continuity_ratio' and adds the...

View source: R/Gamma.R

CCGammaR Documentation

This function extends continuity_ratio and adds the corresponding gaussian correlation matrix for no-precipitation occurrence.

Description

This function extends continuity_ratio and adds the corresponding gaussian correlation matrix for no-precipitation occurrence.

Usage

CCGamma(
  data,
  lag = 0,
  p0_v1 = NULL,
  p = NA,
  valmin = 0.5,
  nearPD = (lag >= 0),
  interval = c(-1, 1),
  tolerance = .Machine$double.eps,
  only.matrix = FALSE,
  return.value = NULL,
  null.gcorrelation = 1e-05,
  sample = NULL,
  origin = "1961-1-1",
  ...
)

Arguments

data

data frame or 'zoo' R object containing daily precipitation time series for several gauges (one gauge time series per column). See continuity_ratio.

lag

numeric lag (expressed as number of days) used for computation for "cross" continuity ratio and joint probability of prercipitation (no)occurrence. See continuity_ratio.

p0_v1

vector for marginal probablities, see omega and omega_inv.

p

positive integer parameter. Default is NA, otherwise, lag is calculated as the vector 0:p.

valmin

threshold precipitation value [mm] for wet/dry day indicator. If precipitation is lower than valmin, day is considered dry. Default is 0.5 mm. See continuity_ratio.

nearPD

see omega_inv. Default is (lag==0).

interval, tolerance

see omega_inv

only.matrix

logical value. If TRUE the function returns only the gaussian correlaton matrix. Deafaul is FALSE.

return.value

string. If it is not either NULL (Default) and NA, function returns only the argument indicated by this argument.

null.gcorrelation

numerical value nooccurrence_gcorrelation under which is considered to be 0.

sample

character string indicated if function must be calculated differently for subset of the year, e.g. monthly. Admitted values are NULL (Default), "all" or "monthly".

origin

character string (yyyy-dd-mm) indicated the date of the first row of "data". It is used if data and sample are not NULL.

...

additional agruments of omega_inv or CCGamma

Value

An object which is a list containing the following fields:

continuity_ratio : lag-day lagged continuity ratio, as returned by continuity_ratio;

occurrence : joint probability of lag-day lagged precipitation occurrence, as returned by continuity_ratio;

nooccurrence : joint probability of lag-day lagged no precipitation occurrence, as returned by continuity_ratio;

lag : number of days lagged between the two compared events (see argument lag);

p0_v1 : vector of marginal probability of no precipitation occurrence. If lag is 0, it corresponds to the diagonal of nooccurrence matrix (see argument p0_v1);

nooccurrence_gcorrelation corresponding gaussian correlation for no precipitation occurrence obtained by applying omega_inv to nooccurrence,

If the argument only.matrix is TRUE, only nooccurrence_gcorrelation is returned as a matrix. In case the argument lag is a vector wirh length more than one, the function returns a list of the above-cited return object for each value of the vector lag.

Note

This functon is useful to generate the serial cross-correlation matrices for no precipitation occurrence for Yule-Walker Equations. In case lag is a vactor, nearPD must be a vector of the same size, default is (lag==0).

See the R code for major details

Author(s)

Emanuele Cordano

References

D.S. Wilks (1998), Multisite Generalization of a Daily Stochastic Precipitation Generation Model, Journal of Hydrology, Volume 210, Issues 1-4, September 1998, Pages 178-191, https://www.sciencedirect.com/science/article/pii/S0022169498001863

Muamaraldin Mhanna and Willy Bauwens (2011) A Stochastic Space-Time Model for the Generation of Daily Rainfall in the Gaza Strip, International Journal of Climatology, Volume 32, Issue 7, pages 1098-1112, doi: 10.1002/joc.2305, https://rmets.onlinelibrary.wiley.com/doi/abs/10.1002/joc.2305

See Also

continuity_ratio,omega_inv,omega,CCGammaToBlockmatrix

Examples


data(trentino)

year_min <- 1961
year_max <- 1990
origin <- paste(year_min,1,1,sep="-")

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]

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

## Not Run in the examples, uncomment to run the following line
 CCGamma <- CCGamma(data=prec_mes,lag=0:2,tolerance=0.001,only.matrix=FALSE)

## Not Run in the examples, uncomment to run the following line
 CCGamma_monthly <- CCGamma(data=prec_mes,lag=0,tolerance=0.001,only.matrix=FALSE,
                     sample="monthly",origin=origin)



ecor/RGENERATEPREC documentation built on Feb. 3, 2023, 10:38 a.m.