lookup_interpolated_value: Look up an interpolated rating-table value

View source: R/lookup.R

lookup_interpolated_valueR Documentation

Look up an interpolated rating-table value

Description

Select the applicable interpolation curve for a rating record and calculate a linearly interpolated value from the surrounding table points.

Usage

lookup_interpolated_value(
  row,
  coverage,
  plan,
  term_name,
  lookup_var,
  bounds = "error"
)

Arguments

row

A one-row data frame containing the rating record.

coverage

A character string identifying the coverage being rated.

plan

A rating_plan object created by new_rating_plan().

term_name

A character string identifying the rating term to look up.

lookup_var

A character string naming the numeric input variable used as the interpolation axis.

bounds

A character string controlling values outside the available interpolation range. Supported values are "error", "clamp", and "extrapolate".

Value

A list containing the interpolated value and supporting trace information, including the lower and upper levels, values, interpolation weight, and factor-row identifiers.

Examples

factor_table <- data.frame(
  state = c("IL", "IL"),
  charter = c("STD", "STD"),
  book_segment = c("new", "new"),
  rate_eff_date = as.Date(c("2025-01-01", "2025-01-01")),
  rate_exp_date = as.Date(c("2025-12-31", "2025-12-31")),
  coverage = c("BI", "BI"),
  term_name = c("limit_factor", "limit_factor"),
  term_value = c(1.00, 1.20),
  variable1 = c("limit_value", "limit_value"),
  level1 = c("100", "200"),
  stringsAsFactors = FALSE
)

rating_spec <- data.frame(
  step_number = 1,
  term_name = "limit_factor",
  value_source = "interpolated_lookup",
  calculation_type = "multiplicative",
  lookup_var = "limit_value",
  stringsAsFactors = FALSE
)

plan <- new_rating_plan(
  factor_table = factor_table,
  rating_spec = rating_spec,
  coverages = "BI"
)

policy <- data.frame(
  policy_id = "P1",
  state = "IL",
  charter = "STD",
  book_segment = "new",
  rating_date = as.Date("2025-06-01"),
  limit_value = 150,
  stringsAsFactors = FALSE
)

answer <- lookup_interpolated_value(
  row = policy,
  coverage = "BI",
  plan = plan,
  term_name = "limit_factor",
  lookup_var = "limit_value"
)

answer$value
answer$interpolation_weight

ratingtables documentation built on Sept. 6, 2026, 1:06 a.m.