as_experiment: Converting a data frame into an experiment

Description Usage Arguments Value Examples

View source: R/as_experiment.R

Description

Converts a data frame into an experiment, using the columns of the data frame to populate values of parameters, periods of observation, duration of simulation and seeds of an object of class experiment.

Usage

1
2
as_experiment(df, parameters = NULL, obsrates = NULL, tmax = "tmax",
  seed = "seed", experiment, model, dic = NULL)

Arguments

df

A data frame containing values of paramters, periods of observation, durations of simulation and seeds for an experiment.

parameters

Names or indexes of columns of df corresponding to values of parameters of the model specified in the model GAML file. If unspecified, all the columns with a name starting with "p_" will be considered.

obsrates

Names or indexes of columns of df corresponding to periods of observation for variables of the model specified in the model GAML file. If unspecified, all the columns with a name starting with "r_" will be considered.

tmax

Name or index of the column of df that corresponds to the durations of the simulations. If not specified, the column named tmax will be considered.

seed

Name or index of the column of df that corresponds to the seeds of the simulations. If not specified, the column named seed will be considered.

experiment

The name of an experiment of the GAML file model.

model

The path to a GAML file.

dic

A named vector of character strings. The values and the names of this vector should be consistent with the names of parameters, obsrates as well as the variables and parameters defined in the model GAML file. See Details for more information.

Value

An object of class experiment.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# A first example:
if (exists("sir1", inherits = FALSE)) rm(sir1)
df <- as.data.frame(repl(sir1, 5))
exp_name <- name(sir1)
gaml_file <- attr(sir1, "model")$path
as_experiment(df, experiment = exp_name, model = gaml_file)
# Alternative uses:
as_experiment(df, 1:5, 6:8, 9, 10, exp_name, gaml_file)
as_experiment(df, c("p_S0", "p_I0", "p_R0", "p_beta", "p_gamma"),
              c("r_S", "r_I", "r_R"), "tmax", "seed", exp_name, gaml_file)
# Or a mixture of character and numeric indexes:
as_experiment(df, 1:5, c("r_S", "r_I", "r_R"), "tmax", "seed", exp_name,
              gaml_file)
# And even using default parameters specification:
as_experiment(df, obsrates = c("r_S", "r_I", "r_R"),
              experiment = exp_name, model = gaml_file)

r-and-gama/rama documentation built on July 19, 2019, 9:49 p.m.