View source: R/downscalePredict.R
downscalePredict | R Documentation |
Downscale data to local scales by statistical models previously obtained by downscaleTrain
.
downscalePredict(newdata, model, simulate = FALSE)
newdata |
The grid data. It should be an object as returned by |
model |
An object containing the statistical model as returned from |
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. |
A regular/irregular grid object.
J. Bano-Medina
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()
# 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])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.