Description Usage Arguments Details See Also Examples
Collapse a dimension with dimtype
"iteration"
,
typically replacing it with a much shorter dimension with dimtype
"quantile"
.
1 2 3 4 | collapseIterations(object, FUN = quantile, ...)
## S4 method for signature 'DemographicArray'
collapseIterations(object, FUN = quantile, ...)
|
object |
Object of class |
FUN |
A function. Defaults to |
... |
Further arguments, passed to |
Many estimation and forecasting methods produce sets of simulation runs or
iterations. When graphing or reporting results, it is typically necessary
to reduce the full set of iterations to a set of summary values. Function
collapseIterations
carries out this reduction. By default,
collapseIterations
calculates quantiles. However, users can supply
alternatives, including their own customized functions.
If FUN
returns a vector, then the dimension with dimtype
"iteration"
is replaced by one with dimtype "quantile"
or
"state"
. If FUN
returns a single value, then the
"iteration"
dimension is dropped.
By default, function quantile
uses quantiles 0, 0.25,
0.5, 0.75, 1
. Quantiles more useful for summarizing iterations, such as
0.025, 0.5, 0.975
, can be obtained by using a prob
argument:
see below for an example.
collapseCategories
, collapseIntervals
,
collapseOrigDest
, collapseDimension
,
dimtypes
, dimscales
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | x <- Counts(array(rpois(n = 20, lambda = c(8, 12)),
dim = c(2, 10),
dimnames = list(sex = c("Female", "Male"),
iteration = 1:10)))
x
collapseIterations(x)
## pass different values for 'prob' to 'quantile'
collapseIterations(x, prob = c(0.025, 0.5, 0.975))
## summarize with a single value
collapseIterations(x, FUN = mean)
## a user-defined function
sumvals <- function(x) c(mean = mean(x), sd = sd(x))
collapseIterations(x, FUN = sumvals)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.