Description Usage Arguments Details Value See Also Examples
Calculate average growth rates or increments for a
DemographicArray
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | growth(
object,
along = NULL,
within = NULL,
weights,
type = c("linear", "exponential"),
method = c("endpoints", "lm")
)
## S4 method for signature 'Counts'
growth(
object,
along = NULL,
within = NULL,
weights,
type = c("exponential", "linear"),
method = c("endpoints", "lm")
)
## S4 method for signature 'Values'
growth(
object,
along = NULL,
within = NULL,
weights,
type = c("exponential", "linear"),
method = c("endpoints", "lm")
)
|
object |
Object of class |
along |
Name or index of dimension along which growth is calculated.
If |
within |
Name or index of dimensions within which growth is calculated.
Value |
weights |
Object of class |
type |
One of |
method |
One of |
The along
dimension must have dimscale
"Intervals"
or "Points"
, which means that it must have
dimtype
"age"
, "cohort"
, or "time"
. The
intervals or points do not need to be evenly spaced.
If there is a dimension with dimtype
"iteration"
and
that dimension is not explicitly included in within
, then it is added
to within
automatically.
All dimensions of object
not included in along
or
within
are aggregated before growth rates or increments are
calculated.
If a weights
argument is supplied when object
has class
Counts
, the argument is ignored. If a weights
argument is not supplied when object
has class
Values
, all elements are given equal weight.
If method
is "endpoints"
, then growth rates or increments are
calculated from the first and last points only. If method
is
"lm"
, then growth rates are calculated by fitting a linear model to
the logged values, and increments are calculated by fitting a linear model
to the values.
If within
is NULL
, a numeric value; otherwise an
object with the same class as object
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## construct data
spend <- USPersonalExpenditure
names(dimnames(spend)) <- c("category", "year")
spend <- Counts(spend)
## calculate average growth rate across all categories
growth(spend, along = "year")
growth(spend) ## defaults to using dimension with dimtype "time"
## growth within categories
growth(spend, within = "category")
growth(spend, within = ".")
## increments rather than rates
growth(spend, within = "category", type = "linear")
## two different methods for calculating
growth(spend, within = "category")
growth(spend, within = "category", method = "lm")
## use base name to specific origin and destination dimensions
a <- array(rpois(n = 45, lambda = 10),
dim = c(3, 3, 5),
dimnames = list(reg_orig = 1:3,
reg_dest = 1:3, time = 2000:2004))
x <- Counts(a, dimscales = c(time = "Points"))
growth(x, within = c("reg_orig", "reg_dest"))
growth(x, within = "reg")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.