Learn R Programming

tidychangepoint (version 1.0.0)

tbl_coef: Format the coefficients from a linear model as a tibble

Description

Format the coefficients from a linear model as a tibble

Usage

tbl_coef(mod, ...)

Value

A tibble::tbl_df object containing the fitted coefficients.

Arguments

mod

An lm model object

...

currently ignored

Examples

Run this code
# Convert a time series into a data frame with indices
ds <- data.frame(y = as.ts(CET), t = 1:length(CET))

# Retrieve the coefficients from a null model
tbl_coef(lm(y ~ 1, data = ds))

# Retrieve the coefficients from a two changepoint model
tbl_coef(lm(y ~ (t >= 42) + (t >= 81), data = ds))

# Retrieve the coefficients from a trendshift model
tbl_coef(lm(y ~ poly(t, 1, raw = TRUE) * (t >= 42) + poly(t, 1, raw = TRUE) * (t >= 81), data = ds))

# Retrieve the coefficients from a quadratic model
tbl_coef(lm(y ~ poly(t, 2, raw = TRUE) * (t >= 42) + poly(t, 2, raw = TRUE) * (t >= 81), data = ds))

Run the code above in your browser using DataLab