new_model {simulator} | R Documentation |
Create a Model object
Description
Creates a new Model
object.
Usage
new_model(name, label, params = list(), simulate)
Arguments
name |
a short name identifier. Must be alphanumeric (though -, _, and / are allowed as long as they are not at the start or end of name. |
label |
a longer, human readable label that can have other characters such as spaces, hyphens, etc. |
params |
a list that contains the Model object's parameters |
simulate |
a function that has arguments |
Examples
make_my_example_model <- function(n) {
new_model(name = "normal-data",
label = sprintf("Normal (n = %s)", n),
params = list(n = n, mu = 2),
simulate = function(n, mu, nsim) {
# this function must return a list of length nsim
x <- matrix(rnorm(n * nsim), n, nsim)
x <- mu + x # true mean is mu
return(split(x, col(x))) # make each col its own list element
})
}
[Package simulator version 0.2.5 Index]