snif: Selection of nonlinear interactions by a forward stepwise...

Description Usage Arguments Details Author(s) References Examples

View source: R/snif.R

Description

snif is a greedy forward stepwise selection algorithm that takes nonlinear effects and interactions into account when adding variables. snif follows the strong hereditary principle (for X1:X2 to be included as an interaction, both X1 and X2 both must be already included in the model. snif supports both binary and continuous outcomes.

Usage

1
2
snif(formula, df, type = "linear", method = "BIC", degree = 3,
  maxnv = ncol(df), main.only = NULL, linear.only = NULL)

Arguments

formula

An initial formula for snif to start with. formula supports linear variables, basis spline expansions via bs, and interaction terms via :. It is highly recommended to read the details section of the documentation before trying anything fancy with formula

df

A data.frame containing the data

type

The type of regression to perform. Either "linear" (default) or "logistic"

method

A character argument that specifies the kind of scoring method used to determine which variable to add to the model. supported options are "BIC" (default), "AIC", and "PV" (p.value).

degree

Degree of basis spline expansion for nonlinear effects

maxnv

Max number of variables to add. Default is ncol(df)

main.only

Character vector of variables that are only considered for main effects

linear.only

Character vector of variables that are considered to have only linear effects

Details

snif uses a formula to initialize the model before the forward stepwise stage of the algorithm. If you are not interested in using a non-null initial model, y ~ NULL should do just fine. On the other hand, if you do wish to use an initial model, some care must be taken so snif will be happy.

Basically, there are four valid ways to build snif formulas:

  1. Add a linear main effect, as in y ~ V2

  2. Add a nonlinear main effect, as in y ~ bs(V2)[,-1]. Note that [, -1] is important.

  3. Add a linear and nonlinear main effect, as in y ~ bs(V2). snif will automatically split a bs expansion without an index ([ ,-1]) into linear and nonlinear parts internally.

  4. Add an interaction term, as in y + V2:V3 You may specify interactions between in any combination of 1-3. If you chose to include an interaction of type 3, note that snif will internally decompose the interaction into parts. For example y ~ bs(V2):V3 is equivalent to y ~ V2:V3 + bs(V2)[,-1]:V3

snif formulas can be built out of any linear combination 1-4.

Author(s)

Alexander Rix

References

Narisetty, Naveen N. and Mukherjee, Bhramar and Chen, Yin-Hsiu and Gonzalez, Richard and Meeker, John D. Selection of nonlinear interactions by a forward stepwise algorithm: Application to identifying environmental chemical mixtures affecting health outcomes. Statistics in Medicine. 2019;38(9):1582-1600. 10.1002/sim.8059

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(snif)

# snif contains a synthetic data.frame, snif.df
# if you not want to include any covariates in the initial model, you can
# just use NULL of the right hand side of formula
snif.out <- snif(formula = y ~ NULL, df = snif.df, type = "linear",
                     method = "BIC")

# snif provides a summary method which will extract and summarise the best
# scoring subset
summary(snif.out)

# you can specify an initial model by using the rules explained in the
# details section.
snif.out <- snif(formula = y ~ V2 + V2:V4, df = snif.df, type = "linear",
                     method = "BIC")

# snif also supports binary outcomes. First, we copy snif.df and discretize y
snif.df.bin <- snif.df
snif.df.bin$y <- ifelse(snif.df.bin$y > 5, 1, 0)
snif.out <- snif(formula = y ~ NULL, df = snif.df.bin, type = "logistic",
                     method = "BIC")
summary(snif.out)

umich-cphds/snif documentation built on Nov. 5, 2019, 11:05 a.m.