Forecast model configurations¶
AR1
¶
- class ledger_analytics.AR1(id: str, name: str, model_type: str, config: dict[str, Any] | None, model_class: str, endpoint: str, requester: Requester, asynchronous: bool = False)¶
AR1.
This model implements, by default, a Bayesian autoregressive lag-1 forecasting model, with the form:
\[\begin{split}\mathrm{LR}_{i} &\sim \mathrm{Gamma}(\eta_{i}, \sigma_{i}^2)\\ \eta_{i} &= (1 - \phi_{\mathrm{reversion}}) \mathrm{LR}_{\mathrm{target}} + \phi_{\mathrm{reversion}} \mathrm{LR}_{i - 1}\\ \sigma_{i}^2 &= \sigma_{\mathrm{base}} + \sigma_{\mathrm{obs}} / \mathrm{EP}_i\end{split}\]See the model-specific documentation in the User Guide for more details.
The fit and predict configurations are controlled by
Config
andPredictConfig
classes, respectively.- class Config(*, loss_family: ~typing.Annotated[~typing.Literal['Gamma', 'Lognormal', 'Normal', 'InverseGaussian'], ~pydantic.functional_validators.BeforeValidator(func=~ledger_analytics.config.<lambda>, json_schema_input_type=PydanticUndefined)] = 'Gamma', loss_definition: ~typing.Literal['paid', 'reported', 'incurred'] = 'reported', recency_decay: str | float | None = None, priors: dict[str, list[float] | float] | None = None, autofit_override: dict[str, float | int | None] = None, prior_only: bool = False, seed: int | None = None)¶
AR1 model configuration class.
- loss_family¶
the likelihood family to use. One of
"Gamma"
,"Lognormal"
,"Normal"
or"InverseGaussian"
. Defaults to"Gamma"
. See theLossFamily
type hint class inledger_analytics.config
.- Type:
Literal[‘Gamma’, ‘Lognormal’, ‘Normal’, ‘InverseGaussian’]
- loss_definition¶
the field to model in the triangle. One of
"paid"
"reported"
or"incurred"
.- Type:
Literal[‘paid’, ‘reported’, ‘incurred’]
- recency_decay¶
geometric decay parameter to downweight earlier diagonals (see Modeling rationale… section in the User Guide). Defaults to 1.0 for no geometric decay. Can be
"lookup"
to choose based online_of_business
.- Type:
str | float | None
- priors¶
dictionary of priors. Defaults to
None
to use the default priors. See the DefaultPriors class for default (non line-of-business) priors.- Type:
dict[str, list[float] | float] | None
- autofit_override¶
override the MCMC autofitting procedure arguments. See the documentation for a fully description of options in the User Guide.
- Type:
dict[str, float | int | None]
- prior_only¶
should a prior predictive simulation be run?
- Type:
bool
- seed¶
Seed to use for model sampling. Defaults to
None
, but it is highly recommended to set.- Type:
int | None
- class DefaultPriors(value)¶
Default priors for AR1.
Attributes:
SSM
¶
- class ledger_analytics.SSM(id: str, name: str, model_type: str, config: dict[str, Any] | None, model_class: str, endpoint: str, requester: Requester, asynchronous: bool = False)¶
SSM (State Space Model).
This model is a, by default, Bayesian state space model or Bayesian structural time series model similar to a local linear trend model with mean reversion (with drift) and a ‘momentum’ term which is analogous to a moving average lag-1 component with decay. The model has the form:
\[\begin{split}\mathrm{LR}_{i} &\sim \mathrm{Gamma}(\exp(\eta_{i}), \sigma_{i}^2)\\ \eta_{i} &= (1 - \phi_{\mathrm{reversion}}) \mathrm{LR}_{\mathrm{target}} + \phi_{\mathrm{reversion}} \eta_{i - 1} + \zeta_{i-1} + z_{i} \sqrt{\epsilon_{\mathrm{latent}}}\\ \zeta_{i} &= \gamma_{\mathrm{momentum}} (\zeta_{i-1} + z_{i} \sqrt{\epsilon_{\mathrm{latent}}})\\ \sigma_{i}^2 &= \exp(\sigma_{\mathrm{base}})^2 + \exp(\sigma_{\mathrm{obs}})^2 / \sqrt{\mathrm{UEP}_i}\end{split}\]where \(\mathrm{UEP}\) is used earned premium as, by default, the Cape Cod method is used. See the model-specific documentation in the User Guide for more details.
The fit and predict configurations are controlled by
Config
andPredictConfig
classes, respectively.- class Config(*, loss_family: ~typing.Annotated[~typing.Literal['Gamma', 'Lognormal', 'Normal', 'InverseGaussian'], ~pydantic.functional_validators.BeforeValidator(func=~ledger_analytics.config.<lambda>, json_schema_input_type=PydanticUndefined)] = 'Gamma', loss_definition: ~typing.Literal['paid', 'reported', 'incurred'] = 'reported', include_mean_reversion: bool = True, include_momentum: bool = True, use_cape_cod: bool = True, use_measurement_error: bool = True, period_years: float = 1.0, recency_decay: str | float | None = None, line_of_business: str | None = None, priors: dict[str, list[float] | float] | None = None, informed_priors_version: str | None = None, autofit_override: dict[str, float | int | None] = None, prior_only: bool = False, seed: int | None = None)¶
SSM model configuration class.
- loss_family¶
the likelihood family to use. One of
"Gamma"
,"Lognormal"
,"Normal"
or"InverseGaussian"
. Defaults to"Gamma"
. See theLossFamily
type hint class inledger_analytics.config
.- Type:
Literal[‘Gamma’, ‘Lognormal’, ‘Normal’, ‘InverseGaussian’]
- loss_definition¶
the field to model in the triangle. One of
"paid"
"reported"
or"incurred"
.- Type:
Literal[‘paid’, ‘reported’, ‘incurred’]
- include_mean_reversion¶
whether to include mean reversion on the latent loss ratios (AR1).
- Type:
bool
- include_momentum¶
whether to include momentum on the latent loss ratios (MA1).
- Type:
bool
- use_cape_cod¶
Whether to use the Cape Cod method for down-weighting more recent, greener experience periods based on the ATU.
- Type:
bool
- use_measurement_error¶
Whether to use measurement errors on the loss ratio inputs. Setting both
use_cape_cod
anduse_measurement_error
is almost always a bad idea.- Type:
bool
- period_years¶
Number of years in each period - 0.25 for quarterly, etc. If supplied along with
line_of_business
, will convert LOB priors as needed.- Type:
float
- recency_decay¶
geometric decay parameter to down-weight earlier diagonals (see Modeling rationale… section in the User Guide). Defaults to 1.0 for no geometric decay. Can be
"lookup"
to choose based online_of_business
.- Type:
str | float | None
- line_of_business¶
Line of business used to specify informed priors. Must be provided if
informed_priors_version
is notNone
.- Type:
str | None
- priors¶
dictionary of priors. Defaults to
None
to use the default priors. See the DefaultPriors class for default (non line-of-business) priors.- Type:
dict[str, list[float] | float] | None
- informed_priors_version¶
If
line_of_business
is set, the priors are based on Ledger Investing’s proprietary values derived from industry data."latest"
uses priors derived from the most recent industry data. Defaults toNone
.- Type:
str | None
- autofit_override¶
override the MCMC autofitting procedure arguments. See the documentation for a fully description of options in the User Guide.
- Type:
dict[str, float | int | None]
- prior_only¶
should a prior predictive simulation be run?
- Type:
bool
- seed¶
Seed to use for model sampling. Defaults to
None
, but it is highly recommended to set.- Type:
int | None
- class DefaultPriors(value)¶
Default priors for SSM.
Attributes:
TraditionalGCC
¶
- class ledger_analytics.TraditionalGCC(id: str, name: str, model_type: str, config: dict[str, Any] | None, model_class: str, endpoint: str, requester: Requester, asynchronous: bool = False)¶
TraditionalGCC.
This model implements the Generalized Cape Cod model with the form:
\[\begin{split}\widehat{\mathrm{LR}}_i &= \frac{\sum_{k=1}^N \mathrm{LR}_k \cdot \mathrm{UEP}_k \cdot \beta^{\lvert k - i\rvert}}{\sum_{k=1}^N \mathrm{UEP}_k \cdot \beta^{\lvert k - i\rvert}}\\ \mathrm{UEP}_i &= \mathrm{EP}_i \frac{\mathrm{LR}_{\text{obs},i}}{\mathrm{LR}_{i}}\\ \beta &= \text{user input} \in (0, 1]\end{split}\]See the model-specific documentation in the User Guide for more details.
The fit and predict configurations are controlled by
Config
andPredictConfig
classes, respectively.- class Config(*, loss_definition: Literal['paid', 'reported', 'incurred'] = 'reported', recency_decay: str | float | None = None)¶
TraditionalGCC model configuration class.
- loss_definition¶
the field to model in the triangle. One of
"paid"
"reported"
or"incurred"
.- Type:
Literal[‘paid’, ‘reported’, ‘incurred’]
- recency_decay¶
geometric decay parameter to downweight earlier diagonals (see Modeling rationale… section in the User Guide). Defaults to 1.0 for no geometric decay. Can be
"lookup"
to choose based online_of_business
.- Type:
str | float | None
- class DefaultPriors(value)¶
Default priors for TraditionalGCC.
Attributes: