"portfolio"
objects. aggregate
splits portfolio data into subsets and computes
summary statistics for each.
frequency
computes the frequency of claims for subsets of
portfolio data.
severity
extracts the individual claim amounts.
weights
extracts the matrix of weights.
"aggregate"(x, by = names(x$nodes), FUN = sum, classification = TRUE, prefix = NULL, ...)
"frequency"(x, by = names(x$nodes), classification = TRUE, prefix = NULL, ...)
"severity"(x, by = head(names(x$node), -1), splitcol = NULL, classification = TRUE, prefix = NULL, ...)
"weights"(object, classification = TRUE, prefix = NULL, ...)
"portfolio"
, typically
created with simul
.x
. The names can be abbreviated.TRUE
, the node identifier
columns are included in the output.NULL
,
sensible defaults are used when appropriate.FUN
, or passed to or from
other methods.by
.For the aggregate
and frequency
methods: if at least one
level other than the last one is used for grouping, the result is a
matrix obtained by binding the appropriate node identifiers extracted
from x$classification
if classification = TRUE
, and the
summaries per grouping. If the last level is used for grouping, the
column names of x$data
are retained; if the last level is not
used for grouping, the column name is replaced by the deparsed name of
FUN
. If only the last level is used (column summaries), a named
vector is returned.For the severity
method: a list of two elements:
NULL
or a matrix of claim amounts for the
columns not specified in splitcol
, with the appropriate node
identifiers extracted from x$classification
if
classification = TRUE
;splitcol
.weights
method: the weight matrix of the portfolio with
node identifiers if classification = TRUE
.
aggregate.portfolio
computes the aggregate claim amounts
for the grouping specified in by
. Any other statistic based on
the individual claim amounts can be used through argument FUN
. frequency.portfolio
is equivalent to using aggregate.portfolio
with argument FUN
equal to if (identical(x, NA)) NA else
length(x)
.
severity.portfolio
extracts individual claim amounts of a portfolio
by groupings using the default method of severity
.
Argument splitcol
allows to get the individual claim amounts of
specific columns separately.
weights.portfolio
extracts the weight matrix of a portfolio.
simul
nodes <- list(sector = 3, unit = c(3, 4),
employer = c(3, 4, 3, 4, 2, 3, 4), year = 5)
model.freq <- expression(sector = rexp(1),
unit = rexp(sector),
employer = rgamma(unit, 1),
year = rpois(employer))
model.sev <- expression(sector = rnorm(6, 0.1),
unit = rnorm(sector, 1),
employer = rnorm(unit, 1),
year = rlnorm(employer, 1))
pf <- simul(nodes, model.freq, model.sev)
aggregate(pf) # aggregate claim amount by employer and year
aggregate(pf, classification = FALSE) # same, without node identifiers
aggregate(pf, by = "sector") # by sector
aggregate(pf, by = "y") # by year
aggregate(pf, by = c("s", "u"), mean) # average claim amount
frequency(pf) # number of claims
frequency(pf, prefix = "freq.") # more explicit column names
severity(pf) # claim amounts by row
severity(pf, by = "year") # by column
severity(pf, by = c("s", "u")) # by unit
severity(pf, splitcol = "year.5") # last year separate
severity(pf, splitcol = 5) # same
severity(pf, splitcol = c(FALSE, FALSE, FALSE, FALSE, TRUE)) # same
weights(pf)
## For portfolios with weights, the following computes loss ratios.
## Not run: aggregate(pf, classif = FALSE) / weights(pf, classif = FALSE)
Run the code above in your browser using DataLab