est_cov: Covariance matrix of PWMs, TLMoments, parameters, or... In TLMoments: Calculate TL-Moments and Convert Them to Distribution Parameters

Description

Calculation of the empirical or theoretical covariance matrix of objects of the classes `PWMs`, `TLMoments`, `parameters`, or `quantiles`.

Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```est_cov(x, ...) ## S3 method for class 'PWMs' est_cov(x, select = attr(x, "order"), ...) ## S3 method for class 'TLMoments' est_cov(x, select = attr(x, "order"), ...) ## S3 method for class 'parameters' est_cov(x, select = c("loc", "scale", "shape"), ...) ## S3 method for class 'quantiles' est_cov(x, select = attr(x, "p"), ...) ```

Arguments

 `x` object of `PWMs`, `TLMoments`, `parameters`, or `quantiles` constructed using the same-named functions. `...` additional arguments given to the sub-functions: `distr` and `np.cov` (see details). `select` numeric oder character vector specifying a subset of the covariance matrix. If not specified the full covariance matrix is returned.

Details

Covariance matrices of `PWMs` and `TLMoments` are calculated without parametric assumption by default. Covariance matrices of `parameters` and `quantiles` use parametric assumption based on their stored distribution attribute (only GEV at the moment). Parametric (GEV) calculation can be enforced by specifying `distr=\"gev\"`, non-parametric calculation by using `np.cov=TRUE`.

Value

numeric matrix (if `x` is of class `PWMs`, `parameters`, or `quantiles`) or a list of two matrices (`lambdas` and `ratios`, if `x` is of class `TLMoments`).

`PWMs`, `TLMoments`, `parameters`, `quantiles`
 ``` 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120``` ```### 1: PWMs: xvec <- rgev(100, shape = .1) xmat <- cbind(rgev(100, shape = .1), rgev(100, shape = .3)) # Covariance estimation of PWMs normally without parametric assumption: est_cov(PWMs(xvec)) est_cov(PWMs(xvec), select = 0:1) est_cov(PWMs(xmat)) est_cov(PWMs(xmat), select = 3) est_cov(PWMs(xmat[, 1, drop = FALSE]), select = 2:3) # Parametric assumptions (only GEV by now) can be used: est_cov(PWMs(xvec), distr = "gev") est_cov(PWMs(xvec), distr = "gev", select = c(1, 3)) ## Not run: cov(t(replicate(100000, as.vector(PWMs(cbind(rgev(100, shape = .1), rgev(100, shape = .3)), max.order = 1))) )) ## End(Not run) ### 2. TLMoments: xvec <- rgev(100, shape = .1) xmat <- cbind(rgev(100, shape = .1), rgev(100, shape = .3)) # Covariance estimation of TLMoments normally without parametric assumption: est_cov(TLMoments(xvec)) est_cov(TLMoments(xvec, rightrim = 1)) est_cov(TLMoments(xvec), select = 3:4) # Parametric assumptions (only GEV by now) can be used: est_cov(TLMoments(xvec), distr = "gev") # Matrix inputs est_cov(TLMoments(xmat)) est_cov(TLMoments(xmat), select = 3:4) est_cov(TLMoments(xmat[, 1, drop = FALSE]), select = 3:4) # Covariance of theoretical TLMoments only with parametric assumption: est_cov(as.TLMoments(c(14, 4, 1)), distr = "gev", set.n = 100) est_cov(as.TLMoments(c(14, 4, 1), rightrim = 1), distr = "gev", set.n = 100) # Regionalized TLMoments est_cov(regionalize(TLMoments(xmat), c(.75, .25))) est_cov(regionalize(TLMoments(xmat), c(.75, .25)), distr = "gev", select = 3:4) ### 3. Parameters: xvec <- rgev(100, shape = .1) xmat <- cbind(rgev(100, shape = .1), rgev(100, shape = .3)) # Covariance estimation of parameters normally with parametric assumption: est_cov(parameters(TLMoments(xvec), "gev")) est_cov(parameters(TLMoments(xvec, rightrim = 1), "gev")) est_cov(parameters(TLMoments(xvec, rightrim = 1), "gev"), select = c("scale", "shape")) # A nonparametric estimation can be enforced with np.cov: est_cov(parameters(TLMoments(xvec), "gev"), np.cov = TRUE) est_cov(parameters(TLMoments(xvec, rightrim = 1), "gev"), np.cov = TRUE) # Matrix inputs est_cov(parameters(TLMoments(xmat), "gev")) est_cov(parameters(TLMoments(xmat), "gev"), select = "shape") est_cov(parameters(TLMoments(xmat[, 1]), "gev"), select = "shape") # Theoretical values (leftrim and/or rightrim have to be specified) para <- as.parameters(loc = 10, scale = 5, shape = .2, distr = "gev") est_cov(para, set.n = 100) est_cov(para, rightrim = 1, set.n = 100) ## Not run: var(t(replicate(10000, parameters(TLMoments(rgev(100, 10, 5, .2)), "gev")))) ## End(Not run) ## Not run: var(t(replicate(10000, parameters(TLMoments(rgev(100, 10, 5, .2), rightrim = 1), "gev")))) ## End(Not run) # Parameter estimates from regionalized TLMoments: est_cov(parameters(regionalize(TLMoments(xmat), c(.75, .25)), "gev")) ### 4. Quantiles: xvec <- rgev(100, shape = .2) xmat <- cbind(rgev(100, shape = .1), rgev(100, shape = .3)) # Covariance estimation of parameters normally with parametric assumption: q <- quantiles(parameters(TLMoments(xvec), "gev"), c(.9, .95, .99)) est_cov(q) est_cov(q, select = c("0.9", "0.99")) est_cov(q, select = .95) # A nonparametric estimation can be enforced with np.cov: est_cov(q, np.cov = TRUE) # Matrix inputs param <- parameters(TLMoments(xmat, 0, 1), "gev") q <- quantiles(param, c(.9, .95, .99)) est_cov(q) est_cov(q, select = .99) param <- parameters(TLMoments(xmat[, 1, drop = FALSE], 0, 1), "gev") q <- quantiles(param, c(.9, .95, .99)) est_cov(q, select = .99) # Theoretical values q <- quantiles(as.parameters(loc = 10, scale = 5, shape = .3, distr = "gev"), c(.9, .99)) est_cov(q) est_cov(q, leftrim = 0, rightrim = 1) est_cov(q, leftrim = 0, rightrim = 1, set.n = 100) # Quantile estimates from regionalized TLMoments: param <- parameters(regionalize(TLMoments(xmat), c(.75, .25)), "gev") est_cov(quantiles(param, c(.9, .99))) ```