| simpf.summaries {actuar} | R Documentation |
Methods for class "simpf" 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 'simpf': aggregate(x, by = names(x$nodes), FUN = sum, ...) ## S3 method for class 'simpf': frequency(x, by = names(x$nodes), ...) ## S3 method for class 'simpf': severity(x, by = head(names(x$node), -1), splitcol = NULL, ...) ## S3 method for class 'simpf': weights(object, ...)
x, object |
an object of class "simpf", typically
created with simpf. |
by |
character vector of grouping elements using the level names
of the portfolio in x. The names can be abbreviated. |
FUN |
the function to be applied to data subsets. |
splitcol |
columns of the data matrix to extract separately; usual matrix indexing methods are supported. |
... |
optional arguments to FUN. |
By default, aggregate.simpf computes the aggregate claim amount
for the grouping specified in by. Any other statistic based on
the individual claim amounts can be used through argument FUN.
frequency.simpf is equivalent to using aggregate.simpf
with argument FUN equal to if (identical(x, NA)) NA else
length(x).
severity.simpf 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.simpf 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 and the summaries per
grouping. If the last level is used, the column names of
x$data are retained; otherwise, 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:
first |
NULL or a matrix of claim amounts for the
columns not specified in splitcol with the appropriate node
identifiers extracted from x$classification; |
last |
same as above, but for the columns specified in
splitcol. |
For the weights method: the weight matrix of the portfolio with
node identifiers.
Vincent Goulet vincent.goulet@act.ulaval.ca and 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 <- simpf(nodes, model.freq, model.sev)
aggregate(pf) # aggregate claim amount by employer and year
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
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)