Non-parametric quantile mapping using robust empirical quantiles.

Share:

Description

fitQmapRQUANT estimates the values of the quantile-quantile relation of observed and modelled time series for regularly spaced quantiles using local linear least square regression. doQmapRQUANT performs quantile mapping by interpolating the empirical quantiles.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
fitQmapRQUANT(obs, mod, ...)
## Default S3 method:
fitQmapRQUANT(obs,mod,wet.day=TRUE,qstep=0.01,
nlls = 10,nboot = 10,...)
## S3 method for class 'matrix'
fitQmapRQUANT(obs, mod, ...)
## S3 method for class 'data.frame'
fitQmapRQUANT(obs, mod, ...)

doQmapRQUANT(x,fobj,...)
## Default S3 method:
doQmapRQUANT(x,fobj,slope.bound=c(lower=0,upper=Inf), 
type=c("linear","linear2","tricub"),...)
## S3 method for class 'matrix'
doQmapRQUANT(x,fobj,...)
## S3 method for class 'data.frame'
doQmapRQUANT(x,fobj,...)

Arguments

obs

numeric vector, column matrix or data.frame with observed time series.

mod

numeric vector or column matrix/data.frame with modelled time series, corresponding to obs

wet.day

logical, indicating whether to perform wet day correction or not. OR a numeric threshold below which all values are set to zero. See details.

qstep

A numeric value between 0 and 1. The values quantile-quantile plot are estimated at the position of the values defined by:

quantile(mod,probs=seq(0,1,by=qstep).

nlls

number of nearest data points to apply in the local regression

nboot

number of bootstrap samples in the estimation of the transformation. If nboot==1 the estimation is based on all (and not resampled) data.

x

numeric vector or a column matrix of modelled time series

fobj

output from fitQmapRQUANT

slope.bound

bounds for the slopes in case of extrapolation. Applies only if type="linear2"

type

type of interpolation between the fitted transformed values. See details

...

Further arguments passed to methods

Details

fitQmapRQUANT produces a robust estimate of the empirical quantile-quantile plot (QQ-plot) of mod vs obs for the seq(0,1,by=qstep) quantiles mod. The corresponding value of the quantiles of obs is estimated using local linear least squares regression. For each quantile of mod the nlls nearest data points in the QQ-plot are identified and used to fit a local regression line. This regression line is then used to estimate value of the quantile of obs. The estimation is replicated for nboot bootstrap samples and the mean of the bootstrap replicates is returned.

This procedure results in a table with empirical quantiles of mod and a corresponding table with robust estimates of the empirical quantiles of obs.

doQmapRQUANT uses the tables of robust empirical quantiles identified using fitQmapRQUANT to transform the variable x. For values that are not in

quantile(mod,probs=seq(0,1,by=qstep)) the transformation is estimated using interpolation of the fitted values. Available interpolation options are:

type="linear": linear interpolation using approx, but using the extrapolation suggested by Boe et al. (2007) for values of x larger than max(mod) (constant correction).

type="linear2": linear interpolation using approx. For any value of x outside range(mod) the transformation is extrapolated using the slope of the local linear least squares regression at the outer most points.

type="tricube": monotonic tricubic spline interpolation using splinefun. Spline interpolation is performed using a _monotone_ Hermite spline (method="monoH.FC" in splinefun).

wet.day is intended for the use for precipitation data. Wet day correction attempts to equalise the fraction of days with precipitation between the observed and the modelled data. If wet.day=TRUE the empirical probability of nonzero observations is found (obs>=0) and the corresponding modelled value is selected as a threshold. All modelled values below this threshold are set to zero. If wet.day is numeric the same procedure is performed after setting all obs<wet.day to zero.

Value

fitQmapRQUANT returns an object of class fitQmapRQUANT containing following elements:

par

A list containing:

par$modq

a matrix. Each column i corresponds to the output of

quantile(mod[,i],probs=seq(0,1,by=qstep)).

par$fitq

the fitted values of the local linear least square regression corresponding to par$modq

par$slope

a matrix. the columns correspond to the columns of mod. The rows contain the slope of the "lower" and the "upper" extreme points of the local linear fit and is used for extrapolation if type="linear2".

wet.day

logical, indicating whether to perform wet day correction or not. OR a numeric threshold below which all values are set to zero.

doQmapRQUANT returns a numeric vector or matrix depending on the format of x.

Author(s)

John Bjornar Bremnes and Lukas Gudmundsson

References

Boe, J.; Terray, L.; Habets, F. & Martin, E. Statistical and dynamical downscaling of the Seine basin climate for hydro-meteorological studies. International Journal of Climatology, 2007, 27, 1643-1655, doi: 10.1002/joc.1602.

See Also

fitQmap

Examples

 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
data(obsprecip)
data(modprecip)

## single series example
qm.fit <- fitQmapRQUANT(obsprecip[,2],modprecip[,2],
                      qstep=0.1,nboot=10,wet.day=TRUE)
qm.a <- doQmapRQUANT(modprecip[,2],qm.fit,type="linear")
qm.b <- doQmapRQUANT(modprecip[,2],qm.fit,type="tricub")

sqrtquant <- function(x,qstep=0.01){
  qq <- quantile(x,prob=seq(0,1,by=qstep))
  sqrt(qq)
}

plot(sqrtquant(modprecip[,2]),
     sqrtquant(obsprecip[,2]))
lines(sqrtquant(modprecip[,2]),
      sqrtquant(qm.a),col="red")
lines(sqrtquant(modprecip[,2]),
      sqrtquant(qm.b),col="blue")
points(sqrt(qm.fit$par$modq),sqrt(qm.fit$par$fitq),
       pch=19,cex=1,col="green")
legend("topleft",
       legend=c("linear","tricub","support","data"),
       lty=c(1,1,NA,NA),pch=c(NA,NA,19,21),
       col=c("red","blue","green","black"))

qm2.fit <- fitQmapRQUANT(obsprecip,modprecip,
                       qstep=0.02,nboot=1,
                       wet.day=TRUE)
qm2 <- doQmapRQUANT(modprecip,qm2.fit,type="tricub")

op <- par(mfrow=c(1,3))
for(i in 1:3){
  plot(sqrtquant(modprecip[,i]),
       sqrtquant(obsprecip[,i]),
       main=names(qm2)[i])
  lines(sqrtquant(modprecip[,i]),
        sqrtquant(qm2[,i]),col="red")
  points(sqrt(qm2.fit$par$modq[,i]),
         sqrt(qm2.fit$par$fitq[,i]),
       pch=19,cex=0.5,col="green")

}
par(op)