sensitive_stics: Make sensitivity analysis of STICS output

View source: R/sensitive_stics.R

sensitive_sticsR Documentation

Make sensitivity analysis of STICS output

Description

Make sensitivity analysis on a particular output(s) given STICS input parameter(s) and their intercation if several are given.

Usage

sensitive_stics(
  dir.orig,
  dir.targ = getwd(),
  stics,
  obs_name,
  Parameters,
  Vars,
  method = c("fast99", "sobol"),
  n = 10 * length(Vars),
  q = "qunif",
  Plant = 1,
  Erase = T,
  values = rep(1, length(Parameters)),
  ...
)

Arguments

dir.orig

Path to the directory from which to copy the simulation files. If NULL (the default), uses the package dummy USM.

dir.targ

Path to the target directory for evaluation. Created if missing.

stics

STICS executable path

obs_name

A vector of observation file name(s). It must have the form c(Dominant,Dominated) for mixed crops. See read_obs() filename parameter for more details.

Parameters

A list of list of min and max values for each parameters, named after them (see details and example)

Vars

Output variables on which the sensitivity is performed

method

The sensitivity method to use, see sensitivity package

n

Sample size for simulation (must be an even number for sobol alike methods)

q

A vector of quantile function names corresponding to factors distribution (see sensitivity::fast99() and details)

Plant

The plant (i.e. Principal or associated) for which the parameters will be set (only for plant or technical parameters in mixed crop simulations) Set to NULL if using STICS in sole crop

Erase

Should the simulations data be erased upon import ? (see details)

values

A named list of number of values given to each parameter (will repeat the value found in the DOE by values). If NULL, it is set to 1.

...

Further parameters passed to the sensitivity function called (see sensitivity package)

Details

The function uses the sensitivity package functions under the hood to create the DOE (design of experiment) and then to compute the sensitivity index. For sobol alike methods, the DOE is first computed using the sensitivity::fast99() function using the q and Parameters (for q.arg) parameters. The DOE is then splitted in two to fill the ⁠X1`` and ⁠X2⁠parameters. The⁠Parameters⁠should take the form of a list of arguments to pass to the⁠q⁠function for each parameter, named after the parameter of interest (see example). As the simulations can take a lot of space on disk while augmenting the parameters number, the⁠Erase⁠parameter allow the user to erase each simulation as soon as its data is imported. The⁠values' parameter is used to repeat the input value found in the DOE given to set_param. It is usefull for plant parameters in intercrops that are still in the temporary parameter file so they have two values (one for each plant).

Value

A list of three :

  • gg_objects: A list of ggplot objects to plot the sensitivity of each variable to the parameter(s) along the rotation

  • sensi_objects: A list of the sensitivity analysis output, e.g. a list of class fast99 for the fast99 method.

  • DOE: A list of the design of experiment, with parameter values used for each simulation.

See Also

stats::Distributions() if you use sensitivity::fast99().

Examples

## Not run: 
library(sticRs)
# Example using the fast99 method for a sensitivity analysis on the
# "interrang" and "P_densitesem" parameters:

sensitive_stics(dir.orig = "0-DATA/dummy/SC_Wheat",
                dir.targ = "2-Simulations/Sensitivity2",
                stics = "0-DATA/stics_executable/EquDens_trg/stics.exe",
                obs_name = "Wheat_N0.obs",
                Parameters= list(interrang= list(min=0.05, max=0.25),
                                 P_densitesem= list(min=140, max=280)),
                Vars = c("raint", "lai(n)", "masec(n)"),
                method= "fast99", n= 10, q= "qunif")

# Example using the sobol method for a sensitivity analysis on the
# "interrang" and "P_densitesem" parameters with different quantile functions:

sensitive_stics(dir.orig = "0-DATA/dummy/SC_Wheat",
                dir.targ = "2-Simulations/Sensitivity2",
                stics = "0-DATA/stics_executable/EquDens_trg/stics.exe",
                obs_name = "Wheat_N0.obs",
                Parameters= list(interrang= list(min=0.05, max=0.25),
                                 P_densitesem= list(mean=210, sd=30)),
                Vars = c("raint", "lai(n)", "masec(n)"),
                method= "fast99", n= 10,
                q= c("qunif","qnorm"))

## End(Not run)


VEZY/sticRs documentation built on Oct. 26, 2023, 7:37 a.m.