ga_anova: ANOVA table from a generalised additive model ('gam')

View source: R/ga_anova.R

ga_anovaR Documentation

ANOVA table from a generalised additive model (gam)

Description

One of two functions for fitting generalised additive models (gam) with the mgcv package. It will use the gam() function in mgcv for ANOVA designs with up to two categorical fixed factors (with two or more levels; Fixed_Factor), and exactly one factor is a continuous variable (e.g. time), which is called Smooth_Factor.

  1. ga_model

  2. ga_anova

Usage

ga_anova(
  data,
  Y_value,
  Fixed_Factor,
  Smooth_Factor,
  Random_Factor = NULL,
  Nodes = NULL,
  ...
)

Arguments

data

a data frame where categorical independent variables are converted to factors using as.factor() first. The function will throw errors without this.

Y_value

name of column containing quantitative (dependent) variable, provided within "quotes".

Fixed_Factor

name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes". Convert to factors first with as.factor.

Smooth_Factor

the continuous variable to fit smoothly with a basis function, provided within "quotes" (only 1 Smooth_Factor allowed).

Random_Factor

name(s) of random factors to be provided in "quotes" (only 1 Random_Factor allowed). Convert to factor with as.factor first.

Nodes

number of nodes (the parameter k in gam).

...

any additional variables to pass on to gam or anova

Details

A smooth function is fitted with factor-wise smooth basis function (⁠by = ⁠). A default value for number of nodes (the argument k in gam) may work, but a specific number can be provided using the Nodes argument. The model is fit using the REML method. When two categorical fixed factors are provided, an interaction term is included for main effects and smooth basis functions.

If a Random_Factor is also provided, it is fitted using bs = "re" smooth.

Value

ANOVA table of class "anova" and "data.frame".

Examples

#with zooplankton data
ga_anova(data = data_zooplankton,
Y_value = "log(density_adj)",
Fixed_Factor = "taxon",
Smooth_Factor = "day")



grafify documentation built on May 29, 2024, 3:49 a.m.

Related to ga_anova in grafify...