apsim_emul_sa: Emulator-Based Sensitivity Analysis

Description Usage Arguments Details Value Examples

View source: R/emulateAPSIM.R

Description

This is a generic function that can be used to estimate the sensitivity indices for complex computer models using GAM-based emulators.

Usage

1
apsim_emul_sa(model, X, boot = 1000, conf = 0.95, y = NULL, method, ...)

Arguments

model

a function that specifies the model of interest

X

n-by-p matrix of input values; n runs, p inputs

boot

number of bootstrap replicates

conf

confidence level of bootstrap calibrated intervals

y

optional vector of model evaluations that can be used in place of the model statement

method

method to use to emulate the model; "singleGAM" or "separateGAM"

...

additional arguments passed to method

Details

Each column of the matrix X corresponds to a different input and each row corresponds to a different run of the computer model. Currently the method choices are: "singleGAM" and "separateGAM". The "singleGAM" method builds a single generalized additive model (GAM) with terms for all main effects of inputs plus all two-way interactions between inputs. With this method all first-order and total sensitivity indices are estimable provided at least 8p^2-4p+1 runs of the computer model are available where p is the number of parameters included in the analysis. The "separateGAM" method builds a separate GAM emulator for each input to estimate first-order indices for each input. Since this method emulates the marginal distribution of y given each of the inputs, total order indices cannot be computed. Both methods can be bootstrapped in order to estimate standard errors and to calibrate confidence regions for the sensitivity index estimates. The argument boot specifies the number of bootstrap replicates and conf is the confidence level of the bootstrap calibrated confidence region.

Value

A data frame of sensitivity measures where the exact form depends on the method, see details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
meanYield<-function(x){
 return(mean(x$lai_cowpea))
}
n <- 75
parValues <- data.frame(SoilCN = runif(n, 5, 25),
                 DiffusConst = runif(n, 20, 50), CNCov = runif(n, 0, 1))
apsimExe <-"C:/Program Files (x86)/Apsim75-r3008/Model/Apsim.exe"
apsimWd <- "~/APSIM"
apsimVars <- c("SoilOrganicMatter/SoilCN", "SoilWater/DiffusConst", "SoilWater/CNCov")
apsimFile <- "Canopy.apsim"
emulRes <- apsim_emul_sa(model = apsim_vector, X = parValues, method = "singleGAM",
             exe = apsimExe, wd = apsimWd, vars = apsimVars, to.run = apsimFile,
             g = meanYield, overwrite = TRUE)

emulRes
plot(emulRes)


## End(Not run)

stanfill/apsimr documentation built on May 30, 2019, 9:40 a.m.