# intervalGRaverage

##### Calculates the growth rates for a specified time interval by taking weighted averages of growth rates for times within the interval

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

```
intervalGRaverage(responses, individuals = "Snapshot.ID.Tag",
which.rates = c("AGR","RGR"), suffices.rates=c("AGR","RGR"),
start.time, end.time, times.factor = "Days", suffix.interval,
data, sep=".", na.rm=TRUE)
```

##### Arguments

- responses
A

`character`

giving the names of the`responses`

for which there are columns in`data`

that contain the growth rates that are to be averaged. The names of the growth rates should have either`AGR`

or`RGR`

appended to the`responses`

names.- individuals
A

`character`

giving the name(s) of the`factor`

(s) that define the subsets of the`data`

for which each subset corresponds to the`responses`

for an individual.- which.rates
A

`character`

giving the growth rates that are to be averaged to obtain growth rates for an interval. It should be a combination`"AGR"`

and`"RGR"`

.- suffices.rates
A

`character`

giving the suffices to be appended to`response`

to form the names of the columns containing the calculated the growth rates and in which growth rates are to be stored. Their elements will be matched with those of`which.rates`

.- start.time
A

`numeric`

giving the times, in terms of levels of`times.factor`

, that will give a single value for each`Snapshot.ID.Tag`

and that will be taken as the observation at the start of the interval for which the growth rate is to be calculated.- end.time
A

`numeric`

giving the times, in terms of levels of`times.factor`

, that will give a single value for each`Snapshot.ID.Tag`

and that will be taken as the observation at the end of the interval for which the growth rate is to be calculated.- times.factor
A

`character`

giving the name of the column in`data`

containing the factor for times at which the data was collected. Its levels will be used in calculating growth rates and should be numeric values stored as characters.- suffix.interval
A

`character`

giving the suffix to be appended to`response`

.`suffices.rates`

to form the names of the columns containing the calculated the growth rates.- data
A

`data.frame`

containing the columns from which the growth rates are to be calculated.- sep
A

`character`

giving the separator to use when the levels of`individuals`

are combined. This is needed to avoid using a`character`

that occurs in a factor to delimit levels when the levels of`individuals`

are combined to identify subsets.- na.rm
A

`logical`

indicating whether`NA`

values should be stripped before the calculation of weighted means proceeds.

##### 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.factor`

. 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.

##### See Also

`intervalGRdiff`

, `intervalWUI`

, `splitValueCalculate`

, `getTimesSubset`

, `GrowthRates`

, `splitSplines`

, `splitContGRdiff`

##### Examples

```
# NOT RUN {
data(exampleData)
longi.dat <- splitSplines(longi.dat, response="Area", x="xDays",
INDICES = "Snapshot.ID.Tag",
df = 4, deriv=1, suffices.deriv="AGRdv", RGR="RGRdv")
Area.smooth.GR <- intervalGRaverage("Area.smooth", which.rates = c("AGR","RGR"),
suffices.rates = c("AGRdv","RGRdv"),
start.time = 31, end.time = 35,
suffix.interval = "31to35",
data = longi.dat)
# }
```

*Documentation reproduced from package growthPheno, version 1.0-13, License: GPL (>= 2)*