augment.lmFit: Augment function for class 'lmFit'

View source: R/augment.R

augment.lmFitR Documentation

Augment function for class lmFit

Description

Generates residuals and fitted values of a fitted lmFit object.

Usage

## S3 method for class 'lmFit'
augment(x, ...)

Arguments

x

A lmFit object.

...

Other arguments not currently used.

Value

A tibble.

Examples

library(dplyr)
library(tibble)
library(tidyr)
library(tsibble)

# Simulate data
n = 1005
set.seed(123)
sim_data <- tibble(x_lag_000 = runif(n)) |>
  mutate(
    # Add x_lags
    x_lag = lag_matrix(x_lag_000, 5)) |>
  unpack(x_lag, names_sep = "_") |>
  mutate(
    # Response variable
    y = (0.9*x_lag_000 + 0.6*x_lag_001 + 0.45*x_lag_003)^3 + rnorm(n, sd = 0.1),
    # Add an index to the data set
    inddd = seq(1, n)) |>
  drop_na() |>
  select(inddd, y, starts_with("x_lag")) |>
  # Make the data set a `tsibble`
  as_tsibble(index = inddd)

# Predictor variables
linear.vars <- colnames(sim_data)[3:8]

# Model fitting
lmModel <- model_lm(data = sim_data,
                    yvar = "y",
                    linear.vars = linear.vars)
# Obtain residuals and fitted values
augment(lmModel)


smimodel documentation built on April 8, 2026, 5:06 p.m.