statistics: Generic simulated/observed statistics for one situation

View source: R/generic_stats.R

statisticsR Documentation

Generic simulated/observed statistics for one situation

Description

Compute statistics for evaluation of any model outputs against observations, providing a formater function (see format_cropr()).

Usage

statistics(
  sim,
  obs = NULL,
  all_situations = FALSE,
  all_plants = TRUE,
  verbose = TRUE,
  formater,
  stat = "all"
)

Arguments

sim

A simulation data.frame

obs

An observation data.frame (variable names must match)

all_situations

Boolean (default = FALSE). If TRUE, computes statistics for all situations. If TRUE, sim and obs are respectively an element of the first element and the second element of the output of cat_situations.

all_plants

Boolean (default = TRUE). If TRUE, computes statistics for all plants (when applicable).

verbose

Boolean. Print informations during execution.

formater

The function used to format the models outputs and observations in a standard way. You can design your own function that format one situation and provide it here.

stat

A character vector of required statistics, "all" for all, or any of predictor_assessment() (e.g. "n" or "RMSE", or both c("n", "RMSE")).

Value

A data.frame with statistics for each variable and possibly each grouping variable returned by the formater.

Note

Because this function has the purpose to assess model quality, all statistics are computed on dates were observations are present only. So the simulation mean is only the mean on dates with observations, not the overall simulation mean.

Examples

## Not run: 
workspace <- system.file(file.path("extdata", "stics_example_1"),
  package = "CroPlotR"
)
situations <- SticsRFiles::get_usms_list(
  usm_path =
    file.path(workspace, "usms.xml")
)
sim <- SticsRFiles::get_sim(workspace = workspace, usm = situations)
obs <- SticsRFiles::get_obs(workspace = workspace, usm = situations)
statistics(
  sim = sim$`IC_Wheat_Pea_2005-2006_N0`,
  obs = obs$`IC_Wheat_Pea_2005-2006_N0`,
  formater = format_cropr
)

## End(Not run)


SticsRPacks/CroPloteR documentation built on Dec. 16, 2024, 12:20 a.m.