Learn R Programming

pop (version 0.1)

dynamic: dynamic objects

Description

creates a dynamic object, comprising multiple transition objects to define a dynamical system. dynamic objects are the core of pop, since they can be created and updated using various methods (MPMs, IPMs etc.), combined (by addition of two dynamic objects to make another) and and analysed in various ways (deterministically to obtain demographic parameters, simulated to evaluate population viability etc.)

Usage

dynamic(...)
is.dynamic(x)
"plot"(x, ...)
states(x)
"print"(x, ...)
"as.matrix"(x, which = c("A", "P", "F", "R"), ...)
"parameters"(x)
"parameters"(x) <- value

Arguments

x
a dynamic object to print, plot, convert to a transition matrix, or an object to test as a dynamic object (for is.dynamic),
which
which type of matrix to build: the overall population growth matrix ('A'), the probabilistic progression matrix ('P'), the fecundity matrix ('F') or the intrinsic reproduction matrix ('R')
value
a nested named list of parameters within each transition matching those currently defined for x
...
for dynamic(): one or more transition (or other dynamic) objects making up the dynamic. For plot() and print(): further arguments passed to or from other methods

Examples

Run this code
# define transitions for a simple three-stage system (with implicit
# mortality):
stasis_egg <- tr(egg ~ egg, p(0.4))
stasis_larva <- tr(larva ~ larva, p(0.3))
stasis_adult <- tr(adult ~ adult, p(0.8))
hatching <- tr(larva ~ egg, p(0.5))
fecundity <- tr(egg ~ adult, r(3))
pupation <- tr(adult ~ larva, p(0.2))

# combine these into separate dynamics
stasis <- dynamic(stasis_egg,
                  stasis_larva,
                  stasis_adult)
growth <- dynamic(hatching,
                  pupation)
reproduction <- dynamic(fecundity)

# combine these into one dynamic (the same as listing all the transitions
# separately)
all <- dynamic(stasis, growth, reproduction)

# plot these
plot(stasis)
plot(growth)
plot(all)

# get component states
states(all)

# print method
print(all)

# convert to a transition matrix
as.matrix(all)
# extract the parameters
(param_stasis <- parameters(stasis))
(param_all <- parameters(all))

# update the parameters of these transfuns
param_stasis$stasis_egg$p <- 0.6
parameters(stasis) <- param_stasis
parameters(stasis)

param_all$fecundity$r <- 15
parameters(all) <- param_all
parameters(all)

Run the code above in your browser using DataLab