Learn R Programming

pop (version 0.1)

transition: transition objects

Description

creates a transition object, encoding a transition between two states. E.g. the probability of a seed germinating, or of an individual surviving in each time step

Usage

transition(formula, transfun)
tr(formula, transfun)
is.transition(x)
"print"(x, ...)
"*"(x, y)
"parameters"(x)
"parameters"(x) <- value

Arguments

formula
a two-sided formula identifying the states between which the transition occurs
transfun
a transfun object quantifying the transition.
x
an object to print or test as a transition object
y
a transition object to be multiplied with another with the same pathway
value
a named list of parameters matching those currently defined for x
...
further arguments passed to or from other methods.

Details

tr is just a shorthand for transition

multiplication of transition objects with the same pathway results in a transition object whose transfun object is a compound of the two transfuns in the transitions. See transfun for more details of compound transfuns.

Examples

Run this code
# 50/50 chance of a larva emerging from an egg
hatching <- tr(larva ~ egg, p(0.5))

# three eggs laid per adult per time step
fecundity <- tr(egg ~ adult, r(3))

# 0.1 probability of a larva pupating into an adult
pupa <- tr(adult ~ larva, p(0.1))

# print method
print(pupa)

# make a compound transition to include a probability of laying eggs
prob_laying <- tr(egg ~ adult, p(0.6))
(recruitment <- prob_laying * fecundity)

# extract the transfun parameters
(param_pupa <- parameters(pupa))
(param_recruitment <- parameters(recruitment))

# update the parameters of these transfuns
param_pupa$p <- 0.6
parameters(pupa) <- param_pupa
parameters(pupa)

param_recruitment$r <- 15
parameters(recruitment) <- param_recruitment
parameters(recruitment)

Run the code above in your browser using DataLab