verticalize3()
returns a vertically formatted demographic data frame
organized to create historical projection matrices, given a horizontally
formatted input data frame.
verticalize3(
data,
noyears,
firstyear,
popidcol = 0,
patchidcol = 0,
individcol = 0,
blocksize,
xcol = 0,
ycol = 0,
juvcol = 0,
sizeacol,
sizebcol = 0,
sizeccol = 0,
repstracol = 0,
repstrbcol = 0,
fecacol = 0,
fecbcol = 0,
indcovacol = 0,
indcovbcol = 0,
indcovccol = 0,
aliveacol = 0,
deadacol = 0,
obsacol = 0,
nonobsacol = 0,
censorcol = 0,
repstrrel = 1,
fecrel = 1,
stagecol = 0,
stageassign = NA,
stagesize = NA,
censorkeep = 0,
censorRepeat = TRUE,
censor = FALSE,
spacing = NA,
NAas0 = FALSE,
NRasRep = FALSE,
reduce = TRUE,
a2check = FALSE
)
The horizontal data file.
The number of years or observation periods in the dataset.
The first year or time of observation.
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 identity of each individual.
The number of variables corresponding to each time in the
input dataset designated in data
.
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 that marks individuals in
immature stages within the dataset. The verticalize3()
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 corresponding to the size entry associated with the first year or observation time in the dataset.
A second variable name or column number corresponding to the size entry associated with the first year or observation time in the dataset.
A third variable name or column number corresponding to the size entry associated with the first year or observation time in the dataset.
A variable name or column number corresponding to the production of reproductive structures, such as flowers, associated with the first year or observation period in the input dataset. 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, associated with the first year or observation period in the input dataset. This can be binomial or count data, and is used to in analysis of the probability of reproduction.
A variable name or column number denoting fecundity associated with the first year or observation time in the input dataset. This may represent egg counts, fruit counts, seed production, etc.
A second variable name or column number denoting fecundity associated with the first year or observation time in the input dataset. 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.
A variable name or column number corresponding to an individual covariate to be used in analysis.
A second variable name or column number corresponding to an individual covariate to be used in analysis.
A variable name or column number that provides information on whether an individual is alive at a given time. 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 at a given time. 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 at a given time. 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 at a given time. If used, observation status must be designated as binomial (not observed = 1, observed = 0).
A variable name or column number corresponding to the first entry of a censor variable, used to distinguish between entries to use and entries not to use, or to designate entries with special issues that require further attention. If used, this should be associated with the first year or observation time, and all other years or times must also have censor columns.
This is a scalar multiplier on variable repstrbcol
to
make it equivalent to repstracol
. This can be useful if two
reproductive status variables have related but unequal units, for example if
repstracol
refers to one-flowered stems while repstrbcol
refers
to two-flowered stems. Defaults to 1.
This is a scalar multiplier on variable fecbcol
to make
it equivalent to fecacol
. This can be useful if two fecundity
variables have related but unequal units. Defaults to 1.
Optional variable name or column number corresponding to life history stage at a given time.
The stageframe object identifying the life history model
being operationalized. Note that if stagecol
is provided, then this
stageframe is not used for 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.
The value of the censor variable identifying data to be included in analysis. Defaults to 0, but may take any value including NA. Note that if NA is the value to keep, then this function will alter all NAs to 0 values, and all other values to 1, treating 0 as the value to keep.
A logical value indicating whether the censor variable is a single column, or whether it repeats across time blocks. Defaults to TRUE.
A logical variable determining whether the output data should
be censored using the variable defined in censorcol
. Defaults to
FALSE.
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 TRUE, then will treat non-reproductive but mature
individuals as reproductive during stage assignment. 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.
A logical variable indicating whether to retain all data with living status at time t equal to 0. Defaults to FALSE, and should be kept on FALSE except to inspect potential errors in the dataset.
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 times 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.
Variables in this data frame include the following:
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 times 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.
In some datasets on species with unobserveable stages, observation status
(obsstatus
) might not be inferred properly if a single size variable
is used that does not yield sizes greater than 0 in all cases in which
individuals were observed. Such situations may arise, for example, in plants
when leaf number is the dominant size variable used, but individuals
occasionally occur with inflorescences but no leaves. In this instances,
it helps to mark related variables as sizeb
and sizec
, because
observation status will be interpreted in relation to all 3 size variables.
Further analysis can then utilize only a single size variable, of the user's
choosing. Similar issues can arise in reproductive status (repstatus
).
Warnings that some individuals occur in state combinations that do not match
any stages in the stageframe used to assign stages are common when first
working with a dataset. Typically, these situations can be identified as
NoMatch
entries in stage3
, although such entries may crop up in
stage1
and stage2
, as well. In rare cases, these warnings will
arise with no concurrent NoMatch
entries, which indicates that the
input dataset contained conflicting state data at once suggesting that the
individual is in some stage but is also dead. The latter is removed if the
conflict occurs in time t or time t-1, as only living entries
are allowed in these times.
Care should be taken to avoid variables with negative values indicating size, fecundity, or reproductive or observation status. Negative values can be interpreted in different ways, typically reflecting estimation through other algorithms rather than actual measured data. Variables holding negative values can conflict with data management algorithms in ways that are difficult to predict.
# NOT RUN {
data(lathyrus)
sizevector <- c(0, 100, 13, 127, 3730, 3800, 0)
stagevector <- c("Sd", "Sdl", "VSm", "Sm", "VLa", "Flo", "Dorm")
repvector <- c(0, 0, 0, 0, 0, 1, 0)
obsvector <- c(0, 1, 1, 1, 1, 1, 0)
matvector <- c(0, 0, 1, 1, 1, 1, 1)
immvector <- c(1, 1, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 100, 11, 103, 3500, 3800, 0.5)
lathframe <- sf_create(sizes = sizevector, stagenames = stagevector,
repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
immstatus = immvector, indataset = indataset, binhalfwidth = binvec,
propstatus = propvector)
lathvert <- verticalize3(lathyrus, noyears = 4, firstyear = 1988,
patchidcol = "SUBPLOT", individcol = "GENET", blocksize = 9,
juvcol = "Seedling1988", sizeacol = "Volume88", repstracol = "FCODE88",
fecacol = "Intactseed88", deadacol = "Dead1988",
nonobsacol = "Dormant1988", stageassign = lathframe, stagesize = "sizea",
censorcol = "Missing1988", censorkeep = NA, censor = TRUE)
summary(lathvert)
# }
Run the code above in your browser using DataLab