Chapter 3 Preliminaries II: Data Formatting

The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents.

— H.P. Lovecraft, The Call of Cthulhu

Matrix projection models are estimated with demographic data. Regardless of whether the goal is a set of raw (empirical) or function-based matrices, the dataset used needs to follow a particular format to make the estimation of elements or vital rate models possible. Package lefko3 utilizes a standardized format similar to formats required by other protocols, such as the projection.matrix() function in package popbio. However, unlike other packages, lefko3 includes functions that can standardize a variety of starting dataset formats into the right format. These functions likely do not cover all possibilities, but deal with most of the interesting differences among the protocols that different demographers use.

The format used in analysis is similar to what one would expect in setting up a data frame for a linear model in R or another statistical analysis environment. If we start with a record of observations of a single individual across several years, where each observation was conducted during a single monitoring session per time interval (such as year), then our data needs to be formatted in a way that allows us to assess at the very least whether the state of an individual at some time depends on the state at the previous time. For a historical model, this dependence extends one further time step back, meaning that we have to be able to assess demographic patterns across groups of three consecutive monitoring times.

In order to analyze these patterns of dependence, we break the data up into pairs of consecutive observation times (or groups of three consecutive times if analyzing historical models). These broken up pairs are then stacked together into a data frame. For example, if we have data for an individual in years 2010, 2011, 2012, and 2013, then we would break up these data into a data set for the years 2010 and 2011, followed by the years 2011 and 2012, followed by the years 2012 and 2013 (if historical, then we would break up 2010-2011-2012, followed by 2011-2012-2013). In terms of the language of matrix projection models, these standardized dataset are arranged with time t followed by time t+1 if ahistorical, and time t-1, followed by time t, followed by time t+1 if in historical format. Thinking of this in terms of the language of linear modeling, individual status in the final time in each group can be seen as the response variable, while status in the previous one or two times can be seen as the causal variable(s). We refer to this stacked format as vertical format, because it stretches the data for a single individual vertically across rows. This format can be further divided into historically-formatted vertical (hfv) format (Shefferson et al. 2021), in which groups of three consecutive monitoring times are stacked, and ahistorically-formatted vertical (ahfv) format, in which pairs of consecutive years are stacked. Note that analysis in lefko3 requires historically-formatted vertical (hfv) format.

The different aspects of the states of individuals can be described by different variables per observation time. There may be one or more measures of size, an age metric, a measure of reproductive status, and perhaps fecundity, among other variables. Each monitoring occasion should have the same variables for use in analysis. Thus, concatenating states for consecutive pairs or triplets of times in this way will generally result in data frames with many more than two or three columns. Stacking the data in this fashion also ends up typically leading to multiple rows of data originating from the same individual. Until recently, these rows were treated as independent data points, and the simplest analyses still assume independence. However, if a separate variable is created recording the identity of the individual across rows within the dataset, then the non-independence of data points can be dealt with statistically via the use of individual identity as a random factor in function-based modeling (more on this in later chapters).

3.1 Kinds of individual state variables that may be included

What sorts of variables can be handled in MPM analysis through lefko3? Because this package was originally developed to handle historical size-classified Lefkovitch models, it can of course handle size variables. From version 4.0.0 onward, up to three different size variables can be included in a single analysis. However, it can handle many, many more variables. At the very least, variables denoting reproductive status and fecundity can be included. These three groups of variables - size, reproductive status, and fecundity - are the classic three variable types used for classification purposes in stage-based models. Wildlife demographers may be more interested in age than size, and so age at each time can also be included. In fact, lefko3 automates the estimation of age and related variables, such as observed age at time t and observed lifespan, and can be used to estimate both Leslie (age-based) and age-by-stage MPMs. Plant demographers may be particularly interested in variables denoting observation status, which is a binomial variable used to denote whether an individual is in an observable stage (lefko3 can automate the identification of these occurrences within the dataset). They may also be interest in using multiple measures of reproductive status and fecundity, since many plants and animals have multiple modes of reproduction, and often actual fecundity cannot be accurately known and so must be estimated.

Identity variables may be included and used in analysis. Such variables include population identity, patch identity or subpopulation identity, individual identity, and monitoring occasion or time (denoting the time at time t). Package lefko3 can use these to subset the data accordingly, and also to estimate variables such as observed age at timet and observed lifespan. If the user has already determined stages for all individuals at all times, then these data may be incorporated as well (although lefko3 can automatically assign stages).

Demographers commonly include censoring variables to denote data points that are suspect. These can also be included in lefko3, and those data points can also be easily removed from analysis. For example, individuals with damaged tags from which identity cannot be properly read can be marked differently in a censor variable, and analyses can then be performed with and without these potentially biasing data.

Spatial coordinates can be included in datasets. When used, spatial coordinates should be Cartesian, and so paired as X-Y coordinates. Package lefko3 includes automated density estimation, and so these coordinates can be used to estimate spatial density.

Finally, variables can be included covering status as alive or dead, status as observed or unobserved, and up to three separate individual or environmental covariates that can be numeric or categorical. Individual covariates may be particularly useful as a means to include environmental variables, or further information on status, such as management regime or presence of injury.

3.2 Formatting demographic data properly for analysis

Regardless of how the dataset should be structured for analysis, demographers themselves often have their own ways of structuring data. In general, most demographers keep their data either in some variant of vertical format (explained above), or in some variant of horizontal format, in which the data for each single individual spans only a single row that contains all data on state across all monitoring occasions. In figure 3.1, we see an example of an ahistorically-formatted vertical dataset. In figure 3.2, we see an example of a horizontally-formatted dataset.

Figure 3.1: Vertically-formatted dataset covering the Cypripedium candidum data

Figure 3.2: Horizontally-formatted dataset covering the Cypripedium candidum data

Every demographer has their own way of keeping data, and I personally do not feel it is up to me to judge (the level of chaos in my own record-keeping prevents me from making ANY harsh judgments). I have therefore created two powerful functions that can handle most datasets falling into these two general types and standardize them into formats that can be analyzed by lefko3. These functions include verticalize3(), and historicalize3(). We will start by describing the former.

3.3 Function verticalize3()

Many demographers (including the author) prefer horizontal data formats for demographic record-keeping. Here, individual life histories are recorded in a spreadsheet with each unique individual’s data organized within a single row. The columns then correspond to descriptor variables and to condition at different times. This format has the advantage that of making an individual’s resighting history easy to analyze even by eye, since it must occur all within a single row. In these circumstances, the verticalize3() function can standardize these data into hfv format.

The verticalize3() function takes a number of inputs. Naturally, it needs the data frame being used for analysis (the data field). It also requires input corresponding to the number of monitoring occasions that the dataset covers (field noyears), and which columns identify the population, patch or subpopulation, and individual (fields popidcol, patchidcol, and individcol, respectively).

After these most basic of fields have been entered, the columns conveying each kind of demographic variable need to be identified (this is a very flexible function, so only those variables that actually occur in the dataset need be identified and all others can be ignored). Up to three separate size variables can be identified (sizeacol, sizebcol, and sizeccol), as can up to two reproductive status variables (repstracol and restrbcol), and up to two fecundity variables (fecacol and fecbcol). These variables will naturally repeat across monitoring occasions, and so each variable represents as many actual columns as monitoring occasions covered by the dataset.

To ensure that R finds all columns corresponding to a variable, the user may take one of two approaches. The most flexible is to treat each input field as a vector, and to input the name or column number of each variable in order of monitoring occasion. For example, if we decided to use only one size variable, perhaps the height of a plant in centimeters, and this variable is labelled ht.2010, ht.2011, ht.2012, and ht.2013 for the years 2010, 2011, 2012, and 2013, the we can input:

sizeacol = c("ht.2010", "ht.2011", "ht.2012", "ht.2013").

All other variables covering status across time need to be input in the same way, yielding equal length vectors in the same temporal order.

Alternatively, if the data is arranged such that each monitoring occasion has its data arranged in a strictly repeating order, and each variable is a fixed number of columns away from the equivalent variable in the preceding time and in the next time, then only the first of these columns needs to be designated, and the blocksize field can be set to the number of columns separating these entries. In the plant height example, if each size variable is 10 columns after the previous size variable and this pattern holds for all other variable types, then this would mean entering only

noyears = 4, blocksize = 10, sizeacol = "ht.2010"

Note that the use of the blocksize option absolutely requires that each instance of a particular variable occurs exactly blocksize columns after the previous instance, with no exceptions allowed. Users who occasionally add empty columns here and there in their dataset will likely find mistakes in the resulting standardization if they do not make sure that the exact number of columns between instances is always the same.

While standardizing the data, function verticalize3() can also handle stage assignment if given a proper stageframe (the stageassign field). For this purpose, lefko3 also needs the proper size variable designations. Currently, the options include:

  • sizea, sizeb, or sizec if only one of these size metrics determines stage
  • sizeab, sizeac, or sizebc if stage assignment is based on a pair of size metrics
  • sizeabc if stage assignment should utilize three size metrics; or
  • sizeadded, if stage assignment should proceed on the basis of the sum of all used size metrics.

Stage assignment is automated using these size metrics as well as reproductive status, observation status, and status as propagule, immature, and mature. Stage assignment will yield warnings and unassigned stages if any combination of variables is found in the demographic dataset that does not fit exactly one stage in the stage frame. We also encourage the use of this function without stage assignment on the first pass, since this will allow users to explore the data more fully prior to the development of a life history model and stageframe.

Function verticalize3() includes a few more fields of interest. The repstrrel and fecrel fields provided means of equalizing reproductive status variables and fecundity variables, respectively, that are set on different scales. For example, if two reproductive status variables are used - the first covering single-flowered individuals and the second covering double-flowered individual - then setting repstrrel = 2 will tell R that the second variable counts for twice the reproductive status of the first. The same applies to fecundity, if two different fecundity measures are used.

Demographers using censoring variables will find powerful options in this function. First, censorcol can be set to a static censor variable covering an individual’s entire resighting history, or to censor variables across time. This can be set with the censorRepeat field, which defaults to FALSE and so assumes that censor values do not vary across time. The value of the censor variable used to denote which individuals to keep can be set to any numeric value (the censorkeep option). The default is censorkeep = 0, meaning that any data points marked 0 are considered OK, while any other value is assumed to be subject to removal. Even NA can be used as the value to mark data to keep. Finally, if all options are set as described, then function verticalize3() will format censor the data with censor variables but will not remove any data points. To force verticalize3() to remove censored data points, set censor = TRUE.

Function verticalize3() can handle spatial coordinates, and can even estimate spatial density. Cartesian coordinates for each individual are assumed to be a single set. However, if coordinates can change across time and each time point has its own set of coordinates for each individual present, then users can set coordsRepeat = TRUE. If the intent in using these coordinates is to estimate spatial density, then this function will calculate the number of individuals within some radius of each focal individual in each monitoring time if given the length of the radius to use via option spacing (e.g. spacing = 1 sets the distance radius to check for other individuals nearby at one unit of distance).

This function includes further parameters handling miscellaneous cases. First, demographers often treat missing data as blanks within their spreadsheets. Setting NAas0 = TRUE tells R to interpret missing data as zeros. This can be useful in many circumstances. For example, if fecundity is estimated as the number of flowers per individual in a plant demographic study, but the number of flowers per individual is only recorded if flowers actually exist, then setting NAas0 = TRUE can allow 0 values to be incorporated in analyses of this fecundity variable when no data were entered for flower number. Second, the NRasRep option allows stage classification to proceed without matching stage reproductive characteristics to the data. For example, if stages are defined such that mature stages are reproductive but it is nonetheless possible for fecundity to equal 0, then setting NRasRep = TRUE tells R not to use reproductive status in stage classification. Otherwise, R will assume that a mature individual that produces offspring is in a different stage than a mature individual that does not, leading to warnings, unassigned stages, and further difficulties if the stageframe does not include stages to cover the non-reproductive category. Third, the NAasObs option provides a means of telling R that unobservable stages should be treated as observed during stage classification, if set to TRUE (the default is FALSE). Fourth, the reduce option, if set to TRUE, will tell R that any columns in the output dataset with a single constant value across all rows should be removed, as invariant variables yield no influence on response variables. Fifth, the a2check field should generally be kept to FALSE (the default), but if set to TRUE, then the resulting standardized dataset will include data for individuals not alive in time t (these instances are removed automatically under the default, since it is only individuals alive in time t that can transition to anything in time t+1). Finally, this function assumes that monitoring studies are conducted using pre-breeding life history models, making the earliest observed age be 1 time unit. To set to post-breeding, set prebreeding = FALSE. Additionally, the age_offset option can be used to add a specific number to all ages, as might happen if the first few years of life cannot be monitored.

Now that we have explained the options, let’s standardize data frames for the stageframes created in the last chapter (chapter 2). Let’s first standardize the vertical dataset for the raw MPM. For this purpose, we will utilize the verticalize3() function. Because we are lumping reproductive and non-reproductive individuals into the non-dormant adult classes, we need to set NRasRep = TRUE. Otherwise, verticalize3() will attempt to use the reproductive status of individuals in classification, and will fail due to the presence of non-reproductive adults. We also need to set NAas0 = TRUE to make sure that NA values in size are turned into 0 entries where necessary, and so aid in the assignment of the vegetative dormancy stage. Note that we will set up three different size variables here, as sizea, sizeb, and sizec, and that we will tell R that we want overall size to be the sum of these (stagesize = "sizeadded"). Finally, since the individuals in this dataset must be at least five years old when they are first seen as adults, we will use the age_offset option to adjust the estimated age.

cypraw_v1 <- verticalize3(data = cypdata, noyears = 6, firstyear = 2004, 
  patchidcol = "patch", individcol = "plantid", blocksize = 4,
  sizeacol = "Inf2.04", sizebcol = "Inf.04", sizeccol = "Veg.04",
  repstracol = "Inf.04", repstrbcol = "Inf2.04", fecacol = "Pod.04",
  stageassign = cypframe_raw, stagesize = "sizeadded", NAas0 = TRUE,
  NRasRep = TRUE, age_offset = 4)

summary(cypraw_v1)
>      rowid       popid  patchid   individ              year2     
>  Min.   : 1.00   :320   A: 93   Length:320         Min.   :2004  
>  1st Qu.:21.00          B:154   Class :character   1st Qu.:2005  
>  Median :37.50          C: 73   Mode  :character   Median :2006  
>  Mean   :38.45                                     Mean   :2006  
>  3rd Qu.:56.00                                     3rd Qu.:2007  
>  Max.   :77.00                                     Max.   :2008  
>    firstseen       lastseen        obsage       obslifespan   
>  Min.   :2004   Min.   :2004   Min.   :5.000   Min.   :0.000  
>  1st Qu.:2004   1st Qu.:2009   1st Qu.:6.000   1st Qu.:5.000  
>  Median :2004   Median :2009   Median :7.000   Median :5.000  
>  Mean   :2004   Mean   :2009   Mean   :6.853   Mean   :4.556  
>  3rd Qu.:2004   3rd Qu.:2009   3rd Qu.:8.000   3rd Qu.:5.000  
>  Max.   :2008   Max.   :2009   Max.   :9.000   Max.   :5.000  
>      sizea1             sizeb1            sizec1       size1added    
>  Min.   :0.000000   Min.   : 0.0000   Min.   : 0.0   Min.   : 0.000  
>  1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.: 0.0   1st Qu.: 0.000  
>  Median :0.000000   Median : 0.0000   Median : 1.0   Median : 2.000  
>  Mean   :0.009375   Mean   : 0.7469   Mean   : 1.9   Mean   : 2.656  
>  3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.: 3.0   3rd Qu.: 4.000  
>  Max.   :1.000000   Max.   :18.0000   Max.   :13.0   Max.   :21.000  
>     repstra1          repstrb1            feca1          juvgiven1
>  Min.   : 0.0000   Min.   :0.000000   Min.   :0.0000   Min.   :0  
>  1st Qu.: 0.0000   1st Qu.:0.000000   1st Qu.:0.0000   1st Qu.:0  
>  Median : 0.0000   Median :0.000000   Median :0.0000   Median :0  
>  Mean   : 0.7469   Mean   :0.009375   Mean   :0.2656   Mean   :0  
>  3rd Qu.: 1.0000   3rd Qu.:0.000000   3rd Qu.:0.0000   3rd Qu.:0  
>  Max.   :18.0000   Max.   :1.000000   Max.   :7.0000   Max.   :0  
>    obsstatus1       repstatus1       fecstatus1       matstatus1    
>  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1.0000  
>  Median :1.0000   Median :0.0000   Median :0.0000   Median :1.0000  
>  Mean   :0.7469   Mean   :0.2875   Mean   :0.1344   Mean   :0.7688  
>  3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1.0000  
>  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
>      alive1          stage1           stage1index         sizea2        
>  Min.   :0.0000   Length:320         Min.   : 0.000   Min.   :0.000000  
>  1st Qu.:1.0000   Class :character   1st Qu.: 6.000   1st Qu.:0.000000  
>  Median :1.0000   Mode  :character   Median : 8.000   Median :0.000000  
>  Mean   :0.7688                      Mean   : 6.144   Mean   :0.009375  
>  3rd Qu.:1.0000                      3rd Qu.: 8.000   3rd Qu.:0.000000  
>  Max.   :1.0000                      Max.   :11.000   Max.   :1.000000  
>      sizeb2            sizec2         size2added        repstra2      
>  Min.   : 0.0000   Min.   : 0.000   Min.   : 0.000   Min.   : 0.0000  
>  1st Qu.: 0.0000   1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.: 0.0000  
>  Median : 0.0000   Median : 2.000   Median : 2.000   Median : 0.0000  
>  Mean   : 0.8969   Mean   : 2.416   Mean   : 3.322   Mean   : 0.8969  
>  3rd Qu.: 1.0000   3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.: 1.0000  
>  Max.   :18.0000   Max.   :13.000   Max.   :24.000   Max.   :18.0000  
>     repstrb2            feca2          juvgiven2   obsstatus2    
>  Min.   :0.000000   Min.   :0.0000   Min.   :0   Min.   :0.0000  
>  1st Qu.:0.000000   1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0000  
>  Median :0.000000   Median :0.0000   Median :0   Median :1.0000  
>  Mean   :0.009375   Mean   :0.2906   Mean   :0   Mean   :0.9531  
>  3rd Qu.:0.000000   3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000  
>  Max.   :1.000000   Max.   :7.0000   Max.   :0   Max.   :1.0000  
>    repstatus2       fecstatus2       matstatus2     alive2     stage2         
>  Min.   :0.0000   Min.   :0.0000   Min.   :1    Min.   :1   Length:320        
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1    1st Qu.:1   Class :character  
>  Median :0.0000   Median :0.0000   Median :1    Median :1   Mode  :character  
>  Mean   :0.3688   Mean   :0.1562   Mean   :1    Mean   :1                     
>  3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1                     
>  Max.   :1.0000   Max.   :1.0000   Max.   :1    Max.   :1                     
>   stage2index         sizea3             sizeb3           sizec3      
>  Min.   : 6.000   Min.   :0.000000   Min.   : 0.000   Min.   : 0.000  
>  1st Qu.: 7.000   1st Qu.:0.000000   1st Qu.: 0.000   1st Qu.: 1.000  
>  Median : 8.000   Median :0.000000   Median : 0.000   Median : 1.000  
>  Mean   : 7.919   Mean   :0.009375   Mean   : 1.069   Mean   : 2.209  
>  3rd Qu.: 8.000   3rd Qu.:0.000000   3rd Qu.: 1.000   3rd Qu.: 3.000  
>  Max.   :11.000   Max.   :1.000000   Max.   :18.000   Max.   :13.000  
>    size3added        repstra3         repstrb3            feca3       
>  Min.   : 0.000   Min.   : 0.000   Min.   :0.000000   Min.   :0.0000  
>  1st Qu.: 1.000   1st Qu.: 0.000   1st Qu.:0.000000   1st Qu.:0.0000  
>  Median : 2.000   Median : 0.000   Median :0.000000   Median :0.0000  
>  Mean   : 3.288   Mean   : 1.069   Mean   :0.009375   Mean   :0.4562  
>  3rd Qu.: 4.000   3rd Qu.: 1.000   3rd Qu.:0.000000   3rd Qu.:0.0000  
>  Max.   :24.000   Max.   :18.000   Max.   :1.000000   Max.   :8.0000  
>    juvgiven3   obsstatus3    repstatus3    fecstatus3       matstatus3
>  Min.   :0   Min.   :0.0   Min.   :0.0   Min.   :0.0000   Min.   :1   
>  1st Qu.:0   1st Qu.:1.0   1st Qu.:0.0   1st Qu.:0.0000   1st Qu.:1   
>  Median :0   Median :1.0   Median :0.0   Median :0.0000   Median :1   
>  Mean   :0   Mean   :0.9   Mean   :0.4   Mean   :0.2219   Mean   :1   
>  3rd Qu.:0   3rd Qu.:1.0   3rd Qu.:1.0   3rd Qu.:0.0000   3rd Qu.:1   
>  Max.   :0   Max.   :1.0   Max.   :1.0   Max.   :1.0000   Max.   :1   
>      alive3          stage3           stage3index    
>  Min.   :0.0000   Length:320         Min.   : 0.000  
>  1st Qu.:1.0000   Class :character   1st Qu.: 7.000  
>  Median :1.0000   Mode  :character   Median : 8.000  
>  Mean   :0.9469                      Mean   : 7.544  
>  3rd Qu.:1.0000                      3rd Qu.: 8.000  
>  Max.   :1.0000                      Max.   :11.000

In the summary of the resulting data frame, we see that the first four variables are identifying information - they show the data row (rowid), the population ID (popid), the patch ID (patchid), and the individual ID (individ), in order. These are followed by two variables identifying in what monitoring occasion the individual was first seen (firstseen), and in what occasion it was last seen (lastseen). The next variable, obsage, gives the estimated age at time t. The next variable, obslifespan, gives the full length of time that the individual was observed in the dataset. After that, we see a group of 15 variables typically ending with the number 1. These 15 variables correspond to the state of each individual in time t-1 (generally referred to as time1 in the actual code). Similarly, the next 15 variables typically end with the number 2 and represent state in time t, while the last 15 variables typically end in the number 3 and refer to state in time t+1. Most of these variables should be obvious to interpret given the names (definitions are in the help file for this function). Note that the final seven variables in each group are calculated by verticalize3(). These variables represent observation status, reproductive status, fecundity status, maturity status, status as alive or dead, stage name, and stage number (with reference to the stageframe), in order.

Let’s also create our standardized data frame for the function-based MPM, as below. Remember that some of the settings need to change here because we will use a different life history model. Particularly, we are now going to separate adults not just by size but by reproductive status. So, we will NOT set NRasRep = TRUE here (the default is NRasRep = FALSE).

cypfb_v1 <- verticalize3(data = cypdata, noyears = 6, firstyear = 2004, 
  patchidcol = "patch", individcol = "plantid", blocksize = 4, 
  sizeacol = "Inf2.04", sizebcol = "Inf.04", sizeccol = "Veg.04", 
  repstracol = "Inf.04", repstrbcol = "Inf2.04", fecacol = "Pod.04", 
  stageassign = cypframe_fb, stagesize = "sizeadded", NAas0 = TRUE,
  age_offset = 4)

summary(cypfb_v1)
>      rowid       popid  patchid   individ              year2     
>  Min.   : 1.00   :320   A: 93   Length:320         Min.   :2004  
>  1st Qu.:21.00          B:154   Class :character   1st Qu.:2005  
>  Median :37.50          C: 73   Mode  :character   Median :2006  
>  Mean   :38.45                                     Mean   :2006  
>  3rd Qu.:56.00                                     3rd Qu.:2007  
>  Max.   :77.00                                     Max.   :2008  
>    firstseen       lastseen        obsage       obslifespan   
>  Min.   :2004   Min.   :2004   Min.   :5.000   Min.   :0.000  
>  1st Qu.:2004   1st Qu.:2009   1st Qu.:6.000   1st Qu.:5.000  
>  Median :2004   Median :2009   Median :7.000   Median :5.000  
>  Mean   :2004   Mean   :2009   Mean   :6.853   Mean   :4.556  
>  3rd Qu.:2004   3rd Qu.:2009   3rd Qu.:8.000   3rd Qu.:5.000  
>  Max.   :2008   Max.   :2009   Max.   :9.000   Max.   :5.000  
>      sizea1             sizeb1            sizec1       size1added    
>  Min.   :0.000000   Min.   : 0.0000   Min.   : 0.0   Min.   : 0.000  
>  1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.: 0.0   1st Qu.: 0.000  
>  Median :0.000000   Median : 0.0000   Median : 1.0   Median : 2.000  
>  Mean   :0.009375   Mean   : 0.7469   Mean   : 1.9   Mean   : 2.656  
>  3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.: 3.0   3rd Qu.: 4.000  
>  Max.   :1.000000   Max.   :18.0000   Max.   :13.0   Max.   :21.000  
>     repstra1          repstrb1            feca1          juvgiven1
>  Min.   : 0.0000   Min.   :0.000000   Min.   :0.0000   Min.   :0  
>  1st Qu.: 0.0000   1st Qu.:0.000000   1st Qu.:0.0000   1st Qu.:0  
>  Median : 0.0000   Median :0.000000   Median :0.0000   Median :0  
>  Mean   : 0.7469   Mean   :0.009375   Mean   :0.2656   Mean   :0  
>  3rd Qu.: 1.0000   3rd Qu.:0.000000   3rd Qu.:0.0000   3rd Qu.:0  
>  Max.   :18.0000   Max.   :1.000000   Max.   :7.0000   Max.   :0  
>    obsstatus1       repstatus1       fecstatus1       matstatus1    
>  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1.0000  
>  Median :1.0000   Median :0.0000   Median :0.0000   Median :1.0000  
>  Mean   :0.7469   Mean   :0.2875   Mean   :0.1344   Mean   :0.7688  
>  3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1.0000  
>  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
>      alive1          stage1           stage1index        sizea2        
>  Min.   :0.0000   Length:320         Min.   : 0.00   Min.   :0.000000  
>  1st Qu.:1.0000   Class :character   1st Qu.: 6.00   1st Qu.:0.000000  
>  Median :1.0000   Mode  :character   Median : 8.00   Median :0.000000  
>  Mean   :0.7688                      Mean   :14.17   Mean   :0.009375  
>  3rd Qu.:1.0000                      3rd Qu.:31.00   3rd Qu.:0.000000  
>  Max.   :1.0000                      Max.   :51.00   Max.   :1.000000  
>      sizeb2            sizec2         size2added        repstra2      
>  Min.   : 0.0000   Min.   : 0.000   Min.   : 0.000   Min.   : 0.0000  
>  1st Qu.: 0.0000   1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.: 0.0000  
>  Median : 0.0000   Median : 2.000   Median : 2.000   Median : 0.0000  
>  Mean   : 0.8969   Mean   : 2.416   Mean   : 3.322   Mean   : 0.8969  
>  3rd Qu.: 1.0000   3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.: 1.0000  
>  Max.   :18.0000   Max.   :13.000   Max.   :24.000   Max.   :18.0000  
>     repstrb2            feca2          juvgiven2   obsstatus2    
>  Min.   :0.000000   Min.   :0.0000   Min.   :0   Min.   :0.0000  
>  1st Qu.:0.000000   1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0000  
>  Median :0.000000   Median :0.0000   Median :0   Median :1.0000  
>  Mean   :0.009375   Mean   :0.2906   Mean   :0   Mean   :0.9531  
>  3rd Qu.:0.000000   3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000  
>  Max.   :1.000000   Max.   :7.0000   Max.   :0   Max.   :1.0000  
>    repstatus2       fecstatus2       matstatus2     alive2     stage2         
>  Min.   :0.0000   Min.   :0.0000   Min.   :1    Min.   :1   Length:320        
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1    1st Qu.:1   Class :character  
>  Median :0.0000   Median :0.0000   Median :1    Median :1   Mode  :character  
>  Mean   :0.3688   Mean   :0.1562   Mean   :1    Mean   :1                     
>  3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1                     
>  Max.   :1.0000   Max.   :1.0000   Max.   :1    Max.   :1                     
>   stage2index        sizea3             sizeb3           sizec3      
>  Min.   : 6.00   Min.   :0.000000   Min.   : 0.000   Min.   : 0.000  
>  1st Qu.: 7.00   1st Qu.:0.000000   1st Qu.: 0.000   1st Qu.: 1.000  
>  Median :10.00   Median :0.000000   Median : 0.000   Median : 1.000  
>  Mean   :18.17   Mean   :0.009375   Mean   : 1.069   Mean   : 2.209  
>  3rd Qu.:32.00   3rd Qu.:0.000000   3rd Qu.: 1.000   3rd Qu.: 3.000  
>  Max.   :54.00   Max.   :1.000000   Max.   :18.000   Max.   :13.000  
>    size3added        repstra3         repstrb3            feca3       
>  Min.   : 0.000   Min.   : 0.000   Min.   :0.000000   Min.   :0.0000  
>  1st Qu.: 1.000   1st Qu.: 0.000   1st Qu.:0.000000   1st Qu.:0.0000  
>  Median : 2.000   Median : 0.000   Median :0.000000   Median :0.0000  
>  Mean   : 3.288   Mean   : 1.069   Mean   :0.009375   Mean   :0.4562  
>  3rd Qu.: 4.000   3rd Qu.: 1.000   3rd Qu.:0.000000   3rd Qu.:0.0000  
>  Max.   :24.000   Max.   :18.000   Max.   :1.000000   Max.   :8.0000  
>    juvgiven3   obsstatus3    repstatus3    fecstatus3       matstatus3
>  Min.   :0   Min.   :0.0   Min.   :0.0   Min.   :0.0000   Min.   :1   
>  1st Qu.:0   1st Qu.:1.0   1st Qu.:0.0   1st Qu.:0.0000   1st Qu.:1   
>  Median :0   Median :1.0   Median :0.0   Median :0.0000   Median :1   
>  Mean   :0   Mean   :0.9   Mean   :0.4   Mean   :0.2219   Mean   :1   
>  3rd Qu.:0   3rd Qu.:1.0   3rd Qu.:1.0   3rd Qu.:0.0000   3rd Qu.:1   
>  Max.   :0   Max.   :1.0   Max.   :1.0   Max.   :1.0000   Max.   :1   
>      alive3          stage3           stage3index   
>  Min.   :0.0000   Length:320         Min.   : 0.00  
>  1st Qu.:1.0000   Class :character   1st Qu.: 7.00  
>  Median :1.0000   Mode  :character   Median :10.00  
>  Mean   :0.9469                      Mean   :18.57  
>  3rd Qu.:1.0000                      3rd Qu.:33.00  
>  Max.   :1.0000                      Max.   :54.00

The output dataset includes a number of summary variables, but the data is essentially broken down into groups of three consecutive monitoring occasions each (occasions t+1, t, and t-1, corresponding to year3, year2, and year1 in the output, respectively), with individuals spread across multiple rows. The output dataset is further limited to those entries in which the individual is alive in occasion t (year2), meaning that all rows in which an individual is dead or not yet recruited in occasion t are dropped. Since the input data is the same, we should see the same numbers of rows and columns in the raw and function-based cases, regardless of the different stageframes used. Thus, we have 320 rows of data and 54 variables in the raw case, and 320 rows of data and 54 variables in the function-based case.

3.4 Function historicalize3()

What should be done if the dataset is in ahistorical vertical format, in which an individual’s condition across time is recorded across rows in a spreadsheet, with a single row corresponding to either a single observation or to a pair of consecutive observations? In that case, the historicalize3() function can standardize the dataset properly. The inputs to this function are very similar to verticalize3(). However, the historicalize3() function assumes that the input dataset is organized with rows corresponding to individual status in either only one monitoring occasion, or two consecutive occasions. Inputs include a series of variables more or less equivalent to input options in verticalize3(), but some variable names end with 2col, and others end with 3col. The former denote status in time t, and are the minimum required for this function to run. If each row includes status in paired consecutive times, then variables ending in 3col can be used to designate status in time t+1. Additionally, this function requires a single variable identifying individuals across rows, so that each individual’s resighting history can be inferred and each group of three consecutive monitoring times can be put together. All other options work essentially the same as in verticalize3().

Package lefko3 also includes dataset cypvert, which is the same dataset as cypdata but set in ahistorical vertical format. Here, we will use the historicalize3() function to standardize this dataset, using the plantid variable as the individual identity term.

data(cypvert)

cypraw_v2 <- historicalize3(data = cypvert, patchidcol = "patch",
  individcol = "plantid", year2col = "year2", sizea2col = "Inf2.2",
  sizea3col = "Inf2.3", sizeb2col = "Inf.2", sizeb3col = "Inf.3",
  sizec2col = "Veg.2", sizec3col = "Veg.3", repstra2col = "Inf2.2",
  repstra3col = "Inf2.3", repstrb2col = "Inf.2", repstrb3col = "Inf.3",
  feca2col = "Pod.2", feca3col = "Pod.3", repstrrel = 2,
  stageassign = cypframe_raw, stagesize = "sizeadded", censorcol = "censor",
  censorkeep = 1, censor = FALSE, NAas0 = TRUE, NRasRep = TRUE, age_offset = 4,
  reduce = TRUE)

summary(cypraw_v2)
>      rowid           popid             patchid            individ         
>  Min.   :  0.00   Length:320         Length:320         Length:320        
>  1st Qu.: 79.75   Class :character   Class :character   Class :character  
>  Median :159.50   Mode  :character   Mode  :character   Mode  :character  
>  Mean   :159.70                                                           
>  3rd Qu.:239.25                                                           
>  Max.   :321.00                                                           
>      year2        firstseen       lastseen        obsage       obslifespan   
>  Min.   :2004   Min.   :2004   Min.   :2004   Min.   :5.000   Min.   :0.000  
>  1st Qu.:2005   1st Qu.:2004   1st Qu.:2009   1st Qu.:6.000   1st Qu.:5.000  
>  Median :2006   Median :2004   Median :2009   Median :7.000   Median :5.000  
>  Mean   :2006   Mean   :2004   Mean   :2009   Mean   :6.853   Mean   :4.556  
>  3rd Qu.:2007   3rd Qu.:2004   3rd Qu.:2009   3rd Qu.:8.000   3rd Qu.:5.000  
>  Max.   :2008   Max.   :2008   Max.   :2009   Max.   :9.000   Max.   :5.000  
>      sizea1             sizeb1            sizec1       size1added    
>  Min.   :0.000000   Min.   : 0.0000   Min.   : 0.0   Min.   : 0.000  
>  1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.: 0.0   1st Qu.: 0.000  
>  Median :0.000000   Median : 0.0000   Median : 1.0   Median : 2.000  
>  Mean   :0.009375   Mean   : 0.7469   Mean   : 1.9   Mean   : 2.656  
>  3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.: 3.0   3rd Qu.: 4.000  
>  Max.   :1.000000   Max.   :18.0000   Max.   :13.0   Max.   :21.000  
>     repstra1           repstrb1           feca1          juvgiven1
>  Min.   :0.000000   Min.   : 0.0000   Min.   :0.0000   Min.   :0  
>  1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.:0.0000   1st Qu.:0  
>  Median :0.000000   Median : 0.0000   Median :0.0000   Median :0  
>  Mean   :0.009375   Mean   : 0.7469   Mean   :0.2656   Mean   :0  
>  3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.:0.0000   3rd Qu.:0  
>  Max.   :1.000000   Max.   :18.0000   Max.   :7.0000   Max.   :0  
>    obsstatus1       repstatus1       fecstatus1       matstatus1    
>  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1.0000  
>  Median :1.0000   Median :0.0000   Median :0.0000   Median :1.0000  
>  Mean   :0.7469   Mean   :0.2875   Mean   :0.1344   Mean   :0.7688  
>  3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1.0000  
>  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
>      alive1          stage1           stage1index         sizea2        
>  Min.   :0.0000   Length:320         Min.   : 0.000   Min.   :0.000000  
>  1st Qu.:1.0000   Class :character   1st Qu.: 6.000   1st Qu.:0.000000  
>  Median :1.0000   Mode  :character   Median : 8.000   Median :0.000000  
>  Mean   :0.7688                      Mean   : 6.144   Mean   :0.009375  
>  3rd Qu.:1.0000                      3rd Qu.: 8.000   3rd Qu.:0.000000  
>  Max.   :1.0000                      Max.   :11.000   Max.   :1.000000  
>      sizeb2            sizec2         size2added        repstra2       
>  Min.   : 0.0000   Min.   : 0.000   Min.   : 0.000   Min.   :0.000000  
>  1st Qu.: 0.0000   1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.:0.000000  
>  Median : 0.0000   Median : 2.000   Median : 2.000   Median :0.000000  
>  Mean   : 0.8969   Mean   : 2.416   Mean   : 3.322   Mean   :0.009375  
>  3rd Qu.: 1.0000   3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.:0.000000  
>  Max.   :18.0000   Max.   :13.000   Max.   :24.000   Max.   :1.000000  
>     repstrb2           feca2          juvgiven2   obsstatus2    
>  Min.   : 0.0000   Min.   :0.0000   Min.   :0   Min.   :0.0000  
>  1st Qu.: 0.0000   1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0000  
>  Median : 0.0000   Median :0.0000   Median :0   Median :1.0000  
>  Mean   : 0.8969   Mean   :0.2906   Mean   :0   Mean   :0.9531  
>  3rd Qu.: 1.0000   3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000  
>  Max.   :18.0000   Max.   :7.0000   Max.   :0   Max.   :1.0000  
>    repstatus2       fecstatus2       matstatus2     alive2     stage2         
>  Min.   :0.0000   Min.   :0.0000   Min.   :1    Min.   :1   Length:320        
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1    1st Qu.:1   Class :character  
>  Median :0.0000   Median :0.0000   Median :1    Median :1   Mode  :character  
>  Mean   :0.3688   Mean   :0.1562   Mean   :1    Mean   :1                     
>  3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1                     
>  Max.   :1.0000   Max.   :1.0000   Max.   :1    Max.   :1                     
>   stage2index         sizea3             sizeb3           sizec3      
>  Min.   : 6.000   Min.   :0.000000   Min.   : 0.000   Min.   : 0.000  
>  1st Qu.: 7.000   1st Qu.:0.000000   1st Qu.: 0.000   1st Qu.: 1.000  
>  Median : 8.000   Median :0.000000   Median : 0.000   Median : 1.000  
>  Mean   : 7.919   Mean   :0.009375   Mean   : 1.069   Mean   : 2.209  
>  3rd Qu.: 8.000   3rd Qu.:0.000000   3rd Qu.: 1.000   3rd Qu.: 3.000  
>  Max.   :11.000   Max.   :1.000000   Max.   :18.000   Max.   :13.000  
>    size3added        repstra3           repstrb3          feca3       
>  Min.   : 0.000   Min.   :0.000000   Min.   : 0.000   Min.   :0.0000  
>  1st Qu.: 1.000   1st Qu.:0.000000   1st Qu.: 0.000   1st Qu.:0.0000  
>  Median : 2.000   Median :0.000000   Median : 0.000   Median :0.0000  
>  Mean   : 3.288   Mean   :0.009375   Mean   : 1.069   Mean   :0.4562  
>  3rd Qu.: 4.000   3rd Qu.:0.000000   3rd Qu.: 1.000   3rd Qu.:0.0000  
>  Max.   :24.000   Max.   :1.000000   Max.   :18.000   Max.   :8.0000  
>    juvgiven3   obsstatus3    repstatus3    fecstatus3       matstatus3
>  Min.   :0   Min.   :0.0   Min.   :0.0   Min.   :0.0000   Min.   :1   
>  1st Qu.:0   1st Qu.:1.0   1st Qu.:0.0   1st Qu.:0.0000   1st Qu.:1   
>  Median :0   Median :1.0   Median :0.0   Median :0.0000   Median :1   
>  Mean   :0   Mean   :0.9   Mean   :0.4   Mean   :0.2219   Mean   :1   
>  3rd Qu.:0   3rd Qu.:1.0   3rd Qu.:1.0   3rd Qu.:0.0000   3rd Qu.:1   
>  Max.   :0   Max.   :1.0   Max.   :1.0   Max.   :1.0000   Max.   :1   
>      alive3          stage3           stage3index    
>  Min.   :0.0000   Length:320         Min.   : 0.000  
>  1st Qu.:1.0000   Class :character   1st Qu.: 7.000  
>  Median :1.0000   Mode  :character   Median : 8.000  
>  Mean   :0.9469                      Mean   : 7.544  
>  3rd Qu.:1.0000                      3rd Qu.: 8.000  
>  Max.   :1.0000                      Max.   :11.000

Let’s also create the function-based MPM version.

cypfb_v2 <- historicalize3(data = cypvert, patchidcol = "patch",
  individcol = "plantid", year2col = "year2", sizea2col = "Inf2.2", 
  sizea3col = "Inf2.3", sizeb2col = "Inf.2", sizeb3col = "Inf.3", 
  sizec2col = "Veg.2", sizec3col = "Veg.3", repstra2col = "Inf2.2", 
  repstra3col = "Inf2.3", repstrb2col = "Inf.2", repstrb3col = "Inf.3", 
  feca2col = "Pod.2", feca3col = "Pod.3", repstrrel = 2,
  stageassign = cypframe_fb, stagesize = "sizeadded", censorcol = "censor",
  censorkeep = 1, censor = FALSE, NAas0 = TRUE, age_offset = 4, reduce = TRUE)

summary(cypfb_v2)
>      rowid           popid             patchid            individ         
>  Min.   :  0.00   Length:320         Length:320         Length:320        
>  1st Qu.: 79.75   Class :character   Class :character   Class :character  
>  Median :159.50   Mode  :character   Mode  :character   Mode  :character  
>  Mean   :159.70                                                           
>  3rd Qu.:239.25                                                           
>  Max.   :321.00                                                           
>      year2        firstseen       lastseen        obsage       obslifespan   
>  Min.   :2004   Min.   :2004   Min.   :2004   Min.   :5.000   Min.   :0.000  
>  1st Qu.:2005   1st Qu.:2004   1st Qu.:2009   1st Qu.:6.000   1st Qu.:5.000  
>  Median :2006   Median :2004   Median :2009   Median :7.000   Median :5.000  
>  Mean   :2006   Mean   :2004   Mean   :2009   Mean   :6.853   Mean   :4.556  
>  3rd Qu.:2007   3rd Qu.:2004   3rd Qu.:2009   3rd Qu.:8.000   3rd Qu.:5.000  
>  Max.   :2008   Max.   :2008   Max.   :2009   Max.   :9.000   Max.   :5.000  
>      sizea1             sizeb1            sizec1       size1added    
>  Min.   :0.000000   Min.   : 0.0000   Min.   : 0.0   Min.   : 0.000  
>  1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.: 0.0   1st Qu.: 0.000  
>  Median :0.000000   Median : 0.0000   Median : 1.0   Median : 2.000  
>  Mean   :0.009375   Mean   : 0.7469   Mean   : 1.9   Mean   : 2.656  
>  3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.: 3.0   3rd Qu.: 4.000  
>  Max.   :1.000000   Max.   :18.0000   Max.   :13.0   Max.   :21.000  
>     repstra1           repstrb1           feca1          juvgiven1
>  Min.   :0.000000   Min.   : 0.0000   Min.   :0.0000   Min.   :0  
>  1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.:0.0000   1st Qu.:0  
>  Median :0.000000   Median : 0.0000   Median :0.0000   Median :0  
>  Mean   :0.009375   Mean   : 0.7469   Mean   :0.2656   Mean   :0  
>  3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.:0.0000   3rd Qu.:0  
>  Max.   :1.000000   Max.   :18.0000   Max.   :7.0000   Max.   :0  
>    obsstatus1       repstatus1       fecstatus1       matstatus1    
>  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1.0000  
>  Median :1.0000   Median :0.0000   Median :0.0000   Median :1.0000  
>  Mean   :0.7469   Mean   :0.2875   Mean   :0.1344   Mean   :0.7688  
>  3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1.0000  
>  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
>      alive1          stage1           stage1index        sizea2        
>  Min.   :0.0000   Length:320         Min.   : 0.00   Min.   :0.000000  
>  1st Qu.:1.0000   Class :character   1st Qu.: 6.00   1st Qu.:0.000000  
>  Median :1.0000   Mode  :character   Median : 8.00   Median :0.000000  
>  Mean   :0.7688                      Mean   :14.17   Mean   :0.009375  
>  3rd Qu.:1.0000                      3rd Qu.:31.00   3rd Qu.:0.000000  
>  Max.   :1.0000                      Max.   :51.00   Max.   :1.000000  
>      sizeb2            sizec2         size2added        repstra2       
>  Min.   : 0.0000   Min.   : 0.000   Min.   : 0.000   Min.   :0.000000  
>  1st Qu.: 0.0000   1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.:0.000000  
>  Median : 0.0000   Median : 2.000   Median : 2.000   Median :0.000000  
>  Mean   : 0.8969   Mean   : 2.416   Mean   : 3.322   Mean   :0.009375  
>  3rd Qu.: 1.0000   3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.:0.000000  
>  Max.   :18.0000   Max.   :13.000   Max.   :24.000   Max.   :1.000000  
>     repstrb2           feca2          juvgiven2   obsstatus2    
>  Min.   : 0.0000   Min.   :0.0000   Min.   :0   Min.   :0.0000  
>  1st Qu.: 0.0000   1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0000  
>  Median : 0.0000   Median :0.0000   Median :0   Median :1.0000  
>  Mean   : 0.8969   Mean   :0.2906   Mean   :0   Mean   :0.9531  
>  3rd Qu.: 1.0000   3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000  
>  Max.   :18.0000   Max.   :7.0000   Max.   :0   Max.   :1.0000  
>    repstatus2       fecstatus2       matstatus2     alive2     stage2         
>  Min.   :0.0000   Min.   :0.0000   Min.   :1    Min.   :1   Length:320        
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1    1st Qu.:1   Class :character  
>  Median :0.0000   Median :0.0000   Median :1    Median :1   Mode  :character  
>  Mean   :0.3688   Mean   :0.1562   Mean   :1    Mean   :1                     
>  3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1                     
>  Max.   :1.0000   Max.   :1.0000   Max.   :1    Max.   :1                     
>   stage2index        sizea3             sizeb3           sizec3      
>  Min.   : 6.00   Min.   :0.000000   Min.   : 0.000   Min.   : 0.000  
>  1st Qu.: 7.00   1st Qu.:0.000000   1st Qu.: 0.000   1st Qu.: 1.000  
>  Median :10.00   Median :0.000000   Median : 0.000   Median : 1.000  
>  Mean   :18.17   Mean   :0.009375   Mean   : 1.069   Mean   : 2.209  
>  3rd Qu.:32.00   3rd Qu.:0.000000   3rd Qu.: 1.000   3rd Qu.: 3.000  
>  Max.   :54.00   Max.   :1.000000   Max.   :18.000   Max.   :13.000  
>    size3added        repstra3           repstrb3          feca3       
>  Min.   : 0.000   Min.   :0.000000   Min.   : 0.000   Min.   :0.0000  
>  1st Qu.: 1.000   1st Qu.:0.000000   1st Qu.: 0.000   1st Qu.:0.0000  
>  Median : 2.000   Median :0.000000   Median : 0.000   Median :0.0000  
>  Mean   : 3.288   Mean   :0.009375   Mean   : 1.069   Mean   :0.4562  
>  3rd Qu.: 4.000   3rd Qu.:0.000000   3rd Qu.: 1.000   3rd Qu.:0.0000  
>  Max.   :24.000   Max.   :1.000000   Max.   :18.000   Max.   :8.0000  
>    juvgiven3   obsstatus3    repstatus3    fecstatus3       matstatus3
>  Min.   :0   Min.   :0.0   Min.   :0.0   Min.   :0.0000   Min.   :1   
>  1st Qu.:0   1st Qu.:1.0   1st Qu.:0.0   1st Qu.:0.0000   1st Qu.:1   
>  Median :0   Median :1.0   Median :0.0   Median :0.0000   Median :1   
>  Mean   :0   Mean   :0.9   Mean   :0.4   Mean   :0.2219   Mean   :1   
>  3rd Qu.:0   3rd Qu.:1.0   3rd Qu.:1.0   3rd Qu.:0.0000   3rd Qu.:1   
>  Max.   :0   Max.   :1.0   Max.   :1.0   Max.   :1.0000   Max.   :1   
>      alive3          stage3           stage3index   
>  Min.   :0.0000   Length:320         Min.   : 0.00  
>  1st Qu.:1.0000   Class :character   1st Qu.: 7.00  
>  Median :1.0000   Mode  :character   Median :10.00  
>  Mean   :0.9469                      Mean   :18.57  
>  3rd Qu.:1.0000                      3rd Qu.:33.00  
>  Max.   :1.0000                      Max.   :54.00

One important consideration is the use of censor variables. Censoring a demographic dataset is typically accomplished by including a binary variable in the dataset denoting whether an individual datum is to be kept or excluded. The objects cypraw_v2 and cpyfb_v2 were both created without using censoring variables. However, because the datasets actually included censor variables (all data were set to be included, with no suspect data), we wished to incorporate those variables in the final datasets. Hence, although censor = FALSE in both the call to verticalize3() and the call to historicalize3(), we also noted censorcol = "censor" and censorkeep = 1 in the call to historicalize3(). Failing to add these options to the call to historicalize3() will produce approximately the same dataset, but with some zeros entering variables censor1, censor2, and censor3 in the historicalized dataset that do not exist in the first, verticalized dataset. This occurs because the vertical dataset that we standardized only includes entries for each individual actually observed at each time, while the horizontal dataset includes entries for all individuals at all times, regardless of whether they were observed. Thus, by setting these options, we have produced datasets that are exactly the same except for variable order. We can see hints of that by looking at the dimensions of our datasets, as below.

dim(cypraw_v1)
> [1] 320  54
dim(cypraw_v2)
> [1] 320  54
dim(cypfb_v1)
> [1] 320  54
dim(cypfb_v2)
> [1] 320  54

One final consideration in historicalize3() regards the use of the 3col sets of options. If users have vertical datasets with pairs of consecutive states, then setting the 3col options to the latter state in each row means that the final year will be included in the historicalized dataset. Failing to enter the 3col set in these cases would mean that the final monitoring occasion would be dropped, since it likely only appears in the latter monitoring occasion.

3.5 Handling spatial data and density

Both functions verticalize3() and historicalize3() handle the formatting of spatial coordinates and the estimation of density. There are four important settings that need to be used in the former case, and three in the latter. In both functions, the first two settings correspond to the columns coding for the X coordinate (xcol), and the Y coordinate (ycol). In both cases, the name of the variable or the column number can be used. The third setting (spacing), used in both functions, sets the radius from the coordinate of the individual to search for other individuals. The approach used for density estimation is to find and count all individuals in the same occasion within this radius from each individual, with density estimation performed for each individual in each time. The final setting, used only in verticalize3(), is a logical variable telling R whether the X and Y coordinate variables are single variables for the individual, or whether each individual has potentially new X and Y coordinates at each time that it is observed (coordsRepeat).

Here, we will produce a new version of the function-based cypdata hfv dataset with density at time t estimated using a 1m radius. Notice that the result includes xpos and ypos variables for times t+1, t, and t-1, and local density (density) at time t.

cypfb_vdens <- verticalize3(data = cypdata, noyears = 6, firstyear = 2004, 
  patchidcol = "patch", individcol = "plantid", blocksize = 4, 
  xcol = "X", ycol = "Y", sizeacol = "Inf2.04", sizebcol = "Inf.04",
  sizeccol = "Veg.04", repstracol = "Inf.04", repstrbcol = "Inf2.04",
  fecacol = "Pod.04", stageassign = cypframe_fb, stagesize = "sizeadded",
  NAas0 = TRUE, age_offset = 4, coordsRepeat = FALSE, spacing = 1)

summary(cypfb_vdens)
>      rowid       popid  patchid   individ              year2     
>  Min.   : 1.00   :320   A: 93   Length:320         Min.   :2004  
>  1st Qu.:21.00          B:154   Class :character   1st Qu.:2005  
>  Median :37.50          C: 73   Mode  :character   Median :2006  
>  Mean   :38.45                                     Mean   :2006  
>  3rd Qu.:56.00                                     3rd Qu.:2007  
>  Max.   :77.00                                     Max.   :2008  
>    firstseen       lastseen        obsage       obslifespan        xpos1       
>  Min.   :2004   Min.   :2004   Min.   :5.000   Min.   :0.000   Min.   :  0.00  
>  1st Qu.:2004   1st Qu.:2009   1st Qu.:6.000   1st Qu.:5.000   1st Qu.: 54.40  
>  Median :2004   Median :2009   Median :7.000   Median :5.000   Median : 60.80  
>  Mean   :2004   Mean   :2009   Mean   :6.853   Mean   :4.556   Mean   : 72.53  
>  3rd Qu.:2004   3rd Qu.:2009   3rd Qu.:8.000   3rd Qu.:5.000   3rd Qu.: 97.40  
>  Max.   :2008   Max.   :2009   Max.   :9.000   Max.   :5.000   Max.   :166.30  
>      ypos1            sizea1             sizeb1            sizec1    
>  Min.   :-28.00   Min.   :0.000000   Min.   : 0.0000   Min.   : 0.0  
>  1st Qu.:  0.00   1st Qu.:0.000000   1st Qu.: 0.0000   1st Qu.: 0.0  
>  Median : 70.90   Median :0.000000   Median : 0.0000   Median : 1.0  
>  Mean   : 44.93   Mean   :0.009375   Mean   : 0.7469   Mean   : 1.9  
>  3rd Qu.: 79.85   3rd Qu.:0.000000   3rd Qu.: 1.0000   3rd Qu.: 3.0  
>  Max.   :142.40   Max.   :1.000000   Max.   :18.0000   Max.   :13.0  
>    size1added        repstra1          repstrb1            feca1       
>  Min.   : 0.000   Min.   : 0.0000   Min.   :0.000000   Min.   :0.0000  
>  1st Qu.: 0.000   1st Qu.: 0.0000   1st Qu.:0.000000   1st Qu.:0.0000  
>  Median : 2.000   Median : 0.0000   Median :0.000000   Median :0.0000  
>  Mean   : 2.656   Mean   : 0.7469   Mean   :0.009375   Mean   :0.2656  
>  3rd Qu.: 4.000   3rd Qu.: 1.0000   3rd Qu.:0.000000   3rd Qu.:0.0000  
>  Max.   :21.000   Max.   :18.0000   Max.   :1.000000   Max.   :7.0000  
>    juvgiven1   obsstatus1       repstatus1       fecstatus1    
>  Min.   :0   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000  
>  Median :0   Median :1.0000   Median :0.0000   Median :0.0000  
>  Mean   :0   Mean   :0.7469   Mean   :0.2875   Mean   :0.1344  
>  3rd Qu.:0   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.0000  
>  Max.   :0   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
>    matstatus1         alive1          stage1           stage1index   
>  Min.   :0.0000   Min.   :0.0000   Length:320         Min.   : 0.00  
>  1st Qu.:1.0000   1st Qu.:1.0000   Class :character   1st Qu.: 6.00  
>  Median :1.0000   Median :1.0000   Mode  :character   Median : 8.00  
>  Mean   :0.7688   Mean   :0.7688                      Mean   :14.17  
>  3rd Qu.:1.0000   3rd Qu.:1.0000                      3rd Qu.:31.00  
>  Max.   :1.0000   Max.   :1.0000                      Max.   :51.00  
>      xpos2            ypos2            sizea2             sizeb2       
>  Min.   : 46.50   Min.   :-28.00   Min.   :0.000000   Min.   : 0.0000  
>  1st Qu.: 60.10   1st Qu.: 23.30   1st Qu.:0.000000   1st Qu.: 0.0000  
>  Median : 90.65   Median : 77.00   Median :0.000000   Median : 0.0000  
>  Mean   : 91.19   Mean   : 56.98   Mean   :0.009375   Mean   : 0.8969  
>  3rd Qu.:141.80   3rd Qu.: 80.40   3rd Qu.:0.000000   3rd Qu.: 1.0000  
>  Max.   :173.00   Max.   :142.40   Max.   :1.000000   Max.   :18.0000  
>      sizec2         size2added        repstra2          repstrb2       
>  Min.   : 0.000   Min.   : 0.000   Min.   : 0.0000   Min.   :0.000000  
>  1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.: 0.0000   1st Qu.:0.000000  
>  Median : 2.000   Median : 2.000   Median : 0.0000   Median :0.000000  
>  Mean   : 2.416   Mean   : 3.322   Mean   : 0.8969   Mean   :0.009375  
>  3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.: 1.0000   3rd Qu.:0.000000  
>  Max.   :13.000   Max.   :24.000   Max.   :18.0000   Max.   :1.000000  
>      feca2          juvgiven2   obsstatus2       repstatus2    
>  Min.   :0.0000   Min.   :0   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0000   1st Qu.:0.0000  
>  Median :0.0000   Median :0   Median :1.0000   Median :0.0000  
>  Mean   :0.2906   Mean   :0   Mean   :0.9531   Mean   :0.3688  
>  3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000   3rd Qu.:1.0000  
>  Max.   :7.0000   Max.   :0   Max.   :1.0000   Max.   :1.0000  
>    fecstatus2       matstatus2     alive2     stage2           stage2index   
>  Min.   :0.0000   Min.   :1    Min.   :1   Length:320         Min.   : 6.00  
>  1st Qu.:0.0000   1st Qu.:1    1st Qu.:1   Class :character   1st Qu.: 7.00  
>  Median :0.0000   Median :1    Median :1   Mode  :character   Median :10.00  
>  Mean   :0.1562   Mean   :1    Mean   :1                      Mean   :18.17  
>  3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1                      3rd Qu.:32.00  
>  Max.   :1.0000   Max.   :1    Max.   :1                      Max.   :54.00  
>      xpos3            ypos3            sizea3             sizeb3      
>  Min.   : 46.50   Min.   :-28.00   Min.   :0.000000   Min.   : 0.000  
>  1st Qu.: 60.10   1st Qu.: 23.30   1st Qu.:0.000000   1st Qu.: 0.000  
>  Median : 90.65   Median : 77.00   Median :0.000000   Median : 0.000  
>  Mean   : 91.19   Mean   : 56.98   Mean   :0.009375   Mean   : 1.069  
>  3rd Qu.:141.80   3rd Qu.: 80.40   3rd Qu.:0.000000   3rd Qu.: 1.000  
>  Max.   :173.00   Max.   :142.40   Max.   :1.000000   Max.   :18.000  
>      sizec3         size3added        repstra3         repstrb3       
>  Min.   : 0.000   Min.   : 0.000   Min.   : 0.000   Min.   :0.000000  
>  1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.: 0.000   1st Qu.:0.000000  
>  Median : 1.000   Median : 2.000   Median : 0.000   Median :0.000000  
>  Mean   : 2.209   Mean   : 3.288   Mean   : 1.069   Mean   :0.009375  
>  3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.: 1.000   3rd Qu.:0.000000  
>  Max.   :13.000   Max.   :24.000   Max.   :18.000   Max.   :1.000000  
>      feca3          juvgiven3   obsstatus3    repstatus3    fecstatus3    
>  Min.   :0.0000   Min.   :0   Min.   :0.0   Min.   :0.0   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0   1st Qu.:0.0   1st Qu.:0.0000  
>  Median :0.0000   Median :0   Median :1.0   Median :0.0   Median :0.0000  
>  Mean   :0.4562   Mean   :0   Mean   :0.9   Mean   :0.4   Mean   :0.2219  
>  3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0   3rd Qu.:1.0   3rd Qu.:0.0000  
>  Max.   :8.0000   Max.   :0   Max.   :1.0   Max.   :1.0   Max.   :1.0000  
>    matstatus3     alive3          stage3           stage3index   
>  Min.   :1    Min.   :0.0000   Length:320         Min.   : 0.00  
>  1st Qu.:1    1st Qu.:1.0000   Class :character   1st Qu.: 7.00  
>  Median :1    Median :1.0000   Mode  :character   Median :10.00  
>  Mean   :1    Mean   :0.9469                      Mean   :18.57  
>  3rd Qu.:1    3rd Qu.:1.0000                      3rd Qu.:33.00  
>  Max.   :1    Max.   :1.0000                      Max.   :54.00  
>     density      
>  Min.   : 0.000  
>  1st Qu.: 0.000  
>  Median : 1.000  
>  Mean   : 1.931  
>  3rd Qu.: 3.000  
>  Max.   :10.000

Next let’s try making the same dataset using the historicalize3() function applied on cypvert. The options to add here are the same as in verticalize3(), except for coordsRepeat (the latter is only available for horizontally formatted dataset inputs). Note that the summaries look essentially the same for both standardized versions of the dataset.

cypfb_hdens <- historicalize3(data = cypvert, patchidcol = "patch",
  individcol = "plantid", xcol = "X", ycol = "Y", year2col = "year2",
  sizea2col = "Inf2.2", sizea3col = "Inf2.3", sizeb2col = "Inf.2",
  sizeb3col = "Inf.3", sizec2col = "Veg.2", sizec3col = "Veg.3",
  repstra2col = "Inf2.2", repstra3col = "Inf2.3", repstrb2col = "Inf.2",
  repstrb3col = "Inf.3", feca2col = "Pod.2", feca3col = "Pod.3", repstrrel = 2,
  stageassign = cypframe_fb, stagesize = "sizeadded", censorcol = "censor",
  censorkeep = 1, censor = FALSE, NAas0 = TRUE, age_offset = 4, spacing = 1,
  reduce = TRUE)

summary(cypfb_hdens)
>      rowid           popid             patchid            individ         
>  Min.   :  0.00   Length:320         Length:320         Length:320        
>  1st Qu.: 79.75   Class :character   Class :character   Class :character  
>  Median :159.50   Mode  :character   Mode  :character   Mode  :character  
>  Mean   :159.70                                                           
>  3rd Qu.:239.25                                                           
>  Max.   :321.00                                                           
>      year2        firstseen       lastseen        obsage       obslifespan   
>  Min.   :2004   Min.   :2004   Min.   :2004   Min.   :5.000   Min.   :0.000  
>  1st Qu.:2005   1st Qu.:2004   1st Qu.:2009   1st Qu.:6.000   1st Qu.:5.000  
>  Median :2006   Median :2004   Median :2009   Median :7.000   Median :5.000  
>  Mean   :2006   Mean   :2004   Mean   :2009   Mean   :6.853   Mean   :4.556  
>  3rd Qu.:2007   3rd Qu.:2004   3rd Qu.:2009   3rd Qu.:8.000   3rd Qu.:5.000  
>  Max.   :2008   Max.   :2008   Max.   :2009   Max.   :9.000   Max.   :5.000  
>      xpos1            ypos1            sizea1             sizeb1       
>  Min.   : 46.50   Min.   :-28.00   Min.   :0.000000   Min.   : 0.0000  
>  1st Qu.: 60.10   1st Qu.: 23.30   1st Qu.:0.000000   1st Qu.: 0.0000  
>  Median : 90.65   Median : 77.00   Median :0.000000   Median : 0.0000  
>  Mean   : 91.19   Mean   : 56.98   Mean   :0.009375   Mean   : 0.7469  
>  3rd Qu.:141.80   3rd Qu.: 80.40   3rd Qu.:0.000000   3rd Qu.: 1.0000  
>  Max.   :173.00   Max.   :142.40   Max.   :1.000000   Max.   :18.0000  
>      sizec1       size1added        repstra1           repstrb1      
>  Min.   : 0.0   Min.   : 0.000   Min.   :0.000000   Min.   : 0.0000  
>  1st Qu.: 0.0   1st Qu.: 0.000   1st Qu.:0.000000   1st Qu.: 0.0000  
>  Median : 1.0   Median : 2.000   Median :0.000000   Median : 0.0000  
>  Mean   : 1.9   Mean   : 2.656   Mean   :0.009375   Mean   : 0.7469  
>  3rd Qu.: 3.0   3rd Qu.: 4.000   3rd Qu.:0.000000   3rd Qu.: 1.0000  
>  Max.   :13.0   Max.   :21.000   Max.   :1.000000   Max.   :18.0000  
>      feca1          juvgiven1   obsstatus1       repstatus1    
>  Min.   :0.0000   Min.   :0   Min.   :0.0000   Min.   :0.0000  
>  1st Qu.:0.0000   1st Qu.:0   1st Qu.:0.0000   1st Qu.:0.0000  
>  Median :0.0000   Median :0   Median :1.0000   Median :0.0000  
>  Mean   :0.2656   Mean   :0   Mean   :0.7469   Mean   :0.2875  
>  3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000   3rd Qu.:1.0000  
>  Max.   :7.0000   Max.   :0   Max.   :1.0000   Max.   :1.0000  
>    fecstatus1       matstatus1         alive1          stage1         
>  Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Length:320        
>  1st Qu.:0.0000   1st Qu.:1.0000   1st Qu.:1.0000   Class :character  
>  Median :0.0000   Median :1.0000   Median :1.0000   Mode  :character  
>  Mean   :0.1344   Mean   :0.7688   Mean   :0.7688                     
>  3rd Qu.:0.0000   3rd Qu.:1.0000   3rd Qu.:1.0000                     
>  Max.   :1.0000   Max.   :1.0000   Max.   :1.0000                     
>   stage1index        xpos2            ypos2            sizea2        
>  Min.   : 0.00   Min.   : 46.50   Min.   :-28.00   Min.   :0.000000  
>  1st Qu.: 6.00   1st Qu.: 60.10   1st Qu.: 23.30   1st Qu.:0.000000  
>  Median : 8.00   Median : 90.65   Median : 77.00   Median :0.000000  
>  Mean   :14.17   Mean   : 91.19   Mean   : 56.98   Mean   :0.009375  
>  3rd Qu.:31.00   3rd Qu.:141.80   3rd Qu.: 80.40   3rd Qu.:0.000000  
>  Max.   :51.00   Max.   :173.00   Max.   :142.40   Max.   :1.000000  
>      sizeb2            sizec2         size2added        repstra2       
>  Min.   : 0.0000   Min.   : 0.000   Min.   : 0.000   Min.   :0.000000  
>  1st Qu.: 0.0000   1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.:0.000000  
>  Median : 0.0000   Median : 2.000   Median : 2.000   Median :0.000000  
>  Mean   : 0.8969   Mean   : 2.416   Mean   : 3.322   Mean   :0.009375  
>  3rd Qu.: 1.0000   3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.:0.000000  
>  Max.   :18.0000   Max.   :13.000   Max.   :24.000   Max.   :1.000000  
>     repstrb2           feca2          juvgiven2   obsstatus2    
>  Min.   : 0.0000   Min.   :0.0000   Min.   :0   Min.   :0.0000  
>  1st Qu.: 0.0000   1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0000  
>  Median : 0.0000   Median :0.0000   Median :0   Median :1.0000  
>  Mean   : 0.8969   Mean   :0.2906   Mean   :0   Mean   :0.9531  
>  3rd Qu.: 1.0000   3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0000  
>  Max.   :18.0000   Max.   :7.0000   Max.   :0   Max.   :1.0000  
>    repstatus2       fecstatus2       matstatus2     alive2     stage2         
>  Min.   :0.0000   Min.   :0.0000   Min.   :1    Min.   :1   Length:320        
>  1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:1    1st Qu.:1   Class :character  
>  Median :0.0000   Median :0.0000   Median :1    Median :1   Mode  :character  
>  Mean   :0.3688   Mean   :0.1562   Mean   :1    Mean   :1                     
>  3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1                     
>  Max.   :1.0000   Max.   :1.0000   Max.   :1    Max.   :1                     
>   stage2index        xpos3            ypos3            sizea3        
>  Min.   : 6.00   Min.   : 46.50   Min.   :-28.00   Min.   :0.000000  
>  1st Qu.: 7.00   1st Qu.: 60.10   1st Qu.: 23.30   1st Qu.:0.000000  
>  Median :10.00   Median : 90.65   Median : 77.00   Median :0.000000  
>  Mean   :18.17   Mean   : 91.19   Mean   : 56.98   Mean   :0.009375  
>  3rd Qu.:32.00   3rd Qu.:141.80   3rd Qu.: 80.40   3rd Qu.:0.000000  
>  Max.   :54.00   Max.   :173.00   Max.   :142.40   Max.   :1.000000  
>      sizeb3           sizec3         size3added        repstra3       
>  Min.   : 0.000   Min.   : 0.000   Min.   : 0.000   Min.   :0.000000  
>  1st Qu.: 0.000   1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.:0.000000  
>  Median : 0.000   Median : 1.000   Median : 2.000   Median :0.000000  
>  Mean   : 1.069   Mean   : 2.209   Mean   : 3.288   Mean   :0.009375  
>  3rd Qu.: 1.000   3rd Qu.: 3.000   3rd Qu.: 4.000   3rd Qu.:0.000000  
>  Max.   :18.000   Max.   :13.000   Max.   :24.000   Max.   :1.000000  
>     repstrb3          feca3          juvgiven3   obsstatus3    repstatus3 
>  Min.   : 0.000   Min.   :0.0000   Min.   :0   Min.   :0.0   Min.   :0.0  
>  1st Qu.: 0.000   1st Qu.:0.0000   1st Qu.:0   1st Qu.:1.0   1st Qu.:0.0  
>  Median : 0.000   Median :0.0000   Median :0   Median :1.0   Median :0.0  
>  Mean   : 1.069   Mean   :0.4562   Mean   :0   Mean   :0.9   Mean   :0.4  
>  3rd Qu.: 1.000   3rd Qu.:0.0000   3rd Qu.:0   3rd Qu.:1.0   3rd Qu.:1.0  
>  Max.   :18.000   Max.   :8.0000   Max.   :0   Max.   :1.0   Max.   :1.0  
>    fecstatus3       matstatus3     alive3          stage3         
>  Min.   :0.0000   Min.   :1    Min.   :0.0000   Length:320        
>  1st Qu.:0.0000   1st Qu.:1    1st Qu.:1.0000   Class :character  
>  Median :0.0000   Median :1    Median :1.0000   Mode  :character  
>  Mean   :0.2219   Mean   :1    Mean   :0.9469                     
>  3rd Qu.:0.0000   3rd Qu.:1    3rd Qu.:1.0000                     
>  Max.   :1.0000   Max.   :1    Max.   :1.0000                     
>   stage3index       density      
>  Min.   : 0.00   Min.   : 0.000  
>  1st Qu.: 7.00   1st Qu.: 0.000  
>  Median :10.00   Median : 1.000  
>  Mean   :18.57   Mean   : 1.931  
>  3rd Qu.:33.00   3rd Qu.: 3.000  
>  Max.   :54.00   Max.   :10.000

Let’s now move on to supplying R with the proxy transitions that we need to properly parameterize our models.

3.6 Formatting supplemental data needed for matrix estimation

MPMs are often estimated only partially from available demographic datasets. Some transitions are parameterized using information gathered from other studies, whether through direct input in the matrix or through the development of kernels contingent on external information. Other transitions might also be estimated via proxy transitions elsewhere in the matrix. In lefko3, this information can be provided in one of two ways. The preferred and most recently developed method is the supplement table, which can be developed using the supplemental() function. This function allows users to create a data frame detailing:

  1. specific transitions to set as constants
  2. specific transitions to estimate via proxy transitions, which can also be multiplied by fixed values
  3. specific multipliers for fecundity in cases in which fecundity estimates resulting from linear modeling must be modified to characterize the full transition.

Examples might illustrate where this approach is useful. If I lack my own data on subterranean juvenile stages in a plant species, but I have estimates of survival for those stages form another study, then I might use those estimates as constants in the MPM. Further, if I lack demographic data on the development of germinated seeds to the seedling or earliest adult stage, but I have reason to believe that the survival probabilities should be similar to the survival within an observed stage of seedlings or small adults, then I can use the latter survival-transitions as proxies. Finally, if fecundity is a function of seed production, survival to the next year, and germination probability, then germination probability might be estimated via a separate field germination study. I might wish to incorporate this germination probability both as a constant transition, and as a multiplier on estimated fecundity. Supplement tables provide a means to include all of this information.

Function supplemental() was developed to provide a robust, general solution to the addition of these data to MPMs. To use this function, first identify each transition that needs to be altered, and split each transition into stage in times t+1, t, and, if conducting a historical analysis, t-1. These stages must then be entered in the same order across the stage3, stage2, and stage1 fields. For example, if I wished to alter the historical transitions from stage A to B to C, and from A to A to C, then I would enter these two transitions as

stage3 = c("C", "C"), stage2 = c("B", "A"), stage1 = c("A", "A")

If I were interested in ahistorical transitions, then I would either set all stage1 values to NA, such as stage1 = c(NA, NA), or simply not include stage1 in the input (the default is a vector of NA elements). If I wished to replace my two transitions with proxy transitions that lefko3 will estimate, then I can designate those proxy transitions using the eststage fields. For example:

eststage3 = c("F", "F"), eststage2 = c("E", "D"), eststage1 = c("D", "D")

The above would replace my original transitions with the values estimated for transitions D-E-F and D-D-F, respectively. Alternatively, if I wished to set these two transitions to fixed constants, then I could designate those with givenrate. For example, givenrate = c(0.15, 0.25) would set these two transitions to 0.15 and 0.25, respectively. Estimated fecundity, as well as proxy values, can be modified by a multiplier using the multiplier field, and it is important to identify the kind of transition to modify as a survival transition or a fecundity rate using the type field (use type12 also to designate the kind of transition occurs between times t-1 and t in the historical case). Fecundity multipliers should be identified separately, since they are not proxy values. The function requires the input of the stageframe used to generate the stages.

We will start off by creating two supplement tables taking all of these sorts of data for the function-based MPMs. The first is the supplement table for the historical analysis, and the second table covers the ahistorical analysis. Each row refers to a specific transition, and in the historical case, there are codes for 23 given transitions (12 for the ahistorical case). The first nine of the historical transitions are set to specific probabilities (six in the ahistorical case), and the next 12 are transitions that will be set to other, estimated transitions (four in the ahistorical case; these are the non-NA transitions in eststage set below) multiplied by specific constants (either 0.7 or 1.0). The final two terms are fecundity multipliers. Based on the literature, the proxies for entry into the adult classes are transitions from dormancy, as below. However, in the raw dataset, dormancy is not common enough to use as an effective proxy in raw matrix creation. Hence, we can use different proxies for function-based matrix estimation than for raw matrix estimation. Where necessary, we also use rep and mat as shorthand to code for all reproductive stages and all mature stages, respectively.

Here is the historical supplement table. We will also introduce a variable representing the number of seeds expected per fruit. Note that the number of seeds per fruit is actually likely higher than this, but we are using this number to reflect the relatively stable population dynamics that we see in the population.

seeds_per_fruit <- 5000
sl_mult <- 0.7

cypsupp3_fb <- supplemental(stage3 = c("SD", "SD", "P1", "P1", "P2", "P3", "SL",
    "SL", "SL", "D", "V1", "V2", "V3", "D", "V1", "V2", "V3", "mat", "mat",
    "mat", "mat", "SD", "P1"), 
  stage2 = c("SD", "SD", "SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "SL", 
    "SL", "SL", "SL", "SL", "SL", "SL", "D", "V1", "V2", "V3", "rep", "rep"), 
  stage1 = c("SD", "rep", "SD", "rep", "SD", "P1", "P2", "P3", "SL", "P3", "P3",
    "P3", "P3", "SL", "SL", "SL", "SL", "SL", "SL", "SL", "SL", "mat", "mat"), 
  eststage3 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "V1", "V2", "V3", "D",
    "V1", "V2", "V3", "mat", "mat", "mat", "mat", NA, NA), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "D", "D", "D", "D", 
    "D", "D", "D", "D", "V1", "V2", "V3", NA, NA), 
  eststage1 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "D", "D", "D", "D", 
    "D", "D", "D", "V1", "V1", "V1", "V1", NA, NA), 
  givenrate = c(0.08, 0.08, 0.1, 0.1, 0.1, 0.1, 0.1, 0.05, 0.05, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
  multiplier = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, sl_mult, sl_mult,
    sl_mult, sl_mult, sl_mult, sl_mult, sl_mult, sl_mult, 1, 1, 1, 1,
    0.5 * seeds_per_fruit, 0.5 * seeds_per_fruit),
  type = c("S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S",
    "S", "S", "S", "S", "S", "S", "S", "R", "R"), 
  type_t12 = c("S", "F", "S", "F", "S", "S", "S", "S", "S", "S", "S", "S", "S",
    "S", "S", "S", "S", "S", "S", "S", "S", "S", "S"),
  stageframe = cypframe_fb, historical = TRUE)

cypsupp3_fb
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate multiplier
> 1      SD     SD     SD      <NA>      <NA>      <NA>      0.08        1.0
> 2      SD     SD    rep      <NA>      <NA>      <NA>      0.08        1.0
> 3      P1     SD     SD      <NA>      <NA>      <NA>      0.10        1.0
> 4      P1     SD    rep      <NA>      <NA>      <NA>      0.10        1.0
> 5      P2     P1     SD      <NA>      <NA>      <NA>      0.10        1.0
> 6      P3     P2     P1      <NA>      <NA>      <NA>      0.10        1.0
> 7      SL     P3     P2      <NA>      <NA>      <NA>      0.10        1.0
> 8      SL     SL     P3      <NA>      <NA>      <NA>      0.05        1.0
> 9      SL     SL     SL      <NA>      <NA>      <NA>      0.05        1.0
> 10      D     SL     P3         D         D         D        NA        0.7
> 11     V1     SL     P3        V1         D         D        NA        0.7
> 12     V2     SL     P3        V2         D         D        NA        0.7
> 13     V3     SL     P3        V3         D         D        NA        0.7
> 14      D     SL     SL         D         D         D        NA        0.7
> 15     V1     SL     SL        V1         D         D        NA        0.7
> 16     V2     SL     SL        V2         D         D        NA        0.7
> 17     V3     SL     SL        V3         D         D        NA        0.7
> 18    mat      D     SL       mat         D        V1        NA        1.0
> 19    mat     V1     SL       mat        V1        V1        NA        1.0
> 20    mat     V2     SL       mat        V2        V1        NA        1.0
> 21    mat     V3     SL       mat        V3        V1        NA        1.0
> 22     SD    rep    mat      <NA>      <NA>      <NA>        NA     2500.0
> 23     P1    rep    mat      <NA>      <NA>      <NA>        NA     2500.0
>    convtype convtype_t12
> 1         1            1
> 2         1            2
> 3         1            1
> 4         1            2
> 5         1            1
> 6         1            1
> 7         1            1
> 8         1            1
> 9         1            1
> 10        1            1
> 11        1            1
> 12        1            1
> 13        1            1
> 14        1            1
> 15        1            1
> 16        1            1
> 17        1            1
> 18        1            1
> 19        1            1
> 20        1            1
> 21        1            1
> 22        3            1
> 23        3            1

Now we can input the ahistorical supplement table.

cypsupp2_fb <- supplemental(stage3 = c("SD", "P1", "P2", "P3", "SL", "SL", "D",
    "V1", "V2", "V3", "SD", "P1"), 
  stage2 = c("SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "SL", "SL", "rep",
    "rep"), 
  eststage3 = c(NA, NA, NA, NA, NA, NA, "D", "V1", "V2", "V3", NA, NA), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, "D", "D", "D", "D", NA, NA), 
  givenrate = c(0.08, 0.1, 0.1, 0.1, 0.05, 0.05, NA, NA, NA, NA, NA, NA), 
  multiplier = c(NA, NA, NA, NA, NA, NA, sl_mult, sl_mult, sl_mult, sl_mult,
    0.5 * seeds_per_fruit, 0.5 * seeds_per_fruit),
  type = c("S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "R", "R"),
  stageframe = cypframe_fb, historical = FALSE)

cypsupp2_fb
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate multiplier
> 1      SD     SD   <NA>      <NA>      <NA>      <NA>      0.08        1.0
> 2      P1     SD   <NA>      <NA>      <NA>      <NA>      0.10        1.0
> 3      P2     P1   <NA>      <NA>      <NA>      <NA>      0.10        1.0
> 4      P3     P2   <NA>      <NA>      <NA>      <NA>      0.10        1.0
> 5      SL     P3   <NA>      <NA>      <NA>      <NA>      0.05        1.0
> 6      SL     SL   <NA>      <NA>      <NA>      <NA>      0.05        1.0
> 7       D     SL   <NA>         D         D      <NA>        NA        0.7
> 8      V1     SL   <NA>        V1         D      <NA>        NA        0.7
> 9      V2     SL   <NA>        V2         D      <NA>        NA        0.7
> 10     V3     SL   <NA>        V3         D      <NA>        NA        0.7
> 11     SD    rep   <NA>      <NA>      <NA>      <NA>        NA     2500.0
> 12     P1    rep   <NA>      <NA>      <NA>      <NA>        NA     2500.0
>    convtype convtype_t12
> 1         1            1
> 2         1            1
> 3         1            1
> 4         1            1
> 5         1            1
> 6         1            1
> 7         1            1
> 8         1            1
> 9         1            1
> 10        1            1
> 11        3            1
> 12        3            1

These supplement tables provide the best means of adding external data to our MPMs because they allow both specific transitions to be isolated, and because they allow the use of shorthand to identify large groups of transitions (e.g. using mat, rep, immat, prop, npr, obs, nobs, or all to signify all mature stages, reproductive stages, immature stages, propagule stages, non-propagule stages, observable stages, unobservable stages, or simply all stages, respectively). Let’s now also supply the supplement tables for the raw MPMs.

cypsupp3_raw <- supplemental(stage3 = c("SD", "SD", "P1", "P1", "P2", "P2",
    "P3", "SL", "SL", "SL", "D", "XSm", "Sm", "D", "XSm", "Sm", "mat", "mat",
    "mat", "SD", "P1"),
  stage2 = c("SD", "SD", "SD", "SD", "P1", "P1", "P2", "P3", "SL", "SL", "SL",
    "SL", "SL", "SL", "SL", "SL", "D", "XSm", "Sm", "rep", "rep"),
  stage1 = c("SD", "rep", "SD", "rep", "SD", "rep", "P1", "P2", "P3", "SL",
    "SL", "SL", "SL", "P3", "P3", "P3", "SL", "SL", "SL", "mat", "mat"),
  eststage3 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "XSm", "Sm", "D",
    "XSm", "Sm", "mat", "mat", "mat", NA, NA), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "XSm", "XSm", "XSm",
    "XSm", "XSm", "XSm", "D", "XSm", "Sm", NA, NA),
  eststage1 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "XSm", "XSm", "XSm",
    "XSm", "XSm", "XSm", "XSm", "XSm", "XSm", NA, NA),
  givenrate = c(0.08, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.05, 0.05, 0.05, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
  multiplier = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, sl_mult, sl_mult,
    sl_mult, sl_mult, sl_mult, sl_mult, 1, 1, 1, 0.5 * seeds_per_fruit,
    0.5 * seeds_per_fruit),
  type =c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3),
  stageframe = cypframe_raw, historical = TRUE)

cypsupp3_raw
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate multiplier
> 1      SD     SD     SD      <NA>      <NA>      <NA>      0.08        1.0
> 2      SD     SD    rep      <NA>      <NA>      <NA>      0.10        1.0
> 3      P1     SD     SD      <NA>      <NA>      <NA>      0.10        1.0
> 4      P1     SD    rep      <NA>      <NA>      <NA>      0.10        1.0
> 5      P2     P1     SD      <NA>      <NA>      <NA>      0.10        1.0
> 6      P2     P1    rep      <NA>      <NA>      <NA>      0.10        1.0
> 7      P3     P2     P1      <NA>      <NA>      <NA>      0.10        1.0
> 8      SL     P3     P2      <NA>      <NA>      <NA>      0.05        1.0
> 9      SL     SL     P3      <NA>      <NA>      <NA>      0.05        1.0
> 10     SL     SL     SL      <NA>      <NA>      <NA>      0.05        1.0
> 11      D     SL     SL         D       XSm       XSm        NA        0.7
> 12    XSm     SL     SL       XSm       XSm       XSm        NA        0.7
> 13     Sm     SL     SL        Sm       XSm       XSm        NA        0.7
> 14      D     SL     P3         D       XSm       XSm        NA        0.7
> 15    XSm     SL     P3       XSm       XSm       XSm        NA        0.7
> 16     Sm     SL     P3        Sm       XSm       XSm        NA        0.7
> 17    mat      D     SL       mat         D       XSm        NA        1.0
> 18    mat    XSm     SL       mat       XSm       XSm        NA        1.0
> 19    mat     Sm     SL       mat        Sm       XSm        NA        1.0
> 20     SD    rep    mat      <NA>      <NA>      <NA>        NA     2500.0
> 21     P1    rep    mat      <NA>      <NA>      <NA>        NA     2500.0
>    convtype convtype_t12
> 1         1            1
> 2         1            1
> 3         1            1
> 4         1            1
> 5         1            1
> 6         1            1
> 7         1            1
> 8         1            1
> 9         1            1
> 10        1            1
> 11        1            1
> 12        1            1
> 13        1            1
> 14        1            1
> 15        1            1
> 16        1            1
> 17        1            1
> 18        1            1
> 19        1            1
> 20        3            1
> 21        3            1

cypsupp2_raw <- supplemental(stage3 = c("SD", "P1", "P2", "P3", "SL", "SL", "D",
    "XSm", "Sm", "SD", "P1"),
  stage2 = c("SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "SL", "rep","rep"), 
  eststage3 = c(NA, NA, NA, NA, NA, NA, "D", "XSm", "Sm", NA, NA), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, "XSm", "XSm", "XSm", NA, NA), 
  givenrate = c(0.08, 0.10, 0.10, 0.10, 0.05, 0.05, NA, NA, NA, NA, NA),
  multiplier = c(NA, NA, NA, NA, NA, NA, sl_mult, sl_mult, sl_mult,
    0.5 * seeds_per_fruit, 0.5 * seeds_per_fruit),
  type =c(1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3),
  stageframe = cypframe_raw, historical = FALSE)

cypsupp2_raw
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate multiplier
> 1      SD     SD   <NA>      <NA>      <NA>      <NA>      0.08        1.0
> 2      P1     SD   <NA>      <NA>      <NA>      <NA>      0.10        1.0
> 3      P2     P1   <NA>      <NA>      <NA>      <NA>      0.10        1.0
> 4      P3     P2   <NA>      <NA>      <NA>      <NA>      0.10        1.0
> 5      SL     P3   <NA>      <NA>      <NA>      <NA>      0.05        1.0
> 6      SL     SL   <NA>      <NA>      <NA>      <NA>      0.05        1.0
> 7       D     SL   <NA>         D       XSm      <NA>        NA        0.7
> 8     XSm     SL   <NA>       XSm       XSm      <NA>        NA        0.7
> 9      Sm     SL   <NA>        Sm       XSm      <NA>        NA        0.7
> 10     SD    rep   <NA>      <NA>      <NA>      <NA>        NA     2500.0
> 11     P1    rep   <NA>      <NA>      <NA>      <NA>        NA     2500.0
>    convtype convtype_t12
> 1         1            1
> 2         1            1
> 3         1            1
> 4         1            1
> 5         1            1
> 6         1            1
> 7         1            1
> 8         1            1
> 9         1            1
> 10        3            1
> 11        3            1

3.6.1 Historical transitions and supplement tables

The supplement tables above have different dimensions depending both on the life history model used, and on whether the MPM is to be historical or not. A full introduction to historical MPMs is provided in the next chapter, but here we will illustrate why there is such a difference in dimension and why users should be careful in creating these tables.

A standard MPM includes information on the rates and probabilities associated with transitions from the different life history stages at one time to the next. We generally say that such an MPM shows the probability of transition from one stage at the current time to the next, or the expected rate of offspring production from the current time to the next. Because conceptually such a matrix shows the expected rates and probabilities moving forward from the current time, the standard MPM is not considered to have any individual history. As such, we may refer to these MPMs as ahistorical.

A historical MPM includes information on the rates and probabilities associated with the transition from the current time and one time step back, to the next time forward. Such a MPM includes one extra time step of information from the individual’s history. For example, in a historical model, the probability of transition from an extra small adult to a small adult will differ depending on what stage the individual was in immediately before being extra small. So, the probability of transition from extra small at time t to small in time t+1 will differ between those individuals that were extra small in time t-1 and those individuals that were small in time t-1. In an ahistorical model, these transition probabilities would all have the exact same value.

Supplement tables for historical MPMs and IPMs need to be written to include all three-time transitions that cannot be estimated from the dataset. Because a single ahistorical transition represents a transition that does no depend on stage in time t-1, this means that a single ahistorical transition is broken down into potentially many historical transitions. The result is that supplement tables for historical MPMs are bigger than those for ahistorical MPMs. Failing to account for any relevant historical transition that is not represented in a dataset forces its value to zero, meaning that failing to account for all relevant transitions in a supplement table will cause a break in the life history that will yield a set of matrices leading to low population growth and often complete insensitivity to alterations in fecundity and other vital rates.

For example, in the raw historical supplement table above, the final two transitions noted are the fecundity transitions. The last of these is mat -> rep -> P1, and is shorthand showing that we are setting the transition from all mature stages in time t-1 and all reproductive stages in time t to the 1st year protocorm stage in time t+1. Since we do not have actual individual demographic data for juvenile stages in our dataset, we also need to specify the next transition, which is the survival transition set rep -> P1 -> P2. Note that here, the transition between times t-1 and t is actually a fecundity step, and so refers to the production of offspring by the mother, while the transition from time t to time t+1 is a survival probability for the offspring itself. In deVries format, we would instead use AlmostBorn -> P1 -> P2, since deVries format does not allow mixing fecundity and survival transitions together in historical transitions unless they refer to the same individual (more on this issue in the next chapter). We need still more transitions here, including at least the following to connect offspring stages to the adult portions of the life history:

\(P1 \rightarrow P2 \rightarrow P3\)

\(P2 \rightarrow P3 \rightarrow SL\)

\(P3 \rightarrow SL \rightarrow D\)

\(P3 \rightarrow SL \rightarrow XSm\)

\(P3 \rightarrow SL \rightarrow Sm\)

\(SL \rightarrow D \rightarrow mat\)

\(SL \rightarrow XSm \rightarrow mat\)

\(SL \rightarrow Sm \rightarrow mat\)

Let’s consider another example. In figure 3.3 below, we show the portion of the life history most closely tied to fecundity. The "rep" argument refers to reproductive stages, and the "mat" argument refers to mature stages. The "rep" to "DS" ahistorical transition, then, refers to 24 different transitions in the function-based stageframe, because there are 24 reproductive (i.e. flowering) stages. Counting up the ahistorical transitions, then, we find that we have 24 + 24 + 1 + 1 + 1 = 51 ahistorical transitions shown. In the historical case, the "mat" to "rep" to "DS" transition set refers to \(24 \times 49 = 1176\) transitions. So, counting everything up, we actually see 1176 + 1176 + 24 + 24 + 1 + 1 = 2402 transitions here. Missing even a single one of these impacts projected population dynamics.

Figure 3.3: The fecundity transition and directly related survival transitions in both ahistorical and historical format

The most important thing to consider in building a supplement table, then, is that all stages must be connected to all other stages as diagrammed in the original life history model. If a single transition noted in the above paragraph is missed, then at least one stage is not properly connected to the other stages in the model, and there is a probability of zero associated with a particular transition that should have a non-zero value. In that circumstance, users will find that their MPM or IPM likely predicts a declining growth rate, and nothing that they do will be able to change it (typically, the asymptotic growth rate will not just decline, but be completely insensitive to changes in survival or fecundity transitions).

3.6.2 An older alternative to the supplement table

Supplement tables provide all of the information that we need. However, there is an alternative means of supplying this information, and that is through the creation of a reproductive matrix and an overwrite table. The reproductive matrix is an ahistorical matrix detailing where fecundity rates are set, and at what level. Cypripedium candidum produces seeds that germinate by the following growing season (stage P1, or a first year protocorm), or that remain dormant for the next year (stage SD). In the following matrix, we detail that the fecundity of each reproductive stage needs to be split into two between each of these output stages. The actual split places 50% of the fecundity of a reproductive stage into each category of recruit, where the full fecundity is estimated by linear models that we will create. This reproductive matrix can be used in historical MPM construction, and it is assumed that stage at occasion t-1 is set to all.

rep.assumptions_fb <- matrix(0, 54, 54)
rep.assumptions_fb[1:2,31:54] <- 0.5 * seeds_per_fruit
rep.assumptions_fb
>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
>  [1,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [2,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [3,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [4,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [5,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [6,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [7,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [8,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>  [9,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [10,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [11,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [12,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [13,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [14,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [15,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [16,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [17,]    0    0    0    0    0    0    0    0    0     0     0     0     0
> [18,]    0    0    0    0    0    0    0    0    0     0     0     0     0
>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
>  [1,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [2,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [3,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [4,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [5,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [6,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [7,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [8,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [9,]     0     0     0     0     0     0     0     0     0     0     0     0
> [10,]     0     0     0     0     0     0     0     0     0     0     0     0
> [11,]     0     0     0     0     0     0     0     0     0     0     0     0
> [12,]     0     0     0     0     0     0     0     0     0     0     0     0
> [13,]     0     0     0     0     0     0     0     0     0     0     0     0
> [14,]     0     0     0     0     0     0     0     0     0     0     0     0
> [15,]     0     0     0     0     0     0     0     0     0     0     0     0
> [16,]     0     0     0     0     0     0     0     0     0     0     0     0
> [17,]     0     0     0     0     0     0     0     0     0     0     0     0
> [18,]     0     0     0     0     0     0     0     0     0     0     0     0
>       [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
>  [1,]     0     0     0     0     0  2500  2500  2500  2500  2500  2500  2500
>  [2,]     0     0     0     0     0  2500  2500  2500  2500  2500  2500  2500
>  [3,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [4,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [5,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [6,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [7,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [8,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [9,]     0     0     0     0     0     0     0     0     0     0     0     0
> [10,]     0     0     0     0     0     0     0     0     0     0     0     0
> [11,]     0     0     0     0     0     0     0     0     0     0     0     0
> [12,]     0     0     0     0     0     0     0     0     0     0     0     0
> [13,]     0     0     0     0     0     0     0     0     0     0     0     0
> [14,]     0     0     0     0     0     0     0     0     0     0     0     0
> [15,]     0     0     0     0     0     0     0     0     0     0     0     0
> [16,]     0     0     0     0     0     0     0     0     0     0     0     0
> [17,]     0     0     0     0     0     0     0     0     0     0     0     0
> [18,]     0     0     0     0     0     0     0     0     0     0     0     0
>       [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
>  [1,]  2500  2500  2500  2500  2500  2500  2500  2500  2500  2500  2500  2500
>  [2,]  2500  2500  2500  2500  2500  2500  2500  2500  2500  2500  2500  2500
>  [3,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [4,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [5,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [6,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [7,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [8,]     0     0     0     0     0     0     0     0     0     0     0     0
>  [9,]     0     0     0     0     0     0     0     0     0     0     0     0
> [10,]     0     0     0     0     0     0     0     0     0     0     0     0
> [11,]     0     0     0     0     0     0     0     0     0     0     0     0
> [12,]     0     0     0     0     0     0     0     0     0     0     0     0
> [13,]     0     0     0     0     0     0     0     0     0     0     0     0
> [14,]     0     0     0     0     0     0     0     0     0     0     0     0
> [15,]     0     0     0     0     0     0     0     0     0     0     0     0
> [16,]     0     0     0     0     0     0     0     0     0     0     0     0
> [17,]     0     0     0     0     0     0     0     0     0     0     0     0
> [18,]     0     0     0     0     0     0     0     0     0     0     0     0
>       [,50] [,51] [,52] [,53] [,54]
>  [1,]  2500  2500  2500  2500  2500
>  [2,]  2500  2500  2500  2500  2500
>  [3,]     0     0     0     0     0
>  [4,]     0     0     0     0     0
>  [5,]     0     0     0     0     0
>  [6,]     0     0     0     0     0
>  [7,]     0     0     0     0     0
>  [8,]     0     0     0     0     0
>  [9,]     0     0     0     0     0
> [10,]     0     0     0     0     0
> [11,]     0     0     0     0     0
> [12,]     0     0     0     0     0
> [13,]     0     0     0     0     0
> [14,]     0     0     0     0     0
> [15,]     0     0     0     0     0
> [16,]     0     0     0     0     0
> [17,]     0     0     0     0     0
> [18,]     0     0     0     0     0
>  [ reached getOption("max.print") -- omitted 36 rows ]

Next we will create the overwrite tables, which outline transitions that cannot be estimated from the data set and need to be set by other means. Here is an example of two overwrite tables for the Cypripedium candidum analysis. Note that they are fundamentally similar to supplement tables, but do not allow the addition of multipliers and transition types from occasion t-1 to t, nor do they involve a check of entered stages against the stageframe.

cypover3_fb <- overwrite(stage3 = c("SD", "SD", "P1", "P1", "P2", "P3", "SL",
    "SL", "SL", "D", "V1", "V2", "V3", "D", "V1", "V2", "V3", "mat", "mat",
    "mat", "mat"), 
  stage2 = c("SD", "SD", "SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "SL", 
    "SL", "SL", "SL", "SL", "SL", "SL", "D", "V1", "V2", "V3"), 
  stage1 = c("SD", "rep", "SD", "rep", "SD", "P1", "P2", "P3", "SL", "P3", "P3",
    "P3", "P3", "SL", "SL", "SL", "SL", "SL", "SL", "SL", "SL"), 
  eststage3 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "V1", "V2", "V3", "D",
    "V1", "V2", "V3", "mat", "mat", "mat", "mat"), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "D", "D", "D", "D", 
    "D", "D", "D", "D", "V1", "V2", "V3"), 
  eststage1 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "D", "D", "D", "D", 
    "D", "D", "D", "V1", "V1", "V1", "V1"), 
  givenrate = c(0.08, 0.08, 0.1, 0.1, 0.1, 0.1, 0.1, 0.05, 0.05, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA))

cypover3_fb
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate convtype
> 1      SD     SD     SD      <NA>      <NA>      <NA>      0.08        1
> 2      SD     SD    rep      <NA>      <NA>      <NA>      0.08        1
> 3      P1     SD     SD      <NA>      <NA>      <NA>      0.10        1
> 4      P1     SD    rep      <NA>      <NA>      <NA>      0.10        1
> 5      P2     P1     SD      <NA>      <NA>      <NA>      0.10        1
> 6      P3     P2     P1      <NA>      <NA>      <NA>      0.10        1
> 7      SL     P3     P2      <NA>      <NA>      <NA>      0.10        1
> 8      SL     SL     P3      <NA>      <NA>      <NA>      0.05        1
> 9      SL     SL     SL      <NA>      <NA>      <NA>      0.05        1
> 10      D     SL     P3         D         D         D        NA        1
> 11     V1     SL     P3        V1         D         D        NA        1
> 12     V2     SL     P3        V2         D         D        NA        1
> 13     V3     SL     P3        V3         D         D        NA        1
> 14      D     SL     SL         D         D         D        NA        1
> 15     V1     SL     SL        V1         D         D        NA        1
> 16     V2     SL     SL        V2         D         D        NA        1
> 17     V3     SL     SL        V3         D         D        NA        1
> 18    mat      D     SL       mat         D        V1        NA        1
> 19    mat     V1     SL       mat        V1        V1        NA        1
> 20    mat     V2     SL       mat        V2        V1        NA        1
> 21    mat     V3     SL       mat        V3        V1        NA        1
>    convtype_t12
> 1             1
> 2             1
> 3             1
> 4             1
> 5             1
> 6             1
> 7             1
> 8             1
> 9             1
> 10            1
> 11            1
> 12            1
> 13            1
> 14            1
> 15            1
> 16            1
> 17            1
> 18            1
> 19            1
> 20            1
> 21            1

cypover2_fb <- overwrite(stage3 = c("SD", "P1", "P2", "P3", "SL", "SL", "D",
    "V1", "V2", "V3"), 
  stage2 = c("SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "SL", "SL"), 
  eststage3 = c(NA, NA, NA, NA, NA, NA, "D", "V1", "V2", "V3"), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, "D", "D", "D", "D"), 
  givenrate = c(0.08, 0.1, 0.1, 0.1, 0.05, 0.05, NA, NA, NA, NA), 
  type = c("S", "S", "S", "S", "S", "S", "S", "S", "S"))

cypover2_fb
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate convtype
> 1      SD     SD   <NA>      <NA>      <NA>      <NA>      0.08        1
> 2      P1     SD   <NA>      <NA>      <NA>      <NA>      0.10        1
> 3      P2     P1   <NA>      <NA>      <NA>      <NA>      0.10        1
> 4      P3     P2   <NA>      <NA>      <NA>      <NA>      0.10        1
> 5      SL     P3   <NA>      <NA>      <NA>      <NA>      0.05        1
> 6      SL     SL   <NA>      <NA>      <NA>      <NA>      0.05        1
> 7       D     SL   <NA>         D         D      <NA>        NA        1
> 8      V1     SL   <NA>        V1         D      <NA>        NA        1
> 9      V2     SL   <NA>        V2         D      <NA>        NA        1
> 10     V3     SL   <NA>        V3         D      <NA>        NA        1
>    convtype_t12
> 1             1
> 2             1
> 3             1
> 4             1
> 5             1
> 6             1
> 7             1
> 8             1
> 9             1
> 10            1

Let’s now also supply the overwrite tables and reproductive matrix for the raw MPMs.

rep_cyp_raw <- matrix(0, 11, 11)
rep_cyp_raw[1:2,7:11] <- 0.5 * seeds_per_fruit

rep_cyp_raw
>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
>  [1,]    0    0    0    0    0    0 2500 2500 2500  2500  2500
>  [2,]    0    0    0    0    0    0 2500 2500 2500  2500  2500
>  [3,]    0    0    0    0    0    0    0    0    0     0     0
>  [4,]    0    0    0    0    0    0    0    0    0     0     0
>  [5,]    0    0    0    0    0    0    0    0    0     0     0
>  [6,]    0    0    0    0    0    0    0    0    0     0     0
>  [7,]    0    0    0    0    0    0    0    0    0     0     0
>  [8,]    0    0    0    0    0    0    0    0    0     0     0
>  [9,]    0    0    0    0    0    0    0    0    0     0     0
> [10,]    0    0    0    0    0    0    0    0    0     0     0
> [11,]    0    0    0    0    0    0    0    0    0     0     0

cypover2_raw <- overwrite(stage3 = c("SD", "P1", "P2", "P3", "SL", "SL", "D",
    "XSm", "Sm"),
  stage2 = c("SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "SL"), 
  eststage3 = c(NA, NA, NA, NA, NA, NA, "D", "XSm", "Sm"), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, "XSm", "XSm", "XSm"), 
  givenrate = c(0.08, 0.10, 0.10, 0.10, 0.05, 0.05, NA, NA, NA),
  type = c("S", "S", "S", "S", "S", "S", "S", "S", "S"))

cypover2_raw
>   stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate convtype
> 1     SD     SD   <NA>      <NA>      <NA>      <NA>      0.08        1
> 2     P1     SD   <NA>      <NA>      <NA>      <NA>      0.10        1
> 3     P2     P1   <NA>      <NA>      <NA>      <NA>      0.10        1
> 4     P3     P2   <NA>      <NA>      <NA>      <NA>      0.10        1
> 5     SL     P3   <NA>      <NA>      <NA>      <NA>      0.05        1
> 6     SL     SL   <NA>      <NA>      <NA>      <NA>      0.05        1
> 7      D     SL   <NA>         D       XSm      <NA>        NA        1
> 8    XSm     SL   <NA>       XSm       XSm      <NA>        NA        1
> 9     Sm     SL   <NA>        Sm       XSm      <NA>        NA        1
>   convtype_t12
> 1            1
> 2            1
> 3            1
> 4            1
> 5            1
> 6            1
> 7            1
> 8            1
> 9            1

cypover3_raw <- overwrite(stage3 = c("SD", "SD", "P1", "P1", "P2", "P2",
    "P3", "SL", "SL", "SL", "D", "XSm", "Sm", "D", "XSm", "Sm", "mat", "mat",
    "mat"),
  stage2 = c("SD", "SD", "SD", "SD", "P1", "P1", "P2", "P3", "SL", "SL", "SL",
    "SL", "SL", "SL", "SL", "SL", "D", "XSm", "Sm"),
  stage1 = c("SD", "rep", "SD", "rep", "SD", "rep", "P1", "P2", "P3", "SL",
    "SL", "SL", "SL", "P3", "P3", "P3", "SL", "SL", "SL"),
  eststage3 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "D", "XSm", "Sm", "D",
    "XSm", "Sm", "mat", "mat", "mat"), 
  eststage2 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "XSm", "XSm", "XSm",
    "XSm", "XSm", "XSm", "D", "XSm", "Sm"),
  eststage1 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "XSm", "XSm", "XSm",
    "XSm", "XSm", "XSm", "XSm", "XSm", "XSm"),
  givenrate = c(0.08, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.05, 0.05, 0.05, NA,
    NA, NA, NA, NA, NA, NA, NA, NA),
  type = c("S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S"))

cypover3_raw
>    stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate convtype
> 1      SD     SD     SD      <NA>      <NA>      <NA>      0.08        1
> 2      SD     SD    rep      <NA>      <NA>      <NA>      0.10        1
> 3      P1     SD     SD      <NA>      <NA>      <NA>      0.10        1
> 4      P1     SD    rep      <NA>      <NA>      <NA>      0.10        1
> 5      P2     P1     SD      <NA>      <NA>      <NA>      0.10        1
> 6      P2     P1    rep      <NA>      <NA>      <NA>      0.10        1
> 7      P3     P2     P1      <NA>      <NA>      <NA>      0.10        1
> 8      SL     P3     P2      <NA>      <NA>      <NA>      0.05        1
> 9      SL     SL     P3      <NA>      <NA>      <NA>      0.05        1
> 10     SL     SL     SL      <NA>      <NA>      <NA>      0.05        1
> 11      D     SL     SL         D       XSm       XSm        NA        1
> 12    XSm     SL     SL       XSm       XSm       XSm        NA        1
> 13     Sm     SL     SL        Sm       XSm       XSm        NA        1
> 14      D     SL     P3         D       XSm       XSm        NA        1
> 15    XSm     SL     P3       XSm       XSm       XSm        NA        1
> 16     Sm     SL     P3        Sm       XSm       XSm        NA        1
> 17    mat      D     SL       mat         D       XSm        NA        1
> 18    mat    XSm     SL       mat       XSm       XSm        NA        1
> 19    mat     Sm     SL       mat        Sm       XSm        NA        1
>    convtype_t12
> 1             1
> 2             1
> 3             1
> 4             1
> 5             1
> 6             1
> 7             1
> 8             1
> 9             1
> 10            1
> 11            1
> 12            1
> 13            1
> 14            1
> 15            1
> 16            1
> 17            1
> 18            1
> 19            1

The overwrite() approach is much less powerful than the supplement table approach, particularly because it lacks the ability to handle multipliers, it lacks some shorthand stage abbreviations, and it lacks inconsistency checks, but some might prefer it.

3.7 Handling complex life histories with stage groups and supplement tables

Situations may occur in which the life history of the organism includes two sets of stages with transitions only occurring in one direction between them. For example, let’s consider the following life history model (figure 3.4).

Figure 3.4: Imaginary life history for perennial plant species X, with a pre-adult non-reproductive set of 3 stages that eventually leads to a reproductive set of stages, from which the plant cannot return.

Raw MPMs have no problem with this situation, provided that each stage has its own, unique set of characteristics. However, function-based MPMs (including IPMs) will have a default tendency to estimate survival transitions from the adult reproductive stages (in blue box) back to the pre-adult non-reproductive stages (in red box). We can deal with this problem using stage grouping.

First, we will create a new stageframe that encapsulates all of the stages above. Note that the primary addition that we will make to the sf_create() input is the group option.

sizevector <- c(0, 0, 0, 0, 0, 0, 1, 3, 1, 3, 6, 11, 20, 31)
stagevector <- c("SD", "P1", "P2", "P3", "SL", "pD", "pXSm", "pSm", "XSm", "Sm",
  "Md", "Lg", "XLg", "XXLg")
repvector <- c(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
obsvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1)
matvector <- c(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
immvector <- c(0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 0, 0, 0, 0, 0.5, 0.5, 1.5, 0.5, 1.5, 1.5, 3.5, 5.5, 5.5)
group <- c(0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2)

comments <- c("Dormant seed", "1st yr protocorm", "2nd yr protocorm",
  "3rd yr protocorm", "Seedling", "Dormant pre-adult", 
  "Extra small pre-adult (1 shoot)", "Small pre-adult (2-4 shoots)",
  "Extra small adult (1 shoot)", "Small adult (2-4 shoots)",
  "Medium adult (5-7 shoots)", "Large adult (8-14 shoots)",
  "Extra large adult (20 shoots)", "Extra extra large adult (>24.5 shoots")

cypframe_alt <- sf_create(sizes = sizevector, stagenames = stagevector, 
  repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
  propstatus = propvector, immstatus = immvector, indataset = indataset, 
  binhalfwidth = binvec, group = group, comments = comments)

cypframe_alt
>    stage size size_b size_c min_age max_age repstatus obsstatus propstatus
> 1     SD    0     NA     NA      NA      NA         0         0          1
> 2     P1    0     NA     NA      NA      NA         0         0          0
> 3     P2    0     NA     NA      NA      NA         0         0          0
> 4     P3    0     NA     NA      NA      NA         0         0          0
> 5     SL    0     NA     NA      NA      NA         0         0          0
> 6     pD    0     NA     NA      NA      NA         0         0          0
> 7   pXSm    1     NA     NA      NA      NA         0         1          0
> 8    pSm    3     NA     NA      NA      NA         0         1          0
> 9    XSm    1     NA     NA      NA      NA         1         1          0
> 10    Sm    3     NA     NA      NA      NA         1         1          0
> 11    Md    6     NA     NA      NA      NA         1         1          0
> 12    Lg   11     NA     NA      NA      NA         1         1          0
> 13   XLg   20     NA     NA      NA      NA         1         1          0
> 14  XXLg   31     NA     NA      NA      NA         1         1          0
>    immstatus matstatus indataset binhalfwidth_raw sizebin_min sizebin_max
> 1          0         0         0              0.0         0.0         0.0
> 2          1         0         0              0.0         0.0         0.0
> 3          1         0         0              0.0         0.0         0.0
> 4          1         0         0              0.0         0.0         0.0
> 5          1         0         0              0.0         0.0         0.0
> 6          1         0         1              0.5        -0.5         0.5
> 7          1         0         1              0.5         0.5         1.5
> 8          1         0         1              1.5         1.5         4.5
> 9          0         1         1              0.5         0.5         1.5
> 10         0         1         1              1.5         1.5         4.5
> 11         0         1         1              1.5         4.5         7.5
> 12         0         1         1              3.5         7.5        14.5
> 13         0         1         1              5.5        14.5        25.5
> 14         0         1         1              5.5        25.5        36.5
>    sizebin_center sizebin_width binhalfwidthb_raw sizebinb_min sizebinb_max
> 1               0             0                NA           NA           NA
> 2               0             0                NA           NA           NA
> 3               0             0                NA           NA           NA
> 4               0             0                NA           NA           NA
> 5               0             0                NA           NA           NA
> 6               0             1                NA           NA           NA
> 7               1             1                NA           NA           NA
> 8               3             3                NA           NA           NA
> 9               1             1                NA           NA           NA
> 10              3             3                NA           NA           NA
> 11              6             3                NA           NA           NA
> 12             11             7                NA           NA           NA
> 13             20            11                NA           NA           NA
> 14             31            11                NA           NA           NA
>    sizebinb_center sizebinb_width binhalfwidthc_raw sizebinc_min sizebinc_max
> 1               NA             NA                NA           NA           NA
> 2               NA             NA                NA           NA           NA
> 3               NA             NA                NA           NA           NA
> 4               NA             NA                NA           NA           NA
> 5               NA             NA                NA           NA           NA
> 6               NA             NA                NA           NA           NA
> 7               NA             NA                NA           NA           NA
> 8               NA             NA                NA           NA           NA
> 9               NA             NA                NA           NA           NA
> 10              NA             NA                NA           NA           NA
> 11              NA             NA                NA           NA           NA
> 12              NA             NA                NA           NA           NA
> 13              NA             NA                NA           NA           NA
> 14              NA             NA                NA           NA           NA
>    sizebinc_center sizebinc_width group                              comments
> 1               NA             NA     0                          Dormant seed
> 2               NA             NA     0                      1st yr protocorm
> 3               NA             NA     0                      2nd yr protocorm
> 4               NA             NA     0                      3rd yr protocorm
> 5               NA             NA     0                              Seedling
> 6               NA             NA     1                     Dormant pre-adult
> 7               NA             NA     1       Extra small pre-adult (1 shoot)
> 8               NA             NA     1          Small pre-adult (2-4 shoots)
> 9               NA             NA     2           Extra small adult (1 shoot)
> 10              NA             NA     2              Small adult (2-4 shoots)
> 11              NA             NA     2             Medium adult (5-7 shoots)
> 12              NA             NA     2             Large adult (8-14 shoots)
> 13              NA             NA     2         Extra large adult (20 shoots)
> 14              NA             NA     2 Extra extra large adult (>24.5 shoots

Now that we have our stageframe, the only thing we need to do is to specify that survival-transitions from group 2 stages to group 1 stages are equal to 0. We can do this with the supplemental() function. Here, we will set these transitions, and also set the fecundity multipliers as before.

cypsupp2_alt <- supplemental(stage3 = c("group1", "SD", "P1"),
  stage2 = c("group2", "rep", "rep"), eststage3 = c(NA, NA, NA),
  eststage2 = c(NA, NA, NA), givenrate = c(0, NA, NA),
  multiplier = c(NA, (0.5 * seeds_per_fruit), (0.5 * seeds_per_fruit)),
  type =c(1, 3, 3), stageframe = cypframe_alt, historical = FALSE)

cypsupp2_alt
>   stage3 stage2 stage1 eststage3 eststage2 eststage1 givenrate multiplier
> 1 group1 group2   <NA>        NA        NA      <NA>         0          1
> 2     SD    rep   <NA>        NA        NA      <NA>        NA       2500
> 3     P1    rep   <NA>        NA        NA      <NA>        NA       2500
>   convtype convtype_t12
> 1        1            1
> 2        3            1
> 3        3            1

This supplement table can now be input into a matrix estimator function to tell that function that these transitions must be 0. We will see how to do this with different styles of MPM in the next four chapters.

We can now proceed in the next chapter to create raw matrices.

3.8 Points to remember

  1. Functions verticalize3() and historicalize3() can be used to take horizontally or vertically arranged demographic data and standardize it into the appropriate format for MPM creation and analysis.
  2. Function supplemental() provides the means to incorporate given transition values obtained from external studies, set transitions to proxy values to be estimated by lefko3, and incorporate multipiers on survival transitions, fecundity estimates, and proxy survival transitions.
  3. Great care must be taken to include every missing transition within the supplement table. Otherwise, models will predict dying populations, and asymptotic analyses will be invariant to changes in survival and fecundity terms.
  4. Stage groups can be used to add directionality and other complex relationships between groups of life history stages.

References

Shefferson, R.P., Kurokawa, S. & Ehrlén, J. (2021). lefko3: Analysing individual history through size-classified matrix population models. Methods in Ecology and Evolution, 12, 378–382.