predict.adlp {ADLP}R Documentation

Accident and Development period Adjusted Linear Pools (ADLP) Functions

Description

Family of functions used to support ADLP inference and prediction.

Usage

## S3 method for class 'adlp'
predict(object, newdata = NULL, ...)

adlp_dens(adlp, newdata, model = c("train", "full"))

adlp_logS(adlp, newdata, model = c("train", "full"), epsilon = 1e-06)

adlp_CRPS(
  adlp,
  newdata,
  response_name,
  model = c("train", "full"),
  lower = 1,
  upper = NULL,
  sample_n = 2000
)

adlp_simulate(n, adlp, newdata = NULL)

Arguments

object

Object of class adlp

newdata

Data to perform the function on

...

Other parameters to pass onto predict

adlp

Object of class adlp

model

Whether the train or full model should be used in function

epsilon

Offset added to the density before calculating the log

response_name

The column name of the response variable; in string format

lower

The lower limit to calculate CRPS; the default value is set to be 1

upper

The upper limit to calculate CRPS; the default value is set to be twice the maximum value of the response variable in the dataset

sample_n

The number of evenly spaced values to sample between lower and upper range of numeric integration used to calculate CRPS. This sample function is designed to constrain memory usage during the computation of CRPS, particularly when dealing with large response variables.

n

number of simulations

Details

Predicts the central estimates based on the ADLP component models and weights.

Calculates the probability density ad each point, given newdata.

Calculates the log score, which is the log of the probability density, with an offset epsilon to handle zero densities. Log Score is a strictly proper scoring rule. For full discussion of the mathematical details and advantages of Log Score, one might refer to Gneiting and Raftery (2007)

Continuously Ranked Probability Score (CRPS) is calculated for each data point. lower and upper are used as limits when approximating the integral. CRPS is a strictly proper scoring rule. For full discussion of the mathematical details and advantages of CRPS, one might refer to Gneiting and Raftery (2007). The CRPS function has been discretized in this context to ensure adaptability to various distributions. For details, one might refer to Gneiting and Ranjan (2011)

Simulations of ADLP predictions, given component models and ADLP weights.

Value

data.frame of results, where the first and second columns correspond to the ⁠$origin⁠ and ⁠$dev⁠ columns from the triangles. An index column for simulation # is also included when simulating ADLP.

References

Gneiting, T., Raftery, A. E., 2007. Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association 102 (477), 359–378.

Gneiting, T., Ranjan, R., 2011. Comparing density forecasts using threshold-and quantile-weighted scoring rules. Journal of Business & Economic Statistics 29 (3), 411–422.

Examples

data(test_adlp_component)
test_component1 <- test_adlp_component
test_component2 <- test_adlp_component
test_components <- adlp_components(
    component1 = test_component1,
    component2 = test_component2
)

newdata <- test_component1$model_train$data

test_adlp <- adlp(test_components, newdata = newdata,
    partition_func = adlp_partition_ap, tri.size = 40, size = 3)

test_adlp_dens <- adlp_dens(test_adlp, newdata, "full")

data(test_adlp_component)
test_component1 <- test_adlp_component
test_component2 <- test_adlp_component
test_components <- adlp_components(
    component1 = test_component1,
    component2 = test_component2
)

newdata <- test_component1$model_train$data

test_adlp <- adlp(test_components, newdata = newdata,
    partition_func = adlp_partition_ap, tri.size = 40, size = 3)

test_adlp_logs <- adlp_logS(test_adlp, newdata, "full")

data(test_adlp_component)
test_component1 <- test_adlp_component
test_component2 <- test_adlp_component
test_components <- adlp_components(
    component1 = test_component1,
    component2 = test_component2
)

newdata <- test_component1$model_train$data

test_adlp <- adlp(test_components, newdata = newdata,
    partition_func = adlp_partition_ap, tri.size = 40, size = 3)

test_adlp_crps <- adlp_CRPS(test_adlp, newdata, "full", response_name = "claims", sample_n = 100)

data(test_adlp_component)
test_component1 <- test_adlp_component
test_component2 <- test_adlp_component
test_components <- adlp_components(
    component1 = test_component1,
    component2 = test_component2
)

newdata <- test_component1$model_train$data

test_adlp <- adlp(test_components, newdata = newdata,
    partition_func = adlp_partition_ap, tri.size = 40, size = 3)

test_adlp_sim <- adlp_simulate(10, test_adlp, newdata=newdata)


[Package ADLP version 0.1.0 Index]