CalendarYearLevels

vecxt_re.CalendarYearLevels
See theCalendarYearLevels companion object
case class CalendarYearLevels

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
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

inline def earliestYear: Int

The earliest year covered

The earliest year covered

Attributes

override def equals(that: Any): Boolean

Checks whether this instance is equal to that. This universal equality method is defined in AnyRef.

Checks whether this instance is equal to that. This universal equality method is defined in AnyRef.

Attributes

Definition Classes
Equals -> Any
override def hashCode: Int

Calculates a hash code value for the object.

Calculates a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
inline def latestYear: Int

The latest year covered (always equals currentYear)

The latest year covered (always equals currentYear)

Attributes

def levelAt(year: Int): Double

Get the index level for a specific year.

Get the index level for a specific year.

Value parameters

year

The calendar year

Attributes

Returns

The index level for that year

Throws
NoSuchElementException

if year is not in the index

inline def numYears: Int

Number of years covered by this index

Number of years covered by this index

Attributes

def onLevel(value: Double, fromYear: Int): Double

On-level a single value from fromYear to the current year.

On-level a single value from fromYear to the current year.

Prefer named arguments - an Int value silently widens to Double, so swapping the arguments compiles:

idx.onLevel(value = 1.0, fromYear = 2023)

Value parameters

fromYear

The calendar year of the value

value

The historical value, in fromYear terms

Attributes

Returns

The value in current-year terms

Throws
IllegalArgumentException

if fromYear is earlier than earliestYear

def onLevel(value: Double, fromYear: Int, fallbackFactor: Double): Double

On-level a single value from fromYear to the current year, extrapolating with fallbackFactor per year if fromYear is earlier than the index covers.

On-level a single value from fromYear to the current year, extrapolating with fallbackFactor per year if fromYear is earlier than the index covers.

idx.onLevel(value = 1.0, fromYear = 2015, fallbackFactor = 1.09)

Attributes

def onLevel(values: Array[Double], fromYears: Array[Int]): Array[Double]

Apply on-leveling to an array of values, given their corresponding years.

Apply on-leveling to an array of values, given their corresponding years.

Value parameters

fromYears

The calendar year for each value (same length as values)

values

The historical values to on-level

Attributes

Returns

Array of on-leveled values

Throws
IllegalArgumentException

if any year in fromYears is earlier than earliestYear

def onLevel(values: Array[Double], fromYears: Array[Int], fallbackFactor: Double): Array[Double]

Apply on-leveling to an array of values, extrapolating with fallbackFactor per year for years earlier than the index covers.

Apply on-leveling to an array of values, extrapolating with fallbackFactor per year for years earlier than the index covers.

Attributes

def onLevelFactor(fromYear: Int): Double

The factor which on-levels a value from fromYear to the current year: level(currentYear) / level(fromYear).

The factor which on-levels a value from fromYear to the current year: level(currentYear) / level(fromYear).

Years after currentYear return 1.0.

Value parameters

fromYear

The historical year

Attributes

Throws
IllegalArgumentException

if fromYear is earlier than earliestYear. Use the overload with a fallbackFactor to extrapolate.

def onLevelFactor(fromYear: Int, fallbackFactor: Double): Double

The factor which on-levels a value from fromYear to the current year, extrapolating the index backwards with a constant fallbackFactor growth per year for any years before earliestYear.

The factor which on-levels a value from fromYear to the current year, extrapolating the index backwards with a constant fallbackFactor growth per year for any years before earliestYear.

Value parameters

fallbackFactor

The assumed growth per year before earliestYear (e.g. 1.05 for 5% per year)

fromYear

The historical year

Attributes

def suggestedNewThreshold(reportThreshold: Double, thresholdYear: Int): Double

The reporting threshold in current-year terms, for a threshold that was set in thresholdYear.

The reporting threshold in current-year terms, for a threshold that was set in thresholdYear.

Value parameters

reportThreshold

The threshold, in thresholdYear money

thresholdYear

The year the threshold was set

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product