Package 'Rramas'

Title: Matrix Population Models
Description: Analyzes and predicts from matrix population models (Caswell 2006) <doi:10.1002/9781118445112.stat07481>.
Authors: Marcelino de la Cruz
Maintainer: Marcelino de la Cruz <[email protected]>
License: GPL (>= 2)
Version: 0.1-6
Built: 2024-12-15 07:19:02 UTC
Source: CRAN

Help Index


Population Transition Matrix

Description

Convert a matrix to transition matrix (class tmatrix) and display some of its properties.

Usage

as.tmatrix(x, names.st = NULL, ...)
## S3 method for class 'tmatrix'
plot(x, ...)
## S3 method for class 'tmatrix'
print(x, ...)
## S3 method for class 'tmatrix'
summary(object, ...)
## S3 method for class 'summary.tmatrix'
print(x, ...)

Arguments

x

For as.tmatrix, x is a square matrix,; for the plot, print and summary methods,x is a matrix of class tmatrix.

object

An object of class tmatrix, i.e, resulting from as.tmatrix.

names.st

A vector of names to rename the rows and columns of the transition matrix.

...

Other parameters passed to print and plot methods.

Details

The purpose of as.tmatrix is to class a transition matrix as an object of class tmatrix, allowing the use of specific methods for transition matrices.

Value

as.tmatrix returns a matrix of class tmatrix.

summary.tmatrix prints the main parameters of the transition matrix: the finite rate of increase ("lambda"), the stable stage distribution, the reproductive value and the sensitivities and elasticities matrices.

plot.tmatrix draw barplots of the stable stage distribution and the reproductive value and plot also a diagram of the life stage cycle.

Author(s)

Marcelino de la Cruz Rot

References

Akcakaya, H. R., Burgman, M. A. and Ginzburg L.R. 1999. Applied Population Ecology. Sinauer.

Caswell, H. 2003. Matrix Population Models: Construction, Analysis, and Interpretation . Sinauer.

Examples

data(coryphanthaA)
  coryphanthaA
  coryphanthaA <- as.tmatrix(coryphanthaA)
  summary(coryphanthaA)
  plot(coryphanthaA)

Transition Matrices of Three Coryphantha robbinsorum Populations

Description

Transition matrices of three Coryphantha robbinsorum populations.

Usage

data(coryphanthaA)

Format

3x3 matrix.

Source

Although the original data are from Schmalzel et al (1995), these matrices have been transcribed from Gurevitch et al. (2002).

References

Gurevitch, J., Scheiner, S. M. and Fox, G. A. 2002. The Ecology of Plants. Sinauer.

Schmalzel, R.J., F.W. Reichenbacher, and S. Rutman. 1995. Demographic study of the rare Coryphantha robbinsorum (Cactaceae) in southeastern Arizona. Madrono 42:332-348.

Examples

data(coryphanthaA)

Compute Declination and Explosion Probabilities

Description

Compute declination (or explosion) probabilities for a stage-structured population. From a vector of initial stage abundances and a transition matrix, decline and explosion compute respectively the probability that the population size falls below or surpasses some abundance thresholds during a given time interval.

Usage

decline(rmas, bootsp = 1000)
explosion(rmas, bootsp = 1000)
## S3 method for class 'rmas.risk'
summary(object, q = c(0.025, 0.975),...)
## S3 method for class 'summary.rmas.risk'
plot(x, ylim = NULL, col = NULL, xlab = NULL, ylab = NULL, main = NULL, ...)

Arguments

rmas

An object of class rmas,i.e., resulting from projectn.

bootsp

number of botstraped samples.

object

An object of class rmas.rsik, i.e. resulting from declineor explosion.

x

An object of class summary.rmas.rsik.

q

vector of quantiles to compute bootstraped confidence intervals.

ylim

Vector with max and min values of the y (abundances) axis.

col

Color or vector of colors to draw the trajectories.

xlab

Label for the x-axis.

ylab

Label for the y-axis.

main

Text to appear as title.

...

Other parameters passed to plot and other methods.

Details

Both decline and explosion require that some stochastic simulations for a given time interval had been previously constructed (using projectn). Using those simulations decline computes the probability of falling bellow some population threshold (and explosion the probability of surpassing it) as the ratio between the number of times that these threshold has been attained and the number of replications. The set of abundances in each time interval (in all the simulations) are bootstraped (i.e. sampled with replacement) to build a confidence interval.

Value

Both decline and explosion return an object of class rmas.rsik, basically a list with the following elements

cf.obs

a data.frame with the evaluated thresholds and their probabilities.

cf.boot

a list of data.frames similar to cf.obs for each bootstraped sample.

abminbot

a list of bootstraped minimum (or maximum for explosion) abundances for each replica in the rmas object.

main

Text to appear as title when plotting the summary.

The methods summary and plot.summary summarize the results and print and plot probabilities and bootstraped confidence interval of attainning a particular population threshold.

Author(s)

Marcelino de la Cruz Rot

References

Akcakaya, H. R., Burgman, M. A. and Ginzburg L.R. 1999. Applied Population Ecology. Sinauer.

Caswell, H. 2003. Matrix Population Models: Construction, Analysis, and Interpretation . Sinauer.

Examples

data(coryphanthaA)
     coryphanthaA <- as.tmatrix(coryphanthaA)
     #initial abundances:
     v0 <- c(100,0,0)
       
     # run 1000 simulations of 20 years with  demographic stochasticity:
     simu20.ds <- projectn(v0=v0, mat=coryphanthaA, time = 20, estdem=TRUE, nrep=1000)
     
     # compute declination probabilities
     simu20.ds.dec <- decline(simu20.ds)
     
     summary(simu20.ds.dec)

Demographic Projections

Description

Make deterministic and stochastic demographic projections according to a transition matrix.

Usage

projectn(v0, mat, matsd = NULL, estamb = FALSE, estdem = FALSE,
         equalsign = TRUE,stmat=NULL, fecundity1=TRUE,
        nrep = 1, time = 10, management=NULL, round=TRUE)
project1(v0, mat, matsd=NULL, estamb=FALSE, estdem=FALSE,
         equalsign=TRUE, stmat=NULL, fecundity1=TRUE)
estambi(mat, matsd, equalsign)
estdemo(v0,mat,stmat=NULL, fecundity1=TRUE)
## S3 method for class 'rmas'
plot(x, sum = TRUE, mean=FALSE, type="l", harvest=FALSE, ...)
## S3 method for class 'rmas'
summary(object, stage=NULL, harvest=FALSE,...)
## S3 method for class 'summary.rmas'
plot(x, ylim=NULL, col=NULL, xlab=NULL, ylab=NULL, main=NULL,...)

Arguments

v0

Vector with the initial abundance of each stage.

mat

Transition matrix.

matsd

Matrix with the standard deviation of the probabilities in mat.

estamb

Logical. Should environmental stochasticity be considered to projet the dynamics of the population?

estdem

Logical. Should demographic stochasticity be employed to project the dynamics of the population?

equalsign

Logical. Should the environmental deviations have all the same sign and magnitude? See details section.

stmat

Matrix indicating for each transition probability in mat which part (i.e. which proportion) should be considered resulting from fecundity (and the rest will be considered resulting from survival). See details.

fecundity1

Logical. Should the first row of mat be considered exclusively as fecundities? See details

nrep

Number of replications to evaluate the effects of stochasticity.

time

length of the demographic trajectory

management

Vector (or matrix) of management actions to be applied each time step.

round

Logical. Should the projections be rounded to the next integer each time step (i.e. consider finite indiviuals)?

object

An object of class rmas, i.e. resulting from projectn.

x

An object resulting from projectn or summary.rmas.

stage

Print only the trajectory of the stage called ...

harvest

Logical. Should the harvest history be summarized or ploted instead of the population one?

sum

Logical. If TRUE, print the trajectory of the whole population. If FALSE, print the individual trajectory of all stages.

mean

Logical. If TRUE, print the mean trajectory of all replications. If FALSE, print all the replicated trajectories.

type

Type of plot to represent the trajectories. By default, a line.

ylim

Vector with max and min values of the y (abundances) axis.

col

Color or vector of colors to draw the trajectories.

xlab

Label for the x-axis.

ylab

Label for the y-axis.

main

Text to appear as title.

...

Other parameters passed to plot and other methods.

Details

The function projectn makes demographic proyections by repetedly calling (as long as the time argument) to project1. If no environmental or demographic stochasticity is required, project1 will multiply the transition matrix mat by the vector of stage abundances.

If demographic stochasticity is required, project1 will call to estdemo function, that for each time will assign abundances to each stage based in sampling from both a binomial and a poisson distribution. Sampling from rbinom with probability mat[i,j] will assign "survival" chances to each individual accounted for in the abundance vector, i.e. it would allow some of them to remain in the same stages (for transitions mat[i,i]) or to pass to another stage (for transitions mat[i,j]). Sampling from rpois with mean mat[i,j] will assign to each individual of stage[j] a random number of offspring of type stage[i].

In the current implementation there are 3 options to generate demographic stochasticity. By deafult ( stmat=NULL and fecundity1=TRUE) probabilities in the first row of the transition matrix (i.e mat[1,j]) are assumed to represent only fecundities, i.e., they would not account for "survival" transitions from stage[j] to stage[1], but only for newborns. This means that these probabilities will only be used as the mean for sampling from rpois. Transitions in rows others than first row will be assumed to represent "survival" transitions if its value is <=1 and accordingly will be employed to sample from rbinom. Transitions >1 will be assumed to represent fecundities and will be employed to sample from rpois.

If stmat=NULL and fecundity1=FALSE transition probabilities in all the rows of the matrix mat are treated in the same way, i.e. probabilities <=1 will be sampled from rbinom and probabilities >1 will be sampled from rpois.

If a stmat matrix (a matrix with values between 0 and 1) is provided, it will be used to divide transition probabilities mat[i,j] into fecundities (mat[i,j] * stmat[i,j]) and survival probabilities (mat[i,j] - (mat[i,j] * stmat[i,j])) and these matrices will be used to sample from rbinom and rpois respectively.

The current implementation of estdemo assumes that reproduction takes place before "survival sorting", so even for individuals that wouldn't survive (according to its sampled binomial probability) offspring is computed (if approppriate) and accounted for.

If environmental stochasticity is required (i.e., a matsd matrix is provided), project1 will call to estambi function, that for each time will change mat[i,j] probabilities sampling from rnorm with mean= mat[i,j] and sd = matsd[i,j]. If equalsign=TRUE the random changes in all cells of mat will have the same sign and the same magnitude (relative to each individual matsd[i,j]). If equalsign=FALSE every transition probability will change independently.

If both environmental and demographic stochasticity are required project1 will call first to estambi and using the modified mat will call to estdemo.

If management is required, a vector or matrix of magement actions should be provided. In the simplest case (i.e., a vector), each element in the vector will be interpreted as the management action that will be applied each time step to the corresponding stage. Positive and negative elements in the vector represent respectively the introduction or extraction of individuals from the corresponding stage. Elements whose absolute value is >= 1 will be interpreted as the introduction or extraction of exactly that number of individuals; absolute values < 1 will be interpreted as the introduction or extraction of that proportion of individuals from the existing individuals in the corresponding stage. If "management" is a matrix, each time step the management actions represented by each column of the matrix will be applied sequentially, from first to last.

Value

project1, estdemo and estambi return a vector of stage abundances with the same length that v0.

projectn return an object of class rmas, basically a list with four elements: vn, with length = (nrep) where each of its elements represents a replicate simulation and consist of a matrix of dimensions [lengtth(v0), time] representing the abundance of each stage at each time. If the simulation included management actions, harvest will be a list of length (nrep) where each of its elements represents the trajectory of harvest in a replicate simulation and consist of a matrix of dimensions [lengtth(v0), time] representing the number of individuals extracted of each stage at each time. The other two elements, mat and management, are respectively the transition matrix and the managenet matrix employed in the simulations. The plot method will draw the demographic trajectory of the population. By default (sum = TRUE, mean=FALSE) it will plot the abundance of the whole population (i.e. the the sum of abundances in each stage) vs. time. If nrep >1 it will plot together the trajectory of each replicated population. If ( sum = TRUE, mean=TRUE) it will plot the mean of all repplicated populations. If (sum = FALSE, mean=TRUE) it wil plot the abundance (or the mean abundance in all the replications) of each stage vs. time.

The summary and plot.summary methods will print a table and draw a plot respectively with the maximun, mean + 1 sd, mean, mean - 1 sd and minimum values of population abundance in all the simulations.

Author(s)

Marcelino de la Cruz Rot

References

Akcakaya, H. R., Burgman, M. A. and Ginzburg L.R. 1999. Applied Population Ecology. Sinauer.

Caswell, H. 2003. Matrix Population Models: Construction, Analysis, and Interpretation . Sinauer.

Examples

data(coryphanthaA)
     coryphanthaA <- as.tmatrix(coryphanthaA)
  
     # run a deterministic simulation of 20 years from an initial state of
     # 100 small juveniles:
     v0 <- c(100,0,0)
     simu20 <- projectn(v0=v0, mat=coryphanthaA, time = 20)
     plot(simu20, sum=FALSE)
     summary(simu20)
  
     # run 100 simulations of 20 years with  demographic stochasticity:
     simu20.ds <- projectn(v0=v0, mat=coryphanthaA, time = 20, estdem=TRUE, nrep=100)
     plot(simu20.ds)
     summary(simu20.ds)
     
     # run 100 simulations of 20 years with  demographic stochasticity but 
     # assuming that the first row of the transition matrix represent both
     # fecundity and survival, each with a 50% contribution 
     
     # first generate the stmat matrix:
     stmat <- (coryphanthaA >0)
     stmat <- stmat*c(0.5,0,0)
     stmat
     
     simu20.ds2 <- projectn(v0=v0, mat=coryphanthaA, time = 20, estdem=TRUE,
                             stmat=stmat, nrep=100)
     plot(simu20.ds2)
     summary(simu20.ds2)
          
  
     # run 100 simulations of 20 years with  both demographic and environmental
     # stochasticity:
     # first generate a sd matrix to describe environmental stochasticity:
     sdenv <- coryphanthaA/20 
     sdenv
     
     simu20.eds <- projectn(v0=v0, mat=coryphanthaA, matsd =sdenv,  time = 20,
                            estdem=TRUE,estamb=TRUE, nrep=100)
     plot(simu20.eds)
     summary(simu20.eds)
     
     # Example of management actions
     #    each time step, 10 individuals will be added to the first stage ,10 individuals  
     #    will be added to the second stage, and 50 percent of the individuals in the 
     #    third stage will be extracted
     
        man <- c(10, 10, -0.5)
        p1 <- projectn(v0 = c(100, 100,100), mat= coryphanthaA, management=man)
	
        # summarize and plot population trajectory
        summary(p1) 
	
	# summarizes and plots harvest history
	summary(p1, harvest=TRUE)