downscalePredict: Downscale climate data for a given statistical model.

View source: R/downscalePredict.R

downscalePredictR Documentation

Downscale climate data for a given statistical model.

Description

Downscale data to local scales by statistical models previously obtained by downscaleTrain.

Usage

downscalePredict(newdata, model, simulate = FALSE)

Arguments

newdata

The grid data. It should be an object as returned by prepareNewData.

model

An object containing the statistical model as returned from downscaleTrain.

simulate

A logic value indicating whether we want to simulate or not based on the GLM distributional parameters. Only relevant when perdicting with a GLM. Default to FALSE.

Value

A regular/irregular grid object.

Author(s)

J. Bano-Medina

See Also

downscaleTrain for training a downscaling model prepareNewData for predictor preparation with new (test) data downscale.cv for automatic cross-validation downscaleR Wiki for downscaling seasonal forecasting and climate projections.

Other downscaling.functions: downscaleCV(), downscaleChunk(), downscaleTrain(), downscale()

Examples


# Loading data
require(transformeR)
require(climate4R.datasets)
data("VALUE_Iberia_tas")
y <- VALUE_Iberia_tas
data("NCEP_Iberia_hus850", "NCEP_Iberia_psl", "NCEP_Iberia_ta850")
x <- makeMultiGrid(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)

# Example1: Basic example (without cross-validation)
data <- prepareData(x = x, y = y, spatial.predictors = list(v.exp = 0.95))
model.analogs <- downscaleTrain(data, method = "analogs", n.analogs = 1)
newdata <- prepareNewData(x,data)
pred <- downscalePredict(newdata, model.analogs)
# This produces the same result as model.analogs$pred

# Example2:  Splitting data in train and test (simple cross-validation)
xT <- subsetGrid(x, years = 1983:1999)  # training predictors
yT <- subsetGrid(y, years = 1983:1999)   # training predictands
data <- prepareData(xT,yT)       # preparing the data
model.analogs <- downscaleTrain(data, method = "analogs", n.analogs = 1)
xt <- subsetGrid(x, years = 2000)       # test predictors
yt <- subsetGrid(y, years = 2000)       # test predictors
newdata <- prepareNewData(xt,data)     # preparing the new predictors
pred  <- downscalePredict(newdata, model.analogs)  # predicting
# Plotting the results for station 5
plot(yt$Data[,5],pred$Data[,5])


SantanderMetGroup/downscaleR documentation built on Nov. 16, 2024, 1:35 a.m.