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.

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

# 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)
#> Experiment with 5 simulations of 5 parameters and 3 observed variables #> experiment name: sir #> input gaml file: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gamar/models/sir.gaml #> model parameters: p_S0, p_I0, p_R0, p_beta, p_gamma #> observed variables: r_S, r_I, r_R #> Experiment overview: #> p_S0 p_I0 p_R0 p_beta p_gamma r_S r_I r_R tmax seed output #> 1 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 2 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 3 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 4 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 5 999 1 0 1.5 0.15 1 1 1 1000 1 NA
# Alternative uses: as_experiment(df, 1:5, 6:8, 9, 10, exp_name, gaml_file)
#> Experiment with 5 simulations of 5 parameters and 3 observed variables #> experiment name: sir #> input gaml file: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gamar/models/sir.gaml #> model parameters: p_S0, p_I0, p_R0, p_beta, p_gamma #> observed variables: r_S, r_I, r_R #> Experiment overview: #> p_S0 p_I0 p_R0 p_beta p_gamma r_S r_I r_R tmax seed output #> 1 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 2 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 3 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 4 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 5 999 1 0 1.5 0.15 1 1 1 1000 1 NA
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)
#> Experiment with 5 simulations of 5 parameters and 3 observed variables #> experiment name: sir #> input gaml file: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gamar/models/sir.gaml #> model parameters: p_S0, p_I0, p_R0, p_beta, p_gamma #> observed variables: r_S, r_I, r_R #> Experiment overview: #> p_S0 p_I0 p_R0 p_beta p_gamma r_S r_I r_R tmax seed output #> 1 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 2 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 3 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 4 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 5 999 1 0 1.5 0.15 1 1 1 1000 1 NA
# 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)
#> Experiment with 5 simulations of 5 parameters and 3 observed variables #> experiment name: sir #> input gaml file: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gamar/models/sir.gaml #> model parameters: p_S0, p_I0, p_R0, p_beta, p_gamma #> observed variables: r_S, r_I, r_R #> Experiment overview: #> p_S0 p_I0 p_R0 p_beta p_gamma r_S r_I r_R tmax seed output #> 1 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 2 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 3 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 4 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 5 999 1 0 1.5 0.15 1 1 1 1000 1 NA
# And even using default parameters specification: as_experiment(df, obsrates = c("r_S", "r_I", "r_R"), experiment = exp_name, model = gaml_file)
#> Experiment with 5 simulations of 5 parameters and 3 observed variables #> experiment name: sir #> input gaml file: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gamar/models/sir.gaml #> model parameters: p_S0, p_I0, p_R0, p_beta, p_gamma #> observed variables: r_S, r_I, r_R #> Experiment overview: #> p_S0 p_I0 p_R0 p_beta p_gamma r_S r_I r_R tmax seed output #> 1 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 2 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 3 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 4 999 1 0 1.5 0.15 1 1 1 1000 1 NA #> 5 999 1 0 1.5 0.15 1 1 1 1000 1 NA