vecxt_re

package vecxt_re

Members list

Type members

Classlikes

enum AmountUnit(val multiplier: Long)

The scale a monetary amount is quoted in. multiplier is the number of major currency units in one of this unit.

The scale a monetary amount is quoted in. multiplier is the number of major currency units in one of this unit.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class CalendarYearLevels

A calendar year index of levels, for on-leveling historical data.

A calendar year index of levels, for on-leveling historical data.

Holds an index level per calendar year (e.g. total insured value, a price index, or any series whose ratio between two years gives the change between them). A value from year Y is on-levelled to the current year by multiplying by level(currentYear) / level(Y).

For year-on-year change factors (e.g. 1.05 for +5%) rather than levels, use CalendarYearRateChanges.

Value parameters

currentYear

The current/reference year. Must equal years.head.

levels

Array of index levels corresponding to each year. All levels must be strictly positive. The constructor is private: the companion apply methods defensively copy the input arrays, so mutating the arrays passed in cannot bypass validation.

years

Array of contiguous years in descending order (most recent first), i.e. years(i) == currentYear - i. Use the companion apply(years, levels) to construct from years in any order.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Year-on-year rate changes by calendar year, for on-leveling historical data.

Year-on-year rate changes by calendar year, for on-leveling historical data.

Each entry is the change factor for a year (e.g. 1.05 for +5%), not an index level. For an index level series (TIV, CPI, ...) use CalendarYearLevels instead.

The factor labelled with year Y is the change from year Y - 1 to year Y. Hence a value from year Y is on-levelled to the current year by multiplying the factors of years Y + 1 to currentYear inclusive, and the earliest year that can be fully on-levelled is earliestYear - 1.

Value parameters

currentYear

The current/reference year (period 0). Must equal years.head.

factors

Array of change factors corresponding to each year. All factors must be strictly positive. The constructor is private: the companion apply methods defensively copy the input arrays, so mutating the arrays passed in cannot bypass validation or desynchronise the cached cumulative factors.

years

Array of contiguous years in descending order (most recent first), i.e. years(i) == currentYear - i. Use the companion apply(years, factors) to construct from years in any order.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Ccy

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Ccy.type
trait ContinuousDistr[T] extends Density[T], Rand[T]

Represents a continuous Distribution.

Represents a continuous Distribution.

Attributes

Supertypes
trait Rand[T]
trait Density[T]
class Object
trait Matchable
class Any
Known subtypes
class Mixed
class Pareto

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class CurrencyAmount

This should NOT be used for actual cash values. We use double here because this intended for financial simulation where errors of <0.01 are meaningless. An absolute monetary quantity denominated in a single currency, e.g. a notional, limit, premium or loss.

This should NOT be used for actual cash values. We use double here because this intended for financial simulation where errors of <0.01 are meaningless. An absolute monetary quantity denominated in a single currency, e.g. a notional, limit, premium or loss.

Amounts in different currencies are never implicitly combined: arithmetic between currencies fails, and conversion requires an explicit FX rate. Scaling by a Rel yields a CurrencyAmount (premium = notional × coupon); dividing two amounts in the same currency yields a Rel.

Stored as a Double in major currency units; AmountUnit only affects construction and display.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object CurrencyRate

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class CurrencyRate(date: LocalDate, base: Ccy, quote: Ccy, rate: Double)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait Density[T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait ContinuousDistr[T]
class Mixed
class Pareto
trait DiscreteDistr[T]
class Empirical
class Poisson
Show all
trait DiscreteDistr[T] extends Density[T], Rand[T]

Represents a discrete Distribution

Represents a discrete Distribution

Attributes

Supertypes
trait Rand[T]
trait Density[T]
class Object
trait Matchable
class Any
Known subtypes
class Empirical
class Poisson
object Empirical

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Empirical.type
case class Empirical(values: IArray[Double], weights: IArray[Double]) extends DiscreteDistr[Double], HasMean[Double], HasVariance[Double], HasCdf[Double], HasInverseCdf

Empirical distribution (JVM only).

Empirical distribution (JVM only).

This is a nonparametric distribution built directly from observed samples. It supports positive weights $w_i$.

The distribution is represented as a discrete measure on the (possibly repeated) sample values: $$\mathbb{P}(X = x) = \sum_{i: x_i = x} \frac{w_i}{\sum_k w_k}.$$

Consequently, the CDF is a right-continuous step function $$F(t) = \mathbb{P}(X \le t) = \sum_{x \le t} \mathbb{P}(X=x).$$

Sampling is performed by inverse-transform sampling on the cumulative weights.

Note: Since this is an empirical (atomic) distribution, a density/PDF in the usual continuous sense is not defined. The plot method instead displays a (weighted) histogram density estimate.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait HasCdf[Double]
trait HasVariance[Double]
trait HasMean[Double]
trait DiscreteDistr[Double]
trait Rand[Double]
trait Density[Double]
class Object
trait Matchable
class Any
Show all
case class Event(eventId: Long = ..., iteration: Int = ..., day: Int = ..., loss: Double = ...)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Event

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Event.type

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final class ExceedanceCurve(val amounts: Array[Double])

An empirical exceedance curve: one value per iteration, ranked largest first.

An empirical exceedance curve: one value per iteration, ranked largest first.

The k-th largest value (1-based rank k) sits at return period numberIterations / k: it is equalled or exceeded in k of the numberIterations iterations. The curve is a step function between these points; nothing is interpolated.

Value parameters

amounts

one value per iteration, sorted descending. Not copied and not checked: build one through Scenarr.oep / Scenarr.aep, or ExceedanceCurve.fromIterationValues, unless you know the array is already ranked.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
enum ExceedanceType(val title: String)

Which exceedance curve of a Scenarr to use.

Which exceedance curve of a Scenarr to use.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object FreqSev

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
FreqSev.type
case class FreqSev(frequency: Poisson | NegativeBinomial, severity: Mixed)

Collective risk model: a claim-count (frequency) distribution paired with a per-claim severity distribution.

Collective risk model: a claim-count (frequency) distribution paired with a per-claim severity distribution.

The aggregate loss is $S = \sum_{i=1}^{N} X_i$ with $N$ drawn from frequency and the $X_i$ iid from severity.

Serialises to JSON with only the distribution parameters; the frequency carries a "type" discriminator so the Poisson / Negative Binomial choice survives a round trip:

{
 "frequency": {"type": "NegativeBinomial", "a": 2.0, "b": 0.5},
 "severity": {"empirical": {"values": [...], "weights": [...]}, "mixingPoint": 1e6, "paretoShape": 1.8}
}

Value parameters

frequency

The claim-count distribution

severity

The per-claim loss distribution

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait HasCdf[T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Empirical
class Mixed
class Pareto
class Poisson

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Empirical
class Mixed
class Pareto
trait HasMean[T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Empirical
class Mixed
class Pareto
class Poisson
trait HasVariance[T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Empirical
class Mixed
class Pareto
class Poisson

Which version of the Hill estimator to compute. All three are built from the k largest losses and the same continuous-threshold curve; they differ in where the threshold sits and in the numerator.

Which version of the Hill estimator to compute. All three are built from the k largest losses and the same continuous-threshold curve; they differ in where the threshold sits and in the numerator.

Write X₍₁₎ ≥ X₍₂₎ ≥ … for the losses, largest first, and S = Σᵢ₌₁ᵏ log(X₍ᵢ₎ / threshold).

  • MaxLikelihood: threshold X₍ₖ₊₁₎, α̂ = k / S (Hill 1975; de Haan & Ferreira; Resnick). The maximum likelihood estimate given the threshold. For exact Pareto data S is Gamma(k, α), so E[α̂] = α · k / (k − 1).
  • Embrechts: threshold X₍ₖ₎, the k-th largest loss itself, α̂ = k / S (Embrechts, Klüppelberg & Mikosch, 1997). The i = k term of S is zero, so S is Gamma(k − 1, α) and E[α̂] = α · k / (k − 2). Equal to (k / (k − 1)) · the MaxLikelihood estimate at k − 1; always at least the MaxLikelihood estimate at the same k.
  • Unbiased: threshold X₍ₖ₊₁₎, α̂ = (k − 1) / S. Exactly unbiased for Pareto data, and minimum variance among unbiased estimators: the most conservative of the three.

The conventions agree as k → ∞; they differ by 25% or more at k = 5. None corrects for losses that are not Pareto.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object HillEstimator

Hill estimator for Pareto tail index estimation.

Hill estimator for Pareto tail index estimation.

The Hill estimator is used to estimate the shape parameter (α) of a Pareto distribution from the upper tail of the data. For a Pareto distribution with survival function S(x) = (x_min/x)^α, the tail index α determines how heavy the tail is:

  • α < 2: Infinite variance
  • α < 1: Infinite mean
  • Larger α means lighter tails

By default the estimator uses the k largest order statistics over the (k+1)-th: α̂ = k / Σᵢ₌₁ᵏ log(X₍ᵢ₎ / X₍ₖ₊₁₎). See HillConvention for the alternatives.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Layer(layerId: Long = ..., layerName: Option[String] = ..., aggLimit: Option[Double] = ..., aggRetention: Option[Double] = ..., aggType: DeductibleType = ..., occLimit: Option[Double] = ..., occRetention: Option[Double] = ..., occType: DeductibleType = ..., share: Double = ..., basePremiumAmount: Option[Double] = ..., basePremiumUnit: Option[Double] = ..., basePremiumDescription: Option[String] = ..., commissionAmount: Option[Double] = ..., commissionUnit: Option[Double] = ..., commissionDescription: Option[String] = ..., brokerageAmount: Option[Double] = ..., brokerageUnit: Option[Double] = ..., brokerageDescription: Option[String] = ..., taxAmount: Option[Double] = ..., taxUnit: Option[Double] = ..., taxDescription: Option[String] = ..., feeAmount: Option[Double] = ..., feeUnit: Option[Double] = ..., feeDescription: Option[String] = ..., reinstatement: Option[Array[Double]] = ..., currency: Option[String] = ...)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Layer

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Layer.type
object Limits

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Limits.type
enum LossCalc

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object LossMatrix

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
LossMatrix.type
object Mixed

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Mixed.type
case class Mixed(empirical: Empirical, mixingPoint: Double, paretoShape: Double) extends ContinuousDistr[Double], HasMean[Double], HasVariance[Double], HasCdf[Double], HasInverseCdf

Mixed distribution: Empirical body with Pareto tail.

Mixed distribution: Empirical body with Pareto tail.

This distribution combines an empirical distribution for the body (values below the mixing point) with a Pareto distribution for the tail (values at or above the mixing point).

The distribution is parameterized by:

  • An empirical distribution of observed values
  • A mixing point $m$ (threshold between body and tail)
  • A Pareto shape parameter $\alpha$ (for the tail)

The CDF is continuous at the mixing point. Let $p_m = F_{\text{emp}}(m^-)$ be the empirical CDF just below the mixing point. Then:

  • For $x < m$: $F(x) = F_{\text{emp}}(x)$
  • For $x \ge m$: $F(x) = p_m + (1 - p_m) \cdot F_{\text{Pareto}}(x)$

where the Pareto distribution has scale = $m$ and shape = $\alpha$.

Value parameters

empirical

The empirical distribution for the body

mixingPoint

The threshold where we switch from empirical to Pareto tail

paretoShape

The shape parameter (α) for the Pareto tail

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait HasCdf[Double]
trait HasVariance[Double]
trait HasMean[Double]
trait ContinuousDistr[Double]
trait Rand[Double]
trait Density[Double]
class Object
trait Matchable
class Any
Show all
object NamedRecord

Compile-time helpers for accepting a named tuple by field name rather than by field position.

Compile-time helpers for accepting a named tuple by field name rather than by field position.

A caller may supply (id = "1", price = p, notional = n, name = "A") where the required shape is (price: Price, notional: CurrencyAmount, name: String, id: String): field order is irrelevant and extra fields are ignored, but every required field must be present with a conforming type or compilation fails.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class NegativeBinomial(a: Double, b: Double) extends DiscreteDistr[Int], HasMean[Double], HasCdf[Int], HasVariance[Double]

Negative Binomial Distribution with alternative parameterization.

Negative Binomial Distribution with alternative parameterization.

Uses the parameterization:

  • r = a (number of successes, can be any positive real)
  • p = 1 / (1 + b) (probability of success)

Which gives:

  • mean = a * b
  • variance = a * b * (1 + b)

Under this parameterisation, as b -> 0, the distribution will converge to Poisson(ab). The parameter b is therefore a measure of overdispersion.

Implementation uses the gamma-Poisson mixture representation, which allows non-integer a: If λ ~ Gamma(a, b) and X | λ ~ Poisson(λ), then X ~ NegativeBinomial(a, b)

Value parameters

a

shape parameter (must be positive, can be non-integer)

b

scale/dispersion parameter (must be positive)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait HasVariance[Double]
trait HasCdf[Int]
trait HasMean[Double]
trait DiscreteDistr[Int]
trait Rand[Int]
trait Density[Int]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class Pareto(scale: Double, shape: Double) extends ContinuousDistr[Double], HasMean[Double], HasVariance[Double], HasCdf[Double], HasInverseCdf

Pareto Type I Distribution.

Pareto Type I Distribution.

The Pareto distribution is a power-law probability distribution commonly used to model the distribution of wealth, insurance losses, and other phenomena where small values are common and large values are rare but possible.

For scale parameter k (minimum possible value) and shape parameter α (Pareto index):

  • PDF: f(x) = α * k^α / x^(α+1) for x >= k
  • CDF: F(x) = 1 - (k/x)^α for x >= k
  • Mean: k * α / (α - 1) for α > 1, otherwise infinite
  • Variance: k² * α / ((α-1)² * (α-2)) for α > 2, otherwise infinite

Value parameters

scale

Scale parameter k (minimum possible value of X, must be positive)

shape

Shape parameter α (Pareto index, must be positive)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait HasCdf[Double]
trait HasVariance[Double]
trait HasMean[Double]
trait ContinuousDistr[Double]
trait Rand[Double]
trait Density[Double]
class Object
trait Matchable
class Any
Show all

Pickands estimator for extreme value index (tail index) estimation.

Pickands estimator for extreme value index (tail index) estimation.

It is unlikely to be useful, given the amount of data typically available in reinsurance.

The Pickands estimator is a robust, non-parametric estimator for the extreme value index (EVI) of a distribution. Unlike the Hill estimator which assumes a Pareto-type tail, the Pickands estimator works for all three domains of attraction (Fréchet, Gumbel, Weibull).

For heavy-tailed distributions (Fréchet domain), the EVI γ > 0 corresponds to a Pareto tail index α = 1/γ.

The estimator uses order statistics at positions n-k, n-2k, n-4k: γ̂ = (1/ln2) * ln((X₍ₙ₋ₖ₎ - X₍ₙ₋₂ₖ₎) / (X₍ₙ₋₂ₖ₎ - X₍ₙ₋₄ₖ₎))

Properties:

  • More robust to model misspecification than Hill
  • Higher variance than Hill for pure Pareto data
  • Works for all extreme value distributions, not just Pareto
  • Consistent and asymptotically normal

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Platform-specific reporting implementations for JVM.

Platform-specific reporting implementations for JVM.

Uses a streaming single-pass algorithm to compute all loss metrics efficiently. The algorithm processes groups inline (avoiding the allocation of an intermediate array) and uses Welford's online algorithm for numerically stable variance computation.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Plots

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Plots.type
object Poisson

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Poisson.type
case class Poisson(lambda: Double) extends DiscreteDistr[Int], HasMean[Double], HasCdf[Int], HasVariance[Double]

Poisson Distribution.

Poisson Distribution.

The Poisson distribution models the number of events occurring in a fixed interval of time or space, given that these events occur with a known constant mean rate and independently of the time since the last event.

Parameterization:

  • λ (lambda) = mean = variance

PMF: P(X = k) = λ^k * e^(-λ) / k!

The Poisson distribution is a limiting case of the Negative Binomial distribution as the dispersion parameter b → 0.

Value parameters

lambda

the rate parameter (must be positive)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait HasVariance[Double]
trait HasCdf[Int]
trait HasMean[Double]
trait DiscreteDistr[Int]
trait Rand[Int]
trait Density[Int]
class Object
trait Matchable
class Any
Show all
object PortfolioCalc

Portfolio level calculations over a collection of positions.

Portfolio level calculations over a collection of positions.

Positions are record-like views over a Map[String, Any], exposing typed fields via scala.Selectable. Callers need not construct them directly: the public entry points accept any named tuple carrying the required fields (see NamedRecord).

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Price

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Price.type
enum PriceUnit(val unit: Int)

The unit a price or rate is quoted in. unit is the value that represents par (100%) in that unit.

The unit a price or rate is quoted in. unit is the value that represents par (100%) in that unit.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait Rand[T]

A trait for monadic distributions. Provides support for use in for-comprehensions

A trait for monadic distributions. Provides support for use in for-comprehensions

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait ContinuousDistr[T]
class Mixed
class Pareto
trait DiscreteDistr[T]
class Empirical
class Poisson
Show all
Self type
Rand[T]

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class RateChangesPerPeriod(factors: Array[Double])

Per-period rate changes, for on-leveling period-based models.

Per-period rate changes, for on-leveling period-based models.

Each entry is the change factor for a period (e.g. 1.05 for +5%), counted from period 0 (current) backwards. The cumulative factor which on-levels a value from a historical period to the current period is the product of the factors in between.

Value parameters

factors

Array of change factors where factors(0) is the current period (period 0) and factors(n) is n periods back.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ReReporting

Per-layer loss metrics over a simulation.

Per-layer loss metrics over a simulation.

Precondition for every method taking years: years(i) is the 1-based iteration of cededToLayer(i), the two arrays have the same length, years is sorted in non-decreasing order, and every value is in 1..numIterations. Arrays that come from a Scenario, or a Scenarr with isSorted = true, already satisfy this.

lossReport checks the precondition and throws IllegalArgumentException if it is broken. The check costs nothing extra: its single pass only consumes years(i) when it equals the current iteration, so leftover entries at the end mean years was unsorted or out of range.

The group-sum based methods (attachmentProbability, exhaustionProbability, std) do NOT check it, because checking would add a second full pass. Unsorted years silently gives wrong numbers there: they keep only the last run of each iteration (see groupSums.scala).

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Rel

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Rel.type

What lossReport divides EL and std by.

What lossReport divides EL and std by.

  • FirstLimit / AggLimit: the layer's limit. Ceded amounts already include the share, so they are divided by limit * share (see divisor). The resulting ratios are on a 100% basis and do not depend on share.
  • Custom(d): divided by exactly d, with no share adjustment, e.g. Custom(1.0) for raw ceded EL / std.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Retentions

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Retentions.type
object RiskFreeRate

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Scenario

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Scenario.type
case class Scenario(events: IndexedSeq[Event] = ..., numberIterations: Int = ..., threshold: Double = ..., day1: LocalDate = ..., name: String = ..., id: Long = ...)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Scenarr

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Scenarr.type
case class Scenarr(iterations: Array[Int], days: Array[Int], amounts: Array[Double], ids: Array[Long], numberIterations: Int, threshold: Double = ..., day1: LocalDate = ..., name: String = ..., id: Long = ..., isSorted: Boolean = ...)

Columnar scenario: one entry per event across iterations, days, amounts and ids.

Columnar scenario: one entry per event across iterations, days, amounts and ids.

isSorted is a promise from the constructor's caller that the columns are ordered by (iteration, day), and that every iteration lies in 1..numberIterations. It is trusted, not verified: per-iteration statistics (freq, agg, oep) feed it into unchecked single-pass kernels (see groupSums.scala), and passing isSorted = true for unsorted data gives silently wrong results. If you're unsure, leave it false and call .sorted.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class SeverityTrendResult(nObs: Int, dfResidual: Int, intercept: Double, slope: Double, seIntercept: Double, seSlope: Double, tIntercept: Double, tSlope: Double, pValueIntercept: Double, pValueSlope: Double, sigma: Double, rSquared: Double, meanYear: Double, sxx: Double)

Result of fitting a severity trend: log(X) = β₀ + β₁·year + ε, by ordinary least squares.

Result of fitting a severity trend: log(X) = β₀ + β₁·year + ε, by ordinary least squares.

exp(β₁) − 1 is the annual trend in the median (geometric mean) severity. If log(X) is normal with constant σ (a lognormal severity), it is also the annual trend in the mean.

Inference uses Student's t with n − 2 degrees of freedom, assuming independent residuals with constant variance. Residuals of log severity are often skewed (log of a Pareto is exponential). With small data volumes that makes the t-based intervals approximate, and single losses can dominate the fit: see TrendAnalysis.fitSeverityTrendLeaveOneOut. Read the result as a check for gross errors in the normalisation, not as a measurement of the trend.

Value parameters

dfResidual

Residual degrees of freedom (n − 2)

intercept

Estimated intercept (β₀), log scale

meanYear

Mean of the years, x̄

nObs

Number of losses

pValueIntercept

Two-tailed p-value for intercept (H₀: β₀ = 0)

pValueSlope

Two-tailed p-value for slope (H₀: β₁ = 0) - this tests for a significant severity trend

rSquared

Coefficient of determination

seIntercept

Standard error of intercept

seSlope

Standard error of slope

sigma

Residual standard deviation of log severity

slope

Estimated year coefficient (β₁), log scale

sxx

Σ(yearᵢ − x̄)²

tIntercept

t-statistic for intercept

tSlope

t-statistic for slope

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SplitLosses

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object SplitScenario

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Spread

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Spread.type
case class Sublayer(limit: Option[Double], retention: Option[Double], layerType: LossCalc, aggOrOcc: DeductibleType)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Tower(layers: IndexedSeq[Layer], id: Long = ..., name: Option[String] = ..., subjPremium: Option[Double] = ...)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Tower

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Tower.type
object TrendAnalysis

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class TrendFitResult(nObs: Int, dfResidual: Int, intercept: Double, slope: Double, seIntercept: Double, seSlope: Double, zIntercept: Double, zSlope: Double, pValueIntercept: Double, pValueSlope: Double, nullDeviance: Double, residualDeviance: Double, dispersion: Double, fStatistic: Double, fPValue: Double, aic: Double, logLikelihood: Double)

Result of fitting a GLM trend model: log(μ) = β₀ + β₁·year

Result of fitting a GLM trend model: log(μ) = β₀ + β₁·year

Contains coefficient estimates, standard errors, test statistics, and goodness-of-fit measures.

Value parameters

aic

Akaike Information Criterion

dfResidual

Residual degrees of freedom (n - 2)

dispersion

Estimated dispersion parameter (1.0 for Poisson, estimated for NegBin)

fPValue

p-value for fStatistic: χ²(1) for Poisson (dispersion fixed at 1), F(1, n−2) for NegBin (dispersion estimated)

fStatistic

Test statistic for model vs intercept-only: the deviance drop, divided by the estimated dispersion for NegBin

intercept

Estimated intercept (β₀)

logLikelihood

Log-likelihood of the fitted model

nObs

Number of observations

nullDeviance

Deviance of intercept-only model

pValueIntercept

Two-tailed p-value for intercept (H₀: β₀ = 0)

pValueSlope

Two-tailed p-value for slope (H₀: β₁ = 0) - this tests for significant trend

residualDeviance

Deviance of full model

seIntercept

Standard error of intercept

seSlope

Standard error of slope

slope

Estimated year coefficient (β₁)

zIntercept

z-statistic for intercept (β₀ / SE(β₀))

zSlope

z-statistic for slope (β₁ / SE(β₁))

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object all

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
all.type
object rpt

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
rpt.type

Types

opaque type Ccy

An ISO 4217 currency code, e.g. Ccy.USD or Ccy("SEK"). Open, so callers may use currencies not listed here.

An ISO 4217 currency code, e.g. Ccy.USD or Ccy("SEK"). Open, so callers may use currencies not listed here.

Attributes

opaque type LossMatrix

The assumption here.

The assumption here.

Potential future outcomes of a single transactions run down columns.

Each row represents one potential future outcome, across a portfolio

Attributes

opaque type Price

A price level relative to par, stored as a canonical Double where 1.0 is par.

A price level relative to par, stored as a canonical Double where 1.0 is par.

A Price is a point on a scale rather than an amount, so it is deliberately not a Rel: the difference of two prices is a Rel, a Rel can be added to or subtracted from a Price, and two prices cannot be added together.

As with Rel, PriceUnit only affects construction (Price(102, PriceUnit.Pts)) and display (p.in(PriceUnit.Pts)).

Attributes

opaque type Rel

A relative quantity: a change in price, a return, a ratio, or a one year rate (see Spread, RiskFreeRate). Stored as a canonical Double where 1.0 is 100%.

A relative quantity: a change in price, a return, a ratio, or a one year rate (see Spread, RiskFreeRate). Stored as a canonical Double where 1.0 is 100%.

PriceUnit is a boundary concern only: it is used to construct a Rel from a quote (Rel(50, PriceUnit.Bps)) and to read one back out (r.in(PriceUnit.Bps)). It is not stored, so equality, ordering and arithmetic are all on the canonical value, and an Array[Rel] is an Array[Double] at runtime.

A price level is not a Rel; see Price. Price - Price is a Rel and Price + Rel is a Price.

Attributes

opaque type RiskFreeRate

An annual risk free rate. Over the one year horizon it is the risk free return.

An annual risk free rate. Over the one year horizon it is the risk free return.

Attributes

opaque type Spread

An annual credit spread. Over the one year horizon it is the return earned for bearing credit risk.

An annual credit spread. Over the one year horizon it is the return earned for bearing credit risk.

Attributes

Value members

Concrete methods

def aggregateByItr(years: Array[Int], splits: IndexedSeq[(Layer, Array[Double])], numItrs: Int): IndexedSeq[(Layer, Array[Double])]

Aggregate each layer's per-event amounts into per-iteration totals.

Aggregate each layer's per-event amounts into per-iteration totals.

years(i) is the 1-based iteration of each layer's amounts(i). It must be sorted in non-decreasing order with values in 1..numItrs, and every amounts array must have the same length as years. This is NOT checked, for performance: unsorted years silently gives wrong totals. See groupSums.scala.

Attributes

inline def groupDiff(groups: Array[Int], values: Array[Double]): Array[Double]
  • You have a sorted groups array.
    • Each group has a small number of values.
  • You're doing per-group differences.
  • Returns differences between consecutive elements within each group
  • Each group starts with its first value

Attributes

inline def groupDiffInPlace(groups: Array[Int], values: Array[Double]): Unit

In-place version that modifies the input array directly. More efficient when the original values are not needed.

In-place version that modifies the input array directly. More efficient when the original values are not needed.

Attributes

Extensions

Extensions

extension (k: Double)
def *[R <: Rel](r: R): R
extension (m: LossMatrix)
def attachProb: Double

The probability of paying any loss

The probability of paying any loss

Attributes

def el: Double
def transactionEls: Matrix[Double]
extension (scenario: Scenario)
inline def applyThreshold(newThresh: Double): Scenario
inline def removeClaimsAfter(date: LocalDate): Scenario
inline def removeClaimsBefore(date: LocalDate): Scenario
inline def scaleAmntBy(scale: Double): Scenario
def shiftDay1To(date: LocalDate): Scenario