R: Tidying methods for a generalized additive model (gam)

gam_tidiers {broom} | R Documentation

## Tidying methods for a generalized additive model (gam)

### Description

These methods tidy the coefficients of a "gam" object (generalized additive model) into a summary, augment the original data with information on the fitted values and residuals, and construct a one-row glance of the model's statistics.

### Usage

    ## S3 method for class 'gam'
    tidy(x, parametric = FALSE, ...)

    ## S3 method for class 'Gam'
    tidy(x, ...)

    ## S3 method for class 'gam'
    glance(x, ...)

    ## S3 method for class 'Gam'
    glance(x, ...)

### Arguments

`x` | gam or Gam object
`parametric` | logical. Return parametric coefficients (`TRUE`) or information about smooth terms (`FALSE`)?
`...` | extra arguments (not used)

### Details

The "augment" method is handled by lm_tidiers.

### Value

All tidying methods return a data.frame without rownames, whose structure depends on the method chosen.

`tidy.gam` called on an object from the gam package, or an object from the mgcv package with `parametric = FALSE`, returns the tidied output of the parametric ANOVA with one row for each term in the formula. The columns match those in anova_tidiers. `tidy.gam` called on a gam object from the mgcv package with `parametric = TRUE` returns the fixed coefficients.

`glance.gam` returns a one-row data.frame with the columns

`df` | Degrees of freedom used by the coefficients
`logLik` | the data's log-likelihood under the model
`AIC` | the Akaike Information Criterion
`BIC` | the Bayesian Information Criterion
`deviance` | deviance
`df.residual` | residual degrees of freedom

### See Also

lm_tidiers, anova_tidiers

### Examples

    if (require("gam", quietly = TRUE)) {
        data(kyphosis)
        g <- gam(Kyphosis ~ s(Age,4) + Number, family = binomial, data = kyphosis)
        tidy(g)
        augment(g)
        glance(g)
    }

[Package broom version 0.4.4 Index]