wquantile: Weighted Quantiles

Description Usage Arguments Author(s) See Also Examples

View source: R/wquantile.R

Description

This function computes weighted quantiles of each column (by default, or for each row if specified by the user) of a matrix/data.frame

It is a wrapper to the wtd.quantile function of the Hmisc package, specially thought for a matrix containing streamflows simulated by different (behavioural) parameter sets

Usage

1
2
wquantile(x, weights=NULL, byrow=FALSE, probs=c(.025, .5, .975), 
          normwt=TRUE, verbose=TRUE)

Arguments

x

numeric or matrix for the computation of the weighted quantiles

weights

numeric vector, values of the weights to be used for computing the quantiles. See wtd.quantile.
Omitting the weights argument or specifying NULL or a zero-length vector will result in the usual unweighted estimates

byrow

logical, indicates if the computations have to be made for each column or for each row of x
When the simulated values obtained with different behavioural parameter sets are stored in columns, byrow must be TRUE
When the simulated values obtained with different behavioural parameter sets are stored in rows, byrow must be FALSE

probs

numeric vector, quantiles to be computed. wtd.quantile
Default value is c(.025, .5, .975) ( => 2.5%, 50%, 97.5% )

normwt

See wtd.quantile. Specify normwt=TRUE to make weights sum to length(x) after deletion of NAs

verbose

logical; if TRUE, progress messages are printed

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail.com

See Also

wtd.quantile

Examples

1
2
3
4
5
6
7
8
# random matrix with 100 parameter sets (in rows) corresponding to 10
# different parameters
params <- matrix(rnorm(1000), ncol=10, nrow=100)
colnames(params) <- paste("Param", 1:10, sep="")

# empirical CDFs for each one of the 10 parameters of x, with equal weight for 
# each one of the 100 parameter sets
wquantile(params, weights=rep(1,100), byrow=FALSE) 

Example output

(C) 2011-2018 M. Zambrano-Bigiarini and R. Rojas (GPL >=2 license)
Type 'citation('hydroPSO')' to see how to cite this package
Warning message:
no DISPLAY variable so Tk is not available 

  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |======================================================================| 100%
             2.5%         50%    97.5%
Param1  -2.222544  0.02585961 1.847638
Param2  -2.089136  0.04207133 1.662706
Param3  -2.151185 -0.24140000 2.235018
Param4  -1.738949  0.06094144 2.047886
Param5  -2.133968 -0.07992169 1.786849
Param6  -1.923354 -0.04437088 1.993409
Param7  -2.221382 -0.05981650 2.002261
Param8  -1.735820  0.16237742 1.987232
Param9  -2.067312 -0.08451873 1.947128
Param10 -1.755331  0.21500000 1.762396

hydroPSO documentation built on April 29, 2020, 9:37 a.m.