Learn R Programming

qmap (version 1.0-4)

fitQmap: Quantile mapping

Description

fitQmap identifyes the parameters of different quantile mapping methods. doQmap performs quantile mapping using previously identified parameters.

Usage

fitQmap(obs,mod,method=c("PTF","DIST","RQUANT","QUANT","SSPLIN"),...) doQmap(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.
method
A character string indicating the method to be used. See Details.
x
numeric vector or a column matrix of modelled time series. Should have the same number of columns as obs.
fobj
output from fitQmap (or of method defined via method).
...
arguments passed to the method specified by method.

Value

fitQmap returns an object which class and structure depends on the selected method (see Details).doQmap returns a numeric vector, matrix or data.frame depending on the format of x.

Details

The method argument decides upon which method for quantile mapping is used:

"PTF" selects fitQmapPTF.

"DIST" selects fitQmapDIST

"RQUANT" selects fitQmapRQUANT

"QUANT" selects fitQmapQUANT

"SSPLIN" selects fitQmapSSPLIN

doQmap investigates the class of fobj and chooses the appropriate method for quantile mapping.

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

fitQmapDIST, fitQmapPTF, fitQmapRQUANT, fitQmapQUANT, fitQmapSSPLIN

Examples

Run this code
data(obsprecip)
data(modprecip)

## call to fitQmapPTF and doQmapPTF
qm1.fit <- fitQmap(obsprecip,modprecip,
              method="PTF",
              transfun="expasympt",
              cost="RSS",wett.day=TRUE)
qm1 <- doQmap(modprecip,qm1.fit)

## call to fitQmapDIST and doQmapDIST
qm2.fit <- fitQmap(sqrt(obsprecip),sqrt(modprecip),
              method="DIST",qstep=0.001,
              transfun="berngamma")
qm2 <- doQmap(sqrt(modprecip),qm2.fit)^2

## call to fitQmapRQUANT and doQmapRQUANT
qm3.fit <- fitQmap(obsprecip,modprecip,
              method="RQUANT",qstep=0.01)
qm3 <- doQmap(modprecip,qm3.fit,type="linear")


## call to fitQmapRQUANT and doQmapRQUANT
qm4.fit <- fitQmap(obsprecip,modprecip,
              method="QUANT",qstep=0.01)
qm4 <- doQmap(modprecip,qm4.fit,type="tricub")

## call to fitQmapSSPLIN and doQmapSSPLIN
qm5.fit <- fitQmap(obsprecip,modprecip,qstep=0.01,
                   method="SSPLIN")
qm5 <- doQmap(modprecip,qm5.fit)

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

op <- par(mfrow=c(1,3))
for(i in 1:3){
  plot(sqrtquant(modprecip[,i]),
       sqrtquant(obsprecip[,i]),pch=19,col="gray",
       main=names(obsprecip)[i])
  lines(sqrtquant(modprecip[,i]),
        sqrtquant(qm1[,i]),col=1)
  lines(sqrtquant(modprecip[,i]),
        sqrtquant(qm2[,i]),col=2)
  lines(sqrtquant(modprecip[,i]),
        sqrtquant(qm3[,i]),col=3)
  lines(sqrtquant(modprecip[,i]),
        sqrtquant(qm4[,i]),col=4)
  lines(sqrtquant(modprecip[,i]),
        sqrtquant(qm5[,i]),col=5)
}
legend("topleft",
       legend=c("PTF","DIST","RQUANT","QUANT","SSPLIN"),
       lty=1, col=1:5)
par(op)

Run the code above in your browser using DataLab