byIndv4Intvl_GRsAvg {growthPheno} | R Documentation |
Calculates the growth rates for a specified time interval for individuals
in a data.frame
in long format by taking weighted averages of
growth rates for times within the interval.
Description
Using previously calculated growth rates over time, calculates the Absolute Growth Rates for a specified interval using the weighted averages of AGRs for each time point in the interval (AGR) and the Relative Growth Rates for a specified interval using the weighted geometric means of RGRs for each time point in the interval (RGR).
Usage
byIndv4Intvl_GRsAvg(data, responses,
individuals = "Snapshot.ID.Tag", times = "DAP",
which.rates = c("AGR","RGR"),
suffices.rates=c("AGR","RGR"), sep.rates = ".",
start.time, end.time,
suffix.interval, sep.suffix.interval = ".",
sep.levels=".", na.rm=FALSE)
Arguments
data |
A |
responses |
A |
individuals |
A |
times |
A |
which.rates |
A |
suffices.rates |
A |
sep.rates |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
sep.suffix.interval |
A |
sep.levels |
A |
na.rm |
A |
Details
The AGR
for an interval is calculated as the weighted mean of the
AGRs for times within the interval. The RGR is calculated as the weighted
geometric mean of the RGRs for times within the interval; in fact the exponential is taken of the weighted means of the logs of the RGRs. The weights are
obtained from the times
. They are taken as the sum of half the time subintervals before and after each time, except for the end points; the end points are taken to be the subintervals at the start and end of the interval.
Value
A data.frame
with the growth rates.
The name of each column is the concatenation of (i) one of
responses
, (ii) one of AGR
, PGR
or RGR
,
or the appropriate element of suffices.rates
, and (iii)
suffix.interval
, the three components being separated by
full stops.
Author(s)
Chris Brien
See Also
byIndv4Intvl_GRsDiff
, byIndv4Intvl_WaterUse
, splitValueCalculate
, getTimesSubset
,
GrowthRates
, byIndv4Times_SplinesGRs
, splitContGRdiff
Examples
data(exampleData)
longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat,
response="PSA", response.smoothed = "sPSA",
individuals = "Snapshot.ID.Tag",
times = "DAP",
df = 4,
rates.method = "deriv",
which.rates = c("AGR", "RGR"),
suffices.rates = c("AGRdv", "RGRdv"))
sPSA.GR <- byIndv4Intvl_GRsAvg(data = longi.dat,
response="sPSA", times = "DAP",
which.rates = c("AGR","RGR"),
suffices.rates = c("AGRdv","RGRdv"),
start.time = 31, end.time = 35,
suffix.interval = "31to35")