Learn R Programming

coala (version 0.2.0)

par_expr: Define Model parameters

Description

This functions allow to 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).

Usage

par_expr(expr)

par_const(constant)

par_named(name)

par_range(name, lower, upper)

par_prior(name, prior)

Arguments

expr
An R expression. This allows to define a parameter using an R expression. It can contain other named parameters (e.g. 2 * a will create an parameter that is twice the value of an existing parameter a). Make sure that the expressi
constant
An R expression. The constant value of the parameter. Different to expr, the expression is evaluated immediately and can not depend on other named parameters.
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 rnorm(1) gives a standard normal prior.

Functions

  • 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 theparsargument insimulate.coalmodel.
  • par_range: Creates an parameter that can take a range of possible values. Similar topar_named, the value of the parameter used in a simulation is set via theparsargument. This is primarily intended for creating model parameters forjaatha.
  • 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 inpar_exprunder the chosen name.

Examples

Run this code
par_const(5)
par_named("x")
par_prior("y", rnorm(1))
par_range("z", 1, 5)
par_expr(2*x + y * z)

Run the code above in your browser using DataLab