Skip to contents

Extracts the model constant term, the model intercept, from a fitted model object.

Usage

model_constant(model)

Arguments

model

a fitted model for which a coef() method exists

Examples

# \dontshow{
op <- options(digits = 4)
# }
load_mgcv()

# simulate a small example
df <- data_sim("eg1", seed = 42)

# fit the GAM
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")

# extract the estimate of the constant term
model_constant(m)
#> [1] 7.495
# same as coef(m)[1L]
coef(m)[1L]
#> (Intercept) 
#>       7.495 

# \dontshow{
options(op)
# }