get_terms {pammtools}R Documentation

Extract the partial effects of non-linear model terms

Description

This function basically creates a new df from data for each term in terms, creating a range from minimum and maximum of the predict(fit, newdata=df, type="terms"). Terms are then stacked to a tidy data frame.

Usage

get_terms(data, fit, terms, ...)

Arguments

data

A data frame containing variables used to fit the model. Only first row will be used.

fit

A fitted object of class gam.

terms

A character vector (can be length one). Specifies the terms for which partial effects will be returned

...

Further arguments passed to seq_range.

Value

A tibble with 5 columns.

Examples

library(survival)
fit <- coxph(Surv(time, status) ~ pspline(karno) + pspline(age), data=veteran)
terms_df <- veteran %>% get_terms(fit, terms = c("karno", "age"))
head(terms_df)
tail(terms_df)

[Package pammtools version 0.5.93 Index]