Summary Statistics of a Portfolio
Methods for class "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.
## S3 method for class 'portfolio' aggregate(x, by = names(x$nodes), FUN = sum, classification = TRUE, prefix = NULL, ...) ## S3 method for class 'portfolio' frequency(x, by = names(x$nodes), classification = TRUE, prefix = NULL, ...) ## S3 method for class 'portfolio' severity(x, by = head(names(x$node), -1), splitcol = NULL, classification = TRUE, prefix = NULL, ...) ## S3 method for class 'portfolio' weights(object, classification = TRUE, prefix = NULL, ...)
x, object |
an object of class |
by |
character vector of grouping elements using the level names
of the portfolio in |
FUN |
the function to be applied to data subsets. |
classification |
boolean; if |
prefix |
characters to prefix column names with; if |
splitcol |
columns of the data matrix to extract separately; usual matrix indexing methods are supported. |
... |
optional arguments to |
By default, 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.
A matrix or vector depending on the groupings specified in 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:
main |
|
split |
same as above, but for the columns specified in
|
For the weights
method: the weight matrix of the portfolio with
node identifiers if classification = TRUE
.
Vincent Goulet vincent.goulet@act.ulaval.ca, Louis-Philippe Pouliot.
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.