parameter | R Documentation |
These functions add parameters to a model. Parameters can either
be used in features, or added directly to a model using the plus operator.
The value of parameters can be specified in the simulation command
(for par_named
and par_range
), sampled from a prior
distribution (par_prior
) or can be derived from other parameters
(par_expr
).
par_expr(expr) par_const(constant) par_named(name) par_range(name, lower, upper) par_prior(name, prior)
expr |
An R expression.
This allows to define a parameter using an R expression.
It can contain other named parameters (e.g. |
constant |
An R expression.
The constant value of the parameter.
Different to |
name |
Character. The name of the parameter. Must be unique in a model. |
lower |
A numeric. The lower boundary of the parameter's range. |
upper |
A numeric. The upper boundary of the parameter's range. |
prior |
An expression. Evaluation this expression should give
a sample from the prior distribution you want for the parameter.
For example using |
par_expr()
: Creates a parameter with value determined by evaluating an expression.
par_const()
: Creates an parameter that is equal to a fixed value.
Different to par_expr
, the value is evaluated on parameter creation.
par_named()
: Creates an parameter whose value is specified via the
pars
argument in simulate.coalmodel
.
par_range()
: Creates an parameter that can take a range of possible
values.
Similar to par_named
, the value of the parameter
used in a simulation is set via the pars
argument.
This is primarily intended for creating model parameters for
jaatha.
par_prior()
: Creates a named parameter with a prior
distribution. Before each simulation, the expression for the prior
is evaluated. The resulting value can be used in
par_expr
under the chosen name.
Paul Staab
For parameters that variate between the loci in a model:
par_variation
, par_zero_inflation
# A parameter (here for the mutation rate) that is always # equal to '5': model_base <- coal_model(20, 1) + sumstat_nucleotide_div() model <- model_base + feat_mutation(par_const(5)) simulate(model) # With using a prior: model <- model_base + feat_mutation(par_prior("theta", rnorm(1, 5, .1))) simulate(model) # Using a named parater: model <- model_base + feat_mutation(par_named("theta")) simulate(model, pars = c(theta = 5)) # or similarly a ranged parameter: model <- model_base + feat_mutation(par_range("theta", 1, 10)) simulate(model, pars = c(theta = 5)) # Expressions can be used to derive parameters from # other parameters: model <- model_base + par_named("theta_half") + feat_mutation(par_expr(theta_half * 2)) simulate(model, pars = c(theta_half = 2.5)) model <- model_base + par_named("theta_log") + feat_mutation(par_expr(exp(theta_log))) simulate(model, pars = c(theta_log = log(5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.