Lag time is calculated by projecting a tangent line at the point
of maximum (per-capita) derivative backwards to find the time when it
intersects with the minimum y-value
Usage
lag_time(
x = NULL,
y = NULL,
deriv = NULL,
blank = NULL,
trans_y = "log",
na.rm = TRUE,
slope = NULL,
x1 = NULL,
y1 = NULL,
y0 = NULL,
warn_logtransform_warnings = TRUE,
warn_logtransform_infinite = TRUE,
warn_min_y_mismatch = TRUE,
warn_multiple_maxderiv = TRUE,
warn_one_lag = TRUE,
warn_no_lag = TRUE,
warn_blank_length = TRUE
)Arguments
- x
vectorofxvalues (typically time)- y
vectorofyvalues (typically density)- deriv
vectorof derivative values (typically per-capita derivative)- blank
y-value associated with a "blank" where the density is 0. Is required whentrans_y = TRUE.A
vectorofblankvalues may be specified only when all ofslope,x1,y1, andy0are provided asvectors- trans_y
One of
c("linear", "log")specifying the transformation ofy-values.'log'is the default, producing calculations of lag time assuming a transition to exponential growth'linear'is available for alternate uses- na.rm
a
logicalindicating whether missing values or values that becomeNAor infinite during log-transformation should be removed- slope
Slope to project from
x1,y1toy0(typically per-capita growth rate). If not provided, will be calculated asmax(deriv)- x1
xvalue (typically time) to project slope from. If not provided, will be calculated asx[which.max(deriv)].- y1
yvalue (typically density) to project slope from. If not provided, will be calculated asy[which.max(deriv)].- y0
yvalue (typically density) to find intersection of slope fromx1,y1with. If not provided, will be calculated asmin(y)- warn_logtransform_warnings
logicalwhether warning should be issued whenlog(y)produced warnings.- warn_logtransform_infinite
logicalwhether warning should be issued whenlog(y)produced infinite values that will be treated asNA.- warn_min_y_mismatch
logicalwhether warning should be issued whenmin(y)does not equalmin(y[!is.na(x)]).- warn_multiple_maxderiv
logicalwhether warning should be issued when there are multiple points inderivthat are tied for the highest, and only the first will be used.- warn_one_lag
logicalwhether warning should be issued when some, but not all, inputs are vectorized, and only one lag time value will be returned.- warn_no_lag
logicalwhether warning should be issued when calculated lag time is less than the minimum value ofx.- warn_blank_length
logicalwhether warning should be issued when an unexpected number ofblankvalues was provided and only the first will be used
Value
Typically a scalar of the lag time in units of x. See Details for
cases when value will be a vector.
Details
For most typical uses, simply supply x, y, and deriv
(using the per-capita derivative and trans_y = 'log').
Advanced users may wish to use alternate values for the slope of the tangent
line (slope), origination point of the tangent line (x1,
y1), or minimum y-value y0. If specified, these values will
override the default calculations. If and only if all of slope,
x1, y1, and y0 are provided, lag_time is
vectorized on their inputs and will return a vector of lag time values.