explore_space: Explore parameter space

View source: R/explore_space.R

explore_spaceR Documentation

Explore parameter space

Description

[Experimental]

The function is aimed at getting an idea of how the parameter space of a model behaves, so that parameter identifiability problems and correlations between parameters can be explored. Therefore, the function samples a large number of parameter sets by randomly drawing from each parameter's 95% confidence interval (generated by lik_profile()). It then checks how many of the parameter sets are within acceptable limits by comparing the likelihood ratio of a parameter set vs. the original parameter set against a chi-square distribution as degrees of freedom (df) the total number of profile parameters (outer rim) or one df (inner rim). If needed, the function resamples until at least nr_accept parameters sets are within the inner rim

Usage

explore_space(
  x,
  par,
  res,
  output,
  data,
  sample_size = 1000,
  max_iter = 30,
  nr_accept = 100,
  sample_factor = 1.2,
  individual = FALSE,
  log_scale = FALSE,
  data_type = c("continuous", "count"),
  max_runs = deprecated(),
  ...
)

Arguments

x

a list of caliset objects

par

best fit parameters from joined calibration

res

output of lik_profile() function

output

character vector, name of output column of simulate() that is used in calibration

data

only needed if x is a scenario

sample_size

number of samples to draw from each parameter interval

max_iter

max number of iterations to redraw samples (within a smaller space), and repeat the process

nr_accept

threshold for number of points sampled within the inner circle

sample_factor

multiplication factor for sampling (95% interval * sample factor)

individual

if FALSE (default), the log likelihood is calculated across the whole dataset. Alternatively, if TRUE, log likelihoods are calculated for each (group of) set(s) individually.

log_scale

FALSE (default), option to calculate the log likelihood on a log scale (i.e., observations and predictions are log transformed during calculation)

data_type

Character argument, "continuous" (default) or "count", to specify the data type for the log likelihood calculations.

max_runs

deprecated alias for max_iter parameter

...

additional parameters passed through to simulate()

Value

a list containing a plot to explore the parameter space, and the data.frame supporting it

See Also

plot.param_space

Examples


library(dplyr)
# Example with Lemna model - physiological params
# Before applying the function, a model needs to be calibrated and its parameters profiled
# Inputs for likelihood profiling

# observations - control run
obs <- schmitt2013 %>%
  filter(trial == "T0")

# parameters after calibration
params <- c(
  k_phot_max = 5.663571,
  k_resp = 1.938689,
  Topt = 26.7
)

# set parameter boundaries (if different from defaults)
bounds <- list(
  k_resp = list(0, 10),
  k_phot_max = list(0, 30),
  Topt = list(20, 30)
)

# update metsulfuron
myscenario <- metsulfuron %>%
  set_init(c(BM = 1.2, E = 1, M_int = 0)) %>%
  set_param(list(
    k_0 = 5E-5,
    a_k = 0.25,
    BM50 = 17600,
    mass_per_frond = 0.1
  )) %>%
  set_noexposure() %>%
  set_param(params) %>%
  set_bounds(bounds)

# Likelihood profiling
res <- lik_profile(
  x = myscenario,
  data = obs,
  output = "FrondNo",
  par = params,
  refit = FALSE,
  type = "fine",
  method = "Brent"
)
# plot
plot(res)

# parameter space explorer
set.seed(1) # for reproducibility
res_space <- explore_space(
  x = myscenario,
  data = obs,
  par = params,
  res = res,
  output = "FrondNo",
  sample_size = 1000,
  max_iter = 20,
  nr_accept = 100)

plot(res_space)



cvasi documentation built on Sept. 11, 2025, 5:11 p.m.