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)
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 |
obsrates | Names or indexes of columns of |
tmax | Name or index of the column of |
seed | Name or index of the column of |
experiment | The name of an experiment of the |
model | The path to a |
dic | A named vector of character strings. The values and the names of
this vector should be consistent with the names of
|
An object of class experiment
.
# 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 NAas_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