Learn R Programming

qmap (version 1.0-4)

fitQmapQUANT: Non-parametric quantile mapping using empirical quantiles.

Description

fitQmapQUANT estimates values of the empirical cumulative distribution function of observed and modelled time series for regularly spaced quantiles. doQmapQUANT uses these estimates to perform quantile mapping.

Usage

fitQmapQUANT(obs, mod, ...) "fitQmapQUANT"(obs,mod,wet.day=TRUE,qstep=0.01, nboot = 1,...) "fitQmapQUANT"(obs, mod, ...) "fitQmapQUANT"(obs, mod, ...)
doQmapQUANT(x,fobj,...) "doQmapQUANT"(x,fobj, type=c("linear","tricub"),...) "doQmapQUANT"(x,fobj,...) "doQmapQUANT"(x,fobj,...)

Arguments

obs
numeric vector, column matrix or data.frame with observed time series.
mod
numeric vector, column matrix or 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 quantile mapping is fitted only for the quantiles defined by quantile(0,1,probs=seq(0,1,by=qstep).
nboot
number of bootstrap samples used for estimation of the observed quantiles. If nboot==1 the estimation is based on all (and not resampled) data. See details.
x
numeric vector or a column matrix of modelled time series
fobj
output from fitQmapQUANT
type
type of interpolation between the fitted transformed values. See details.
...
Further arguments passed to methods

Value

fitQmapQUANT returns an object of class fitQmapQUANT 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
observed empirical quantiles corresponding to par$modq.
wet.day
logical, indicating whether to perform wet day correction or not. OR a numeric threshold below which all values are set to zero.
doQmapQUANT returns a numeric vector or matrix depending on the format of x.

Details

fitQmapQUANT estimates the empirical cumulative distribution function of mod and obs for the quantiles defined by seq(0,1,by=qstep). The quantiles of mod are estimated using the empirical quantiles. If nboot>1 the quantiles of obs are estimated as the mean of nboot bootstrap samples (if nboot>1).

doQmapQUANT transforms the variable x based on the transformation identified using fitQmapQUANT. For all 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="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 to zero.

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.

For a general assessment of the methods see:

Gudmundsson, L.; Bremnes, J. B.; Haugen, J. E. & Engen-Skaugen, T. Technical Note: Downscaling RCM precipitation to the station scale using statistical transformations - a comparison of methods. Hydrology and Earth System Sciences, 2012, 16, 3383-3390, doi:10.5194/hess-16-3383-2012.

See Also

fitQmap

Examples

Run this code
data(obsprecip)
data(modprecip)

qm.fit <- fitQmapQUANT(obsprecip[,2],modprecip[,2],
                      qstep=0.1,nboot=1,wet.day=TRUE)
qm.a <- doQmapQUANT(modprecip[,2],qm.fit,type="linear")
qm.s <- doQmapQUANT(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.s),col="blue")
points(sqrt(qm.fit$par$modq),sqrt(qm.fit$par$fitq),
       pch=19,cex=0.5,col="green")
legend("topleft",
       legend=c("linear","tricub","support"),
       lty=c(1,1,NA),pch=c(NA,NA,19),
       col=c("red","blue","green"))
         

qm2.fit <- fitQmapQUANT(obsprecip,modprecip,
                      qstep=0.01,nboot=1,wet.day=TRUE)
qm2 <- doQmapQUANT(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)


Run the code above in your browser using DataLab