Last data update: 2014.03.03

R: Builds P and F matrices built off regressions fitted to...
makeIntegerFmatrixR Documentation

Builds P and F matrices built off regressions fitted to discrete variables (with probability mass functions rather than probability density functions).

Description

Uses survival, growth and fecundity objects to construct a matrix defining per-capita contribution to recruitment stages (e.g., propagules [seed, spore], seedlings, calves) by reproductive stages due to sexual reproduction (for the F matrix); and transition probabilities determined from survival and growth to quasi-continuous stages based on integer data (e.g. number of leaves) as opposed to truly continuous data (e.g. mass). NOTE - old createIntegerPmatrix is being deprecated; use makeIntegerPmatrix instead; etc

Usage

makeIntegerFmatrix(fecObj, nEnvClass = 1, meshpoints = 1:20, 
	chosenCov = data.frame(covariate=1), 
	preCensus = TRUE, survObj = NULL, growObj = NULL, offspringObj=NULL)

makeIntegerPmatrix(nEnvClass = 1, 
		meshpoints = 1:20,
		chosenCov = data.frame(covariate = 1), 
		growObj, survObj, 
		discreteTrans = 1)

Arguments

fecObj

fecundity object.

nEnvClass

numeric, number of environmental classes, always = 1 for non-compound matrices.

meshpoints

numeric, identifying meshpoints

chosenCov

data-frame indicating level of the discrete covariate, or range of values where multiple covariates are modeled.

preCensus

logical (TRUE or FALSE), indicating whether the fecundity object should represent an interval between pre-breeding or a post-breeding censuses. defaults to TRUE (pre-breeding census), meaning that all reproduction and offspring rates required for the F matrix are embedded in fecObj. Alternatively, an F matrix based on post-breeding census (preCensus=FALSE) requires additional survObj and growObj, to cover the survival and growth of the parents until the reproductive event.

survObj

survival object, describing the survival of parents from a census until the reproductive event starts (at some point during the inter-census time step). If preCensus = FALSE but no survival object is provided, it is assumed that all individuals survive to the breeding event.

growObj

growth object, describing the growth of parents that survive until the reproductive event starts. Warning: this growth object is still ignored in makeIPMFmatrix in the current version of IPMpack. It will become functional in coming versions. So far it is assumed that at time of breeding the individuals have the same size as at the beginning of the time interval.

discreteTrans

object of class discreteTrans, or numeric.

offspringObj

growth object, describing the size of offspring (this process may alternatively appear in fecObj).

Details

do check whether the Pmatrix adequately reflects survival by using diagnosticsPmatrix().

Value

an object of class IPMmatrix with dimensions length(meshpoints)*length(meshpoints), or length(meshpoints)+nrow(discreteTrans).

Note

With thanks to Dr Alden Griffith.

Author(s)

C. Jessica E. Metcalf, Sean M. McMahon, Roberto Salguero-Gomez, Eelke Jongejans & Cory Merow.

References

For information on F and P matrix: Caswell. 2001. Matrix population models: construction, analysis, and interpretation. 2nd ed. Sinauer. p110-112.

See Also

makeDiscreteTransInteger, makeFecObjInteger

Examples


# Open dataset for the herbaceous perennial Cryptantha flava 
# where the state variable is integer (number of rosettes)
data(dataIPMpackCryptantha)
head(dataIPMpackCryptantha)
d <- dataIPMpackCryptantha

#See the description of the data for information on the variables
help(dataIPMpackCryptantha)

# For this example, focus only on the first annual transition available 
# in the dataset
d1 <- d[d$year==2004, ]

#Make survival, growth and fecundity objects assuming a poisson distribution
so <- makeSurvObj(d1)
go1 <- makeGrowthObj(d1, Formula = sizeNext~size, Family = "poisson")
fo <- makeFecObjInteger(d1, Formula = fec1~size, distOffspring = "poisson")

#Create P and F matrices
Pmatrix1 <- makeIntegerPmatrix(growObj = go1, survObj = so, meshpoints = 1:101, 
    discreteTrans = 1)
Fmatrix <- makeIntegerFmatrix(fecObj = fo, meshpoints = 1:101)

par(mfrow = c(1, 3), bty = "l")

plot(d1$size, d1$sizeNext, xlab = "Stage at t", ylab = "Stage at t+1")

image(Pmatrix1@meshpoints, Pmatrix1@meshpoints, t(Pmatrix1), 
	xlab = "Stage at t", 
		ylab = "Stage at t+1")
image(Fmatrix@meshpoints, Fmatrix@meshpoints, t(Fmatrix), 
	xlab = "Stage at t", 
		ylab = "Stage at t+1")		

#Same approach, but with negative binomial instead of 
# poisson for stage transitions
go2 <- makeGrowthObj(d1, Formula = sizeNext~size, Family = "negbin")

#Recalculate the P matrix
Pmatrix2 <- makeIntegerPmatrix(growObj = go1, survObj = so, 
    meshpoints = 1:101, discreteTrans = 1)

par(mfrow = c(1, 3), bty = "l")
plot(d1$size, d1$sizeNext, xlab = "Stage at t", ylab = "Stage at t+1")
points(1:100, predict(go2@fit[[1]], newdata = data.frame(size = 1:100),
		type = "response"), type = "l", col = 2)

image(Pmatrix2@meshpoints, Pmatrix2@meshpoints, t(Pmatrix2), 
	xlab = "Stage at t", 
		ylab = "Stage at t+1")
image(Fmatrix@meshpoints, Fmatrix@meshpoints, t(Fmatrix), 
	xlab = "Stage at t", 
		ylab = "Stage at t+1")		

#The following repeats the same approach, but with negative binomial 
# instead of poisson for stage transitions
dff <- generateData()
go2 <- makeGrowthObj(d1, Family = "negbin")
Pmatrix2 <- makeIntegerPmatrix(growObj = go2, survObj = so, 
    meshpoints = 1:101, discreteTrans = 1)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(IPMpack)
Loading required package: Matrix
Loading required package: MASS
Loading required package: nlme
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IPMpack/makeIntegerFmatrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: makeIntegerFmatrix
> ### Title: Builds P and F matrices built off regressions fitted to discrete
> ###   variables (with probability mass functions rather than probability
> ###   density functions).
> ### Aliases: makeIntegerFmatrix makeIntegerPmatrix createIntegerFmatrix
> ###   createIntegerPmatrix
> 
> ### ** Examples
> 
> 
> # Open dataset for the herbaceous perennial Cryptantha flava 
> # where the state variable is integer (number of rosettes)
> data(dataIPMpackCryptantha)
> head(dataIPMpackCryptantha)
                    ID treatment site plot quadrat  x  y shrub compass distance
1  Control_I_3_3_65_25   Control    I    3       3 65 25  <NA>      NA       NA
2 Control_II_5_2_46_42   Control   II    5       2 46 42  <NA>      NA       NA
3 Control_II_5_4_40_35   Control   II    5       4 40 35  <NA>      NA       NA
4 Control_II_5_4_95_91   Control   II    5       4 95 91  <NA>      NA       NA
5 Control_II_5_5_50_70   Control   II    5       5 50 70  <NA>      NA       NA
6 Control_II_5_5_50_70   Control   II    5       5 50 70  <NA>      NA       NA
  year prec age size fec0 fec1 surv precNext ageNext sizeNext
1 2004   56  NA   NA   NA   NA   NA       36       1        4
2 2004   56   1    1    0   NA    0       36      NA       NA
3 2004   56   6   43    1    6    1       36       7       25
4 2004   56  NA   NA   NA   NA   NA       36       1        1
5 2004   56   1    1    0   NA    0       36      NA       NA
6 2004   56   1    1    0   NA    0       36      NA       NA
> d <- dataIPMpackCryptantha
> 
> #See the description of the data for information on the variables
> help(dataIPMpackCryptantha)
dataIPMpackCryptantha         package:IPMpack          R Documentation

_C_r_y_p_t_a_n_t_h_a _P_e_r_e_n_n_i_a_l _D_a_t_a_s_e_t _w_i_t_h _C_o_v_a_r_i_a_t_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Demographic data of Cryptantha flava in the "Redfleet State Park",
     UT, USA. Life cycle, experimental design and data are described in
     Salguero-Gomez et al (2012). Data contains a subset of individuals
     from 2004 to 2010. Full dataset can be obtained upon request to
     the authors (salguero@demogr.mpg.de and bcasper@sas.upenn.edu).

_U_s_a_g_e:

     data(dataIPMpackCryptantha)
     
_F_o_r_m_a_t:

     The format is: chr "dataIPMpackCryptantha"

_D_e_t_a_i_l_s:

     Data-frame with headings:

     - ID: unique plant id (this file contains only a subset of all
     individuals)

     - treatment: the full experimental design contain to droughts (in
     1998 and 1999) but this subset contains only info on the control
     permanent plots. See Lucas et al J Ecol 2008

     - site: spatial replication site

     - plot: plot number

     - quadrat: quadrat number inside of plot

     - x: x coordinate (cm) inside of the quadrat

     - y: y coordinate (cm) inside of the quadrat

     - shrub: shrub species within the zone of influence of the
     individual (At = Artemisia tridentata; Cn = Chrysothamnus
     nauseosus)

     - compass: compass direction of the line connecting the centroid
     of the shrub and the individual of Cryptantha flava

     - distance: distance (in cm) of the individual of Cryptantha flava
     to the shrub. Negative distance imply the individual is "inside"
     the shrub. Zero implies the individual is at the edge of the
     shrub's canopy.

     - year: transition from t to t+1 (this subset contains only data
     for 2004-2010)

     - prec: annual precipitation (in cm) from June of year t-1 to May
     of year t

     - age: age of individual (in years) in year t. Individuals of
     unknown age are assigned to 999

     - size: total number of rosettes (vegetative and flowering) of the
     individual in year t

     - fec0: probability of reproduction (0: vegetative, 1: flowering;
     NA: individual not alive) in year t

     - fec1: number of flowering rosettes in year t (NA: fec0 = 0 or
     NA)

     - surv: survival (0 = dead, 1= alive, NAs if not yet recruited)

     - precNext: annual precipitation (in cm) from June of year t to
     May of year t+1

     - ageNext: age of individual (in years) in year t+1. Individuals
     of unknown age are assigned to 999

     - sizeNext: total number of rosettes (vegetative and flowering) of
     the individual in year t+1

_A_u_t_h_o_r(_s):

     Rob Salguero-Gomez & Brenda B Casper

_R_e_f_e_r_e_n_c_e_s:

     Salguero-Gomez R, Siewert W, Casper B & Tielboerger K. Oct 2012. A
     demographic approach to study effects of climate change in desert
     plants. Philosophical Transactions of the Royal Society. Series B
     - Biological Sciences x, pxxx-xxx

     Lucas R, Forseth I, Casper B. 2008. Using rainout shelters to
     evaluate climate change effects on the demography of Cryptantha
     flava. Journal of Ecology 96, p514-522

_E_x_a_m_p_l_e_s:

     data(dataIPMpackCryptantha)
     print(head(dataIPMpackCryptantha))
     

> 
> # For this example, focus only on the first annual transition available 
> # in the dataset
> d1 <- d[d$year==2004, ]
> 
> #Make survival, growth and fecundity objects assuming a poisson distribution
> so <- makeSurvObj(d1)
> go1 <- makeGrowthObj(d1, Formula = sizeNext~size, Family = "poisson")
> fo <- makeFecObjInteger(d1, Formula = fec1~size, distOffspring = "poisson")
> 
> #Create P and F matrices
> Pmatrix1 <- makeIntegerPmatrix(growObj = go1, survObj = so, meshpoints = 1:101, 
+     discreteTrans = 1)
> Fmatrix <- makeIntegerFmatrix(fecObj = fo, meshpoints = 1:101)
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
> 
> par(mfrow = c(1, 3), bty = "l")
> 
> plot(d1$size, d1$sizeNext, xlab = "Stage at t", ylab = "Stage at t+1")
> 
> image(Pmatrix1@meshpoints, Pmatrix1@meshpoints, t(Pmatrix1), 
+ 	xlab = "Stage at t", 
+ 		ylab = "Stage at t+1")
> image(Fmatrix@meshpoints, Fmatrix@meshpoints, t(Fmatrix), 
+ 	xlab = "Stage at t", 
+ 		ylab = "Stage at t+1")		
> 
> #Same approach, but with negative binomial instead of 
> # poisson for stage transitions
> go2 <- makeGrowthObj(d1, Formula = sizeNext~size, Family = "negbin")
[1] "setting link to identity"
> 
> #Recalculate the P matrix
> Pmatrix2 <- makeIntegerPmatrix(growObj = go1, survObj = so, 
+     meshpoints = 1:101, discreteTrans = 1)
> 
> par(mfrow = c(1, 3), bty = "l")
> plot(d1$size, d1$sizeNext, xlab = "Stage at t", ylab = "Stage at t+1")
> points(1:100, predict(go2@fit[[1]], newdata = data.frame(size = 1:100),
+ 		type = "response"), type = "l", col = 2)
> 
> image(Pmatrix2@meshpoints, Pmatrix2@meshpoints, t(Pmatrix2), 
+ 	xlab = "Stage at t", 
+ 		ylab = "Stage at t+1")
> image(Fmatrix@meshpoints, Fmatrix@meshpoints, t(Fmatrix), 
+ 	xlab = "Stage at t", 
+ 		ylab = "Stage at t+1")		
> 
> #The following repeats the same approach, but with negative binomial 
> # instead of poisson for stage transitions
> dff <- generateData()
> go2 <- makeGrowthObj(d1, Family = "negbin")
[1] "setting link to identity"
> Pmatrix2 <- makeIntegerPmatrix(growObj = go2, survObj = so, 
+     meshpoints = 1:101, discreteTrans = 1)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>