extract_model_data: Extract model data

View source: R/model_get_data.R

extract_model_dataR Documentation

Extract model data

Description

[Experimental]

extract_model_data() retrieves the modelling data and metadata from fitted models. It works for objects of class "glm", as well as objects produced by refitting procedures ("refitsmooth" or "refitrestricted").

model_data() is kept as a deprecated compatibility wrapper.

Usage

extract_model_data(x)

Arguments

x

An object of class "glm", "refitsmooth", or "refitrestricted".

Details

For GLM objects, the function returns the model data and attaches attributes with the response, rating factors, terms object, and any weights or offsets.

For refit objects, the function removes auxiliary columns used during smoothing or restriction and attaches attributes with rating factors, merged smooths, restrictions, and offsets.

Value

A data.frame of class "model_data" with additional attributes:

  • response — response variable in the model;

  • rf — names of risk factors in the model;

  • offweights — weight and offset variables if present;

  • terms — model terms object for plain GLMs;

  • mgd_rst, mgd_smt — merged restrictions/smooths for refit objects;

  • new_nm, old_nm — new and old column names for refit objects.

Author(s)

Martin Haringa

Examples

## Not run: 
library(insurancerating)

pmodel <- glm(
  breaks ~ wool + tension,
  data = warpbreaks,
  family = poisson(link = "log")
)

extract_model_data(pmodel)

## End(Not run)


insurancerating documentation built on July 30, 2026, 5:09 p.m.