historicalize3()
returns a vertically formatted demographic data frame
organized to create historical projection matrices, given a vertically but
ahistorically formatted data frame. This data frame is in standard lefko3
format and can be used in all functions in the package.
historicalize3(
data,
popidcol = 0,
patchidcol = 0,
individcol,
year2col = 0,
year3col = 0,
xcol = 0,
ycol = 0,
sizea2col = 0,
sizea3col = 0,
sizeb2col = 0,
sizeb3col = 0,
sizec2col = 0,
sizec3col = 0,
repstra2col = 0,
repstra3col = 0,
repstrb2col = 0,
repstrb3col = 0,
feca2col = 0,
feca3col = 0,
fecb2col = 0,
fecb3col = 0,
indcova2col = 0,
indcova3col = 0,
indcovb2col = 0,
indcovb3col = 0,
indcovc2col = 0,
indcovc3col = 0,
alive2col = 0,
alive3col = 0,
dead2col = 0,
dead3col = 0,
obs2col = 0,
obs3col = 0,
nonobs2col = 0,
nonobs3col = 0,
repstrrel = 1,
fecrel = 1,
stage2col = 0,
stage3col = 0,
juv2col = 0,
juv3col = 0,
stageassign = NA,
stagesize = NA,
censor = FALSE,
censorcol = 0,
censorkeep = 0,
spacing = NA,
NAas0 = FALSE,
NRasRep = FALSE,
reduce = TRUE
)
The horizontal data file.
A variable name or column number corresponding to the identity of the population for each individual.
A variable name or column number corresponding to the identity of the patch for each individual, if patches have been designated within populations.
A variable name or column number corresponding to the unique identity of each individual.
A variable name or column number corresponding to the year or time in time t.
A variable name or column number corresponding to the year or time in time t+1.
A variable name or column number corresponding to the x coordinate of each individual in Cartesian space.
A variable name or column number corresponding to the y coordinate of each individual in Cartesian space.
A variable name or column number corresponding to the primary size entry in time t.
A variable name or column number corresponding to the primary size entry in time t+1.
A variable name or column number corresponding to the secondary size entry in time t.
A variable name or column number corresponding to the secondary size entry in time t+1.
A variable name or column number corresponding to the tertiary size entry in time t.
A variable name or column number corresponding to the tertiary size entry in time t+1.
A variable name or column number corresponding to the production of reproductive structures, such as flowers, in time t. This can be binomial or count data, and is used to in analysis of the probability of reproduction.
A variable name or column number corresponding to the production of reproductive structures, such as flowers, in time t+1. This can be binomial or count data, and is used to in analysis of the probability of reproduction.
A second variable name or column number corresponding to the production of reproductive structures, such as flowers, in time t. This can be binomial or count data.
A second variable name or column number corresponding to the production of reproductive structures, such as flowers, in time t+1. This can be binomial or count data.
A variable name or column number corresponding to fecundity in time t. This may represent egg counts, fruit counts, seed production, etc.
A variable name or column number corresponding to fecundity in time t+1. This may represent egg counts, fruit counts, seed production, etc.
A second variable name or column number corresponding to fecundity in time t. This may represent egg counts, fruit counts, seed production, etc.
A second variable name or column number corresponding to fecundity in time t+1. This may represent egg counts, fruit counts, seed production, etc.
A variable name or column number corresponding to an individual covariate to be used in analysis, in time t.
A variable name or column number corresponding to an individual covariate to be used in analysis, in time t+1.
A second variable name or column number corresponding to an individual covariate to be used in analysis, in time t.
A second variable name or column number corresponding to an individual covariate to be used in analysis, in time t+1.
A third variable name or column number corresponding to an individual covariate to be used in analysis, in time t.
A third variable name or column number corresponding to an individual covariate to be used in analysis, in time t+1.
A variable name or column number that provides information on whether an individual is alive in time t. If used, living status must be designated as binomial (living = 1, dead = 0).
A variable name or column number that provides information on whether an individual is alive in time t+1. If used, living status must be designated as binomial (living = 1, dead = 0).
A variable name or column number that provides information on whether an individual is dead in time t. If used, dead status must be designated as binomial (dead = 1, living = 0).
A variable name or column number that provides information on whether an individual is dead in time t+1. If used, dead status must be designated as binomial (dead = 1, living = 0).
A variable name or column number providing information on whether an individual is in an observable stage in time t. If used, observation status must be designated as binomial (observed = 1, not observed = 0).
A variable name or column number providing information on whether an individual is in an observable stage in time t+1. If used, observation status must be designated as binomial (observed = 1, not observed = 0).
A variable name or column number providing information on whether an individual is in an unobservable stage in time t. If used, observation status must be designated as binomial (not observed = 1, observed = 0).
A variable name or column number providing information on whether an individual is in an unobservable stage in time t+1. If used, observation status must be designated as binomial (not observed = 1, observed = 0).
This is a scalar multiplier to make the variable represented by
repstrb2col
equivalent to the variable represented by repstra2col
.
This can be useful if two reproductive status variables have related but unequal
units, for example if repstrb2col
refers to one-flowered stems while
repstra2col
refers to two-flowered stems.
This is a scalar multiplier that makes the variable represented by
fecb2col
equivalent to the variable represented by feca2col
. This can
be useful if two fecundity variables have related but unequal units.
Optional variable name or column number corresponding to life history stage in time t.
Optional variable name or column number corresponding to life history stage in time t+1.
A variable name or column number that marks individuals in
immature stages in time t. The historicalize3()
function assumes
that immature individuals are identified in this variable marked with a number
equal to or greater than 1, and that mature individuals are marked as 0 or NA.
A variable name or column number that marks individuals in
immature stages in time t+1. The historicalize3()
function assumes
that immature individuals are identified in this variable marked with a number
equal to or greater than 1, and that mature individuals are marked as 0 or NA.
The stageframe object identifying the life history model
being operationalized. Note that if stage2col
is provided, then this
stageframe is not utilized in stage designation.
A variable name or column number describing which size variable
to use in stage estimation. Defaults to NA, and can also take sizea
, sizeb
,
sizec
, or sizeadded
, depending on which size variable is chosen.
A logical variable determining whether the output data should be
censored using the variable defined in censorcol
. Defaults to FALSE.
A variable name or column number corresponding to a censor variable within the dataset, used to distinguish between entries to use and those to discard from analysis, or to designate entries with special issues that require further attention.
The value of the censoring variable identifying data that should be included in analysis. Defaults to 0, but may take any value including NA.
The spacing at which density should be estimated, if density
estimation is desired and x and y coordinates are supplied. Given in the same
units as those used in the x and y coordinates given in xcol
and ycol
.
Defaults to NA.
If TRUE, then all NA entries for size and fecundity variables will
be set to 0. This can help increase the sample size analyzed by modelsearch()
,
but should only be used when it is clear that this substitution is biologically
realistic. Defaults to FALSE.
If set to TRUE, then this function will treat non-reproductive
but mature individuals as reproductive during stage zssignment. This can be
useful when a matrix is desired without separation of reproductive and
non-reproductive but mature stages of the same size. Only used if stageassign
is set to a stageframe. Defaults to FALSE.
A logical variable determining whether unused variables and some invariant state variables should be removed from the output dataset. Defaults to TRUE.
If all inputs are properly formatted, then this function will output a
historical vertical data frame (class hfvdata
), meaning that the output
data frame will have three consecutive years of size and reproductive data per
individual per row. This data frame is in standard format for all functions used
in lefko3
, and so can be used without further modification. Note that
determination of state in times *t*-1 and *t*+1 gives preference to condition in
time *t* within the input dataset. Conflicts in condition in input datasets that
have both times *t* and *t*+1 listed per row are resolved by using condition in
time *t*.
Unique identifier for the row of the data frame.
Unique identifier for the population, if given.
Unique identifier for patch within population, if given.
Unique identifier for the individual.
Year or time at time t.
Year or time of first observation.
Year or time of last observation.
Observed age in time t, assuming first observation corresponds to age = 0.
Observed lifespan, given as lastseen - firstseen + 1
.
X position in Cartesian space in times t-1, t, and t+1, respectively, if provided.
Y position in Cartesian space in times t-1, t, and t+1, respectively, if provided.
Main size measurement in times t-1, t, and t+1, respectively.
Secondary size measurement in times t-1, t, and t+1, respectively.
Tertiary measurement in times t-1, t, and t+1, respectively.
Sum of primary, secondary, and tertiary size measurements in timea t-1, t, and t+1, respectively.
Main numbers of reproductive structures in times t-1, t, and t+1, respectively.
Secondary numbers of reproductive structures in times t-1, t, and t+1, respectively.
Sum of primary and secondary reproductive structures in times t-1, t, and t+1, respectively.
Main numbers of offspring in times t-1, t, and t+1, respectively.
Secondary numbers of offspring in times t-1, t, and t+1, respectively.
Sum of primary and secondary fecundity in times t-1, t, and t+1, respectively.
Censor state values in times t-1, t, and t+1, respectively.
Binomial variable indicating whether
individual is juvenile in times t-1, t, and t+1. Only given
if juvcol
is provided.
Binomial observation state in times t-1, t, and t+1, respectively.
Binomial reproductive state in times t-1, t, and t+1, respectively.
Binomial offspring production state in times t-1, t, and t+1, respectively.
Binomial maturity state in times t-1, t, and t+1, respectively.
Binomial state as alive in times t-1, t, and t+1, respectively.
Density of individuals per unit designated in spacing
. Only
given if spacing is not NA.
# NOT RUN {
data(cypvert)
sizevector <- c(0, 0, 0, 0, 0, 0, 1, 2.5, 4.5, 8, 17.5)
stagevector <- c("SD", "P1", "P2", "P3", "SL", "D", "XSm", "Sm", "Md", "Lg", "XLg")
repvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
obsvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
matvector <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
immvector <- c(0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 0, 0, 0, 0, 0.5, 0.5, 1, 1, 2.5, 7)
cypframe_raw <- sf_create(sizes = sizevector, stagenames = stagevector,
repstatus = repvector, obsstatus = obsvector,
matstatus = matvector, propstatus = propvector,
immstatus = immvector, indataset = indataset,
binhalfwidth = binvec)
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", censor = FALSE,
NAas0 = TRUE, NRasRep = TRUE)
summary(cypraw_v2)
# }
Run the code above in your browser using DataLab