Learn R Programming

broom (version 0.3.4)

smooth.spline_tidiers: tidying methods for smooth.spline objects

Description

This combines the original data given to smooth.spline with the fit and residuals

Usage

## S3 method for class 'smooth.spline':
augment(x, data = x$data, ...)

## S3 method for class 'smooth.spline': glance(x, ...)

Arguments

x
a smooth.spline object
data
defaults to data used to fit model
...
not used in this method

Value

  • augment returns the original data with extra columns:
  • .fittedFitted values of model
  • .residResiduals
  • glance returns one row with columns
  • sparsmoothing parameter
  • lambdachoice of lambda corresponding to spar
  • dfequivalent degrees of freedom
  • critminimized criterion
  • pen.critpenalized criterion
  • cv.critcross-validation score

Details

No tidy method is provided for smooth.spline objects.

Examples

Run this code
spl <- smooth.spline(mtcars$wt, mtcars$mpg, df = 4)
head(augment(spl, mtcars))
head(augment(spl))  # calls original columns x and y

library(ggplot2)
ggplot(augment(spl, mtcars), aes(wt, mpg)) +
    geom_point() + geom_line(aes(y = .fitted))

Run the code above in your browser using DataLab