Learn R Programming

gapfill (version 0.9.6-1)

Validate: Validation with RMSE

Description

The function summarizes the validation scenario and returns the root mean squared error (RMSE) of the predictions. The typical validation procedure is: start with the trueData. Remove some validation points to obtain artificially generated dataObserved. Predicting the validation points based on dataObserved leads to dataFilled.

Usage

Validate(
  dataObserved,
  dataFilled,
  dataTrue,
  include = rep(TRUE, length(dataObserved))
)

Arguments

dataObserved

Numeric vector containing the observed data.

dataFilled

Numeric vector containing the filled (predicted) data. Needs to have the same length as dataObserved.

dataTrue

Numeric vector containing the true data. Needs to have the same length as dataObserved.

include

Logical vector indicating which element to include in the calculation of the RMSE.

Value

Numeric matrix with one 1 row and 6 columns having the entries:

  • nNA: number of missing values in dataObserved,

  • nFilled: number of predicted values,

  • nNotFilled: number of not predicted missing values,

  • ratioFilled: ratio: nFilled / nNA,

  • nCrossvali: number of values for validation,

  • RMSE: root mean squared error.

Examples

Run this code
# NOT RUN {
Validate(c(1, NA, 2, NA), c(1, 2, 2, NA), c(1, 1, 2, 2))

## validate gap-fill predictions: consider the ndvi data
Image(ndvi)

## define some validation points vp
## in the image of the day 145 of the year 2004
vp <- 300 + c(5:10) + rep(21 * c(0:5), each = 6)

## remove the vp values from the data
nn <- ndvi
nn[vp] <- NA
Image(nn)

## predict the vp values 
out <- Gapfill(nn, subset = vp)
Validate(dataObserved = nn, dataFilled = out$fill,
         dataTrue = ndvi)

# }

Run the code above in your browser using DataLab