gam_predict_newdata: Testing predictive power for GAMs

Description Usage Arguments Examples

View source: R/gam_predict_newdata.R

Description

Function builds GAM and dredges saturated models, fixed to maximum of 3 covariates to prevent overfitting. Then predicts response against new predictor covariates 1. the top-ranked model (AICc > 2 lower than candidate models) OR 2. across a top-ranking model set (AICc < 7 of top-ranked model)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gam_predict_newdata(
  dataset,
  newdataset,
  exp.names,
  indicator,
  family,
  base_k = -1,
  smoother = "cr",
  n.param.max = 3
)

Arguments

dataset

= dataset containing y and all x covariates. should be scaled and centered (mean = 0, sd = 1)

newdataset

= generating predictions with 'newdata'. should be scaled + centered (mean = 0, sd = 1)

exp.names

= explanatory covariate names, passed as vector of characters

indicator

= y variable of interest (character)

family

= GAM family distribution, takes 'gaussian' or 'Gamma'

base_k

= number of knots for each smoother term. Default = -1, mgcv uses generalized cross-validation

smoother

= cubic regression spline method (cr is default)

n.param.max

= maximum number of parameters included in each reduced model

Examples

1

jpwrobinson/funk documentation built on Nov. 21, 2021, 11:23 p.m.