factor_analysis: Factor analysis for discrete risk factors

View source: R/univariate.R

factor_analysisR Documentation

Factor analysis for discrete risk factors

Description

Performs a factor analysis for discrete risk factors in an insurance portfolio. The following summary statistics are calculated:

  • frequency = number of claims / exposure

  • average severity = severity / number of claims

  • risk premium = severity / exposure

  • loss ratio = severity / premium

  • average premium = premium / exposure

Usage

factor_analysis(
  data = NULL,
  risk_factors = NULL,
  claim_amount = NULL,
  claim_count = NULL,
  exposure = NULL,
  premium = NULL,
  group_by = NULL,
  df = NULL,
  x = NULL,
  severity = NULL,
  nclaims = NULL,
  by = NULL
)

Arguments

data

A data.frame with the insurance portfolio.

risk_factors

Character vector: column(s) in data with the risk factor(s).

claim_amount

Character, column in data with claim amounts (default = NULL).

claim_count

Character, column in data with number of claims (default = NULL).

exposure

Character, column in data with exposures (default = NULL).

premium

Character, column in data with premiums (default = NULL).

group_by

Character vector of column(s) in data to group by in addition to risk_factors.

df, x, severity, nclaims, by

Deprecated argument names. Use data, risk_factors, claim_amount, claim_count, and group_by instead.

Details

The function computes summary statistics for discrete risk factors.

  • Frequency: number of claims / exposure

  • Average severity: severity / number of claims

  • Risk premium: severity / exposure

  • Loss ratio: severity / premium

  • Average premium: premium / exposure

If one or more input arguments are not specified, the related statistics are omitted from the results.

Migration from univariate()

The function univariate() is deprecated as of version 0.8.0 and replaced by factor_analysis(). In addition to the name change, the interface has also changed:

  • univariate() used non-standard evaluation (NSE), so column names could be passed unquoted (e.g. x = area).

  • factor_analysis() uses standard evaluation (SE), so column names must be passed as character strings (e.g. x = "area").

This makes the function easier to use in programmatic workflows.

univariate() is still available for backward compatibility but will emit a deprecation warning and will be removed in a future release.

Value

An object of class "factor_analysis" and "univariate" with summary statistics.

Author(s)

Martin Haringa

Examples

## --- New usage (SE) ---
factor_analysis(MTPL2,
                risk_factors = "area",
                claim_amount = "amount",
                claim_count = "nclaims",
                exposure = "exposure",
                premium = "premium")

## --- Deprecated usage (NSE) ---
univariate(MTPL2,
           x = area,
           severity = amount,
           nclaims = nclaims,
           exposure = exposure,
           premium = premium)


insurancerating documentation built on July 30, 2026, 5:09 p.m.