ccrlm: Climate Conserving Recalibration (as Regression)

View source: R/ccrlm.R

ccrlmR Documentation

Climate Conserving Recalibration (as Regression)

Description

Climate conserving recalibration with correction factors for each lead time without smoothing (application to daily series not recommended).

Usage

ccrlm(fcst, obs, pred = NULL, fcst.out = fcst, pred.out = pred, ...)

Arguments

fcst

n x m x k array of n lead times, m forecasts, of k ensemble members

obs

n x m matrix of veryfing observations

pred

m vector, n x m matrix, or list of m vectors or n x m matrices with additional predictors

fcst.out

array of forecast values to which bias correction should be applied (defaults to fcst)

pred.out

n vector, n x m matrix, or list of n vectors or n x m matrices with additional predictors

...

additional arguments for compatibility with other bias correction methods

Examples

nveri <- 50
ncal <- 30
nn <- nveri + ncal
ical <- seq(1, ncal)
iveri <- seq(ncal + 1, nn)
nens <- 15
signal <- rnorm(nn, sd=5)
sdfrac <- 2
fcst <- array(rnorm(nn*nens, sd=sdfrac), c(1, nn, nens)) + 
  0.6 * signal + seq(-3,3,length=nn) 
obs <- array(rnorm(nn, sd=1), c(1, nn)) + signal
fcst.deb <- biascorrection:::ccrlm(fcst[,ical,,drop=FALSE], 
                                   obs[,ical,drop=FALSE],
                                   fcst.out=fcst)
fcst.deb2 <- biascorrection:::ccrlm(fcst[,ical,,drop=FALSE], 
                                   obs[,ical,drop=FALSE],
                                   fcst.out=fcst, 
                                   pred=seq(1,ncal), 
                                   pred.out=seq(1,nn))
f.rmse <- sqrt(apply((obs[,ical, drop=FALSE] - 
            apply(fcst.deb[,ical,,drop=FALSE], 2, mean))**2, 1, mean))
f.rmse2 <- sqrt(apply((obs[,ical,drop=FALSE] - 
            apply(fcst.deb2[,ical,,drop=FALSE], 2, mean))**2, 1, mean))
f.sd <- sqrt(mean(apply(fcst.deb[,ical,,drop=FALSE], 1:2, sd)**2))
f.sd2 <- sqrt(mean(apply(fcst.deb2[,ical,,drop=FALSE], 1:2, sd)**2))
f.sd / f.rmse ## should be one
f.sd2 / f.rmse2 ## should be one
## spread to error with out-of-sample validation
f.rmse <- sqrt(apply((obs[,iveri, drop=FALSE] - 
            apply(fcst.deb[,iveri,,drop=FALSE], 2, mean))**2, 1, mean))
f.rmse2 <- sqrt(apply((obs[,iveri,drop=FALSE] - 
            apply(fcst.deb2[,iveri,,drop=FALSE], 2, mean))**2, 1, mean))
f.sd <- sqrt(mean(apply(fcst.deb[,iveri,,drop=FALSE], 1:2, sd)**2))
f.sd2 <- sqrt(mean(apply(fcst.deb2[,iveri,,drop=FALSE], 1:2, sd)**2))
f.sd / f.rmse ## should be close to one
f.sd2 / f.rmse2 ## can be close to one


jonasbhend/biascorrection documentation built on Nov. 11, 2023, 1:16 a.m.