predict.distmap: Apply a distribution mapping transfer function to data

Description Usage Arguments Value Examples

View source: R/predict.distmap.R

Description

Calls a distribution mapping (distmap) object's transfer function on data. This transforms the distribution of the data such that x-distributed input will be y-distributed on output, for the x and y datasets used to construct the mapping.

Usage

1
2
## S3 method for class 'distmap'
predict(object, xnew = NULL, ...)

Arguments

object

An object of class 'distmap'.

xnew

The data to be transformed. If omitted, object$x is used.

...

Additional arguments to object$transfer(), which is constructed by splinefun().

Value

A vector of transformed values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
set.seed(222)
obs <- rgamma(1e6, shape=2)
mod <- rweibull(1e6,shape=3, scale=3)
mod2 <- exp(rnorm(1e6, sd=0.5)+1)

map <- distmap(mod, obs)
bc  <- predict(map)
bc2 <- predict(map, mod2)

plot(NA, type="n", xlim=c(0,10), ylim=c(0,0.5), main="bias-correction PDFs")
lines(density(obs),  col="black", lwd=3)
lines(density(mod),  col="red",  lwd=2)
lines(density(bc),   col="red",  lwd=2, lty=2)
lines(density(mod2), col="blue", lwd=2)
lines(density(bc2),  col="blue", lwd=2, lty=2)
legend("topright", c("obs","mod","bc","mod2","bc2"),
       col=c("black","red","red","blue","blue"), lty=c(1,1,2,1,2))

sethmcg/climod documentation built on Nov. 19, 2021, 11:12 p.m.