fitqmapssplin: Quantile mapping using a smoothing spline

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

fitQmapSSPLIN fits a smoothing spline to the quantile-quantile plot of observed and modelled time series. doQmapSSPLIN uses the spline function to adjust the distribution of the modelled data to match the distribution of the observations.

Usage

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

doQmapSSPLIN(x,fobj,...)
## Default S3 method:
doQmapSSPLIN(x,fobj,...)
## S3 method for class 'matrix'
doQmapSSPLIN(x,fobj,...)
## S3 method for class 'data.frame'
doQmapSSPLIN(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

NULL or a numeric value between 0 and 1. See Details.

spline.par

a named list with parameters passed to smooth.spline.

x

numeric vector or a column matrix of modelled time series

fobj

output from fitQmapDIST

...

Further arguments passed to methods

Details

Before further computations the empirical cumulative distribution functions (CDF) of the observed (obs) and modelled (mod) are estimated. If !is.null(qstep) than mod and obs are aggregated to quantiles before model identification as: quantile(x,probs=seq(0,1,by=qstep). If !is.null(qstep) than mod and obs are sorted to produce an estimate of the empirical CDF. In case of different length of mod and obs than quantile(x,probs=seq(0,1,len=n)] is used, where

n <- min(length(obs),length(mod)). NOTE that large values of qstep effectively reduce the sample-size and can be used to speedup computations - but may render estimates less reliable.

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. The transformations are then only fitted to the portion of the distributions corresponding to observed wet days.

Value

fitQmapSSPLIN returns an object of class fitQmapSSPLIN containing following elements:

par

A list containing objects of class smooth.spline.fit, which are equivalent to the value of the element fit in the output of smooth.spline. The spline coefficients are checked for monotony and adjusted if necessary by replacement with the previous value. If mod is a matrix the names of par correspond to colnames(mod).

wet.day

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

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

Author(s)

Lukas Gudmundsson

References

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, smooth.spline

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

qm.a.fit <- fitQmapSSPLIN(obsprecip[,2],modprecip[,2],
                      qstep=0.01,wet.day=TRUE)
qm.a <- doQmapSSPLIN(modprecip[,2],qm.a.fit)

## example on how to use spline.par
## (this example has little effect)
qm.b.fit <- fitQmapSSPLIN(obsprecip[,2],modprecip[,2],
                          qstep=0.01,wet.day=TRUE,
                          spline.par=list(cv=TRUE))
qm.b <- doQmapSSPLIN(modprecip[,2],qm.b.fit)

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")
legend("topleft",legend=c("cv=FALSE","cv=TRUE"),
       lty=1,col=c("red","blue"))

qm2.fit <- fitQmapSSPLIN(obsprecip,modprecip,
                      qstep=0.1,wet.day=TRUE)
qm2 <- doQmapSSPLIN(modprecip,qm2.fit)


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")
}
par(op)

qmap documentation built on May 1, 2019, 7:31 p.m.