simAges {FSATeach}R Documentation

Simulate an age structure.

Description

Constructs either a simulated age frequency table or individuals that follow a simulated age frequency table. The number of individuals at each age is determined from an initial cohort size and an instantaneous or annual mortality rate supplied by the user.

Usage

  simAges(N0 = 500, A = 0.3, Z = -log(1 - A),
    incl.zero = FALSE, max.age = NULL, indivs = TRUE,
    rand = TRUE)

Arguments

N0

A numeric representing the initial cohort size to be used in the simulations.

A

A numeric representing the annual mortality rate to be used in the simulations.

Z

A numeric representing the instantaneous mortality rate to be used in the simulations. Will default to the value that corresponds to the user supplied value for A.

incl.zero

A logical indicating whether age-0 should be included in the ouptut (TRUE) or not (FALSE; default).

max.age

A numeric indicating the maximum age to use in the simulations. If NULL then the maximum age will be the age at which the projected cohort size is approximately equal to 1.

indivs

A logical indicating whether the output result should be ages assigned to individual fish (TRUE; default) or an age-frequency table.

rand

A logical indicating whether the individual ages should be chosen randomly (TRUE; default) or deterministically.

Details

The heart of this simulation is the assumption of an exponential decay model that starts with N0 individuals at age-0 and estimates Nt individuals at each age t, from 0 or 1 (depending on the incl.zero value) to max.age, with Nt=N0*exp(-Zt). If indivs=FALSE then the ages (t) and frequencies (Nt) are output as a data frame. If indivs=TRUE (default) and rand=FALSE then the age frequency values are used to deterministically produce ages for individual fish – i.e., essentially rep(t,Nt). Finally, if indivs=TRUE (default) and rand=TRUE (default) then the age frequency values are used to stochastically produce ages for individual fish – i.e., essentially sample(t,sum(Nt),replace=TRUE,prob=Nt/sum(Nt)).

Value

Either a data frame containing the ages and the simulated number of fish at each age (i.e., when indivs=FALSE) or a vector containing the simulated ages for individual fish (i.e., when indivs=TRUE; default).

See Also

simLenFromAge, simLenSelectP, simLenSelectM

Examples

## set seed for repeatability
set.seed(5234734)

## Simulated individual ages (random)
bg.ages <- simAges(N0=500,A=0.35)
str(bg.ages)
table(bg.ages)

## Simulated age frequency (non-random)
bg.ages.sum <- simAges(N0=500,A=0.35,indivs=FALSE)
str(bg.ages.sum)
t(bg.ages.sum)

## Simulated individual ages (non-random)
bg.ages2 <- simAges(N0=500,A=0.35,rand=FALSE)
table(bg.ages2)

[Package FSATeach version 0.0.1 Index]