Description Usage Arguments Details Author(s) References Examples
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.
1 2 |
formula |
An initial formula for |
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 |
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 |
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:
Add a linear main effect, as in y ~ V2
Add a nonlinear main effect, as in y ~ bs(V2)[,-1]
. Note
that [, -1]
is important.
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.
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.
Alexander Rix
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
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.