fix_offset: Fix the names of a data frame containing an offset variable.

fix_offsetR Documentation

Fix the names of a data frame containing an offset variable.

Description

Identifies which variable, if any, is the model offset, and fixed the name such that offset(foo(var)) is converted to var, and possibly sets the values of that variable to offset_val.

Usage

fix_offset(model, newdata, offset_val = NULL)

Arguments

model

a fitted GAM.

newdata

data frame; new values at which to predict at.

offset_val

numeric, optional; if provided, then the offset variable in newdata is set to this constant value before returning newdata

Value

The original newdata is returned with fixed names and possibly modified offset variable.

Author(s)

Gavin L. Simpson

Examples

load_mgcv()

df <- data_sim("eg1", n = 400, dist = "normal", seed = 2)
m <- gam(y ~ s(x0) + s(x1) + offset(x2), data = df, method = "REML")
names(model.frame(m))
names(fix_offset(m, model.frame(m), offset_val = 1L))

gratia documentation built on Feb. 16, 2023, 10:40 p.m.