Learn R Programming

hydroPSO (version 0.5-1)

wquantile: Weighted Quantiles

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

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

See Also

wtd.quantile

Examples

Run this code
# NOT RUN {
# 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) 
# }

Run the code above in your browser using DataLab