Description Usage Arguments Details Value See Also Examples
Given assumptions about the type and amount of change, extend a demographic array along a specified dimension.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
object |
An object of class |
along |
Name or index of dimension along which values are extrapolated.
If |
labels |
Labels for the new elements to be added to dimension
|
growth |
A single number, or a |
type |
The type of growth assumed: |
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.
Values may be extrapolated forward, from the end of the along
dimension, or backward, from the start. See below for examples.
If growth
is a demographic array, it will
typically have been created by a call to growth
. Use of a
demographic array object allows growth rates or increments to differ
within classifying variables: see growth
for details.
If type
is "exponential"
, then extrapolated values are
generated using the formula y[n] = y[1]
(1 + g)^(t[n] - t[1]), and if type
is "linear"
, values are
generated using y[n] = y[1] + (t[n] - t[1])
g, where g is growth
. If type
is "missing"
the
extra cells are filled with NA
s.
An object of 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 29 30 31 32 33 34 35 36 37 38 | ## prepare data
library(datasets)
spend <- USPersonalExpenditure
names(dimnames(spend)) <- c("category", "year")
spend <- Values(spend)
## extrapolate assuming expenditure in all
## categories grows at 1% per annum
## (note that 'type' defaults to "exponential")
extrapolate(spend, labels = c(1965, 1970), growth = 0.01)
## linear increase of $1 per annum
extrapolate(spend, labels = c(1965, 1970), growth = 1, type = "linear")
extrapolate(spend, labels = c(1965, 1970), growth = 1, type = "l")
## grows at historial growth rate - same rate for all categories
gr <- growth(spend)
extrapolate(spend, labels = c(1965, 1970), growth = gr)
## grows at historical growth rates - rate specific to each category
gr <- growth(spend, within = "category")
extrapolate(spend, labels = c(1965, 1970), growth = gr)
## irregularly-spaced times
extrapolate(spend, labels = c(1972.25, 2001), growth = 0.01)
## backward extrapolation
extrapolate(spend, labels = c(1930, 1935), growth = 0.01)
## fill extra years with NAs
extrapolate(spend, labels = c(1965, 1970), type = "missing")
## example of extrapolation over age intervals
library(demdata)
deaths <- Values(VADeaths2)
gr <- growth(deaths, along = "age", within = c("sex", "residence"))
extrapolate(deaths, along = "age", labels = c("75-79", "80+"), growth = gr)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.