Use GAM analysis to compute residuals. Relies on mgcv::gam to perform general additive model.

createResiduals(
  df,
  dep,
  residualModel = "doy_flw_sal",
  analySpec = analySpec,
  gamTable = FALSE,
  gamPlot = FALSE,
  flow.detrended = NA,
  salinity.detrended = NA,
  width = 10,
  height = 3.5,
  folder_r = "pltResiduals",
  ProjRoot
)

Arguments

df

data frame

dep

variable

residualModel

which gam formula is used to compute. Default = 'doy_flw_sal'

analySpec

analytical specifications

gamTable

gam table setting (set to FALSE to turn off table output) Default = FALSE

gamPlot

gam plot setting (set to FALSE to turn off plotting) Default = FALSE

flow.detrended

data generated by detrended.flow. Default = NA

salinity.detrended

data generated by detrended.flow. Default = NA

width

width of png figure (inches). Default = 10

height

height of png figure (inches). Default = 3.5

folder_r

folder to store residual plots

ProjRoot

Root folder for project.

Value

Returns df with appended column of data