lm_filter: Linear model filter

View source: R/filters.R

lm_filterR Documentation

Linear model filter


Linear models are fitted on each predictor, with inclusion of variable names listed in force_vars in the model. Predictors are ranked by Akaike information criteria (AIC) value, or can be filtered by the p-value on the estimate of the coefficient for that predictor in its model.


  force_vars = NULL,
  nfilter = NULL,
  p_cutoff = NULL,
  rsq_cutoff = NULL,
  type = c("index", "names", "full")



Numeric or integer response vector


Matrix of predictors. If x is a data.frame it will be turned into a matrix. But note that factors will be reduced to numeric values, but a full design matrix is not generated, so if factors have 3 or more levels, it is recommended to convert x into a design (model) matrix first.


Vector of column names x which are incorporated into the linear model.


Number of predictors to return. If NULL all predictors with p-values < p_cutoff are returned.


p-value cut-off. P-values are calculated by t-statistic on the estimated coefficient for the predictor being tested.


r^2 cutoff for removing predictors due to collinearity. Default NULL means no collinearity filtering. Predictors are ranked based on AIC from a linear model. If 2 or more predictors are collinear, the first ranked predictor by AIC is retained, while the other collinear predictors are removed. See collinear().


Type of vector returned. Default "index" returns indices, "names" returns predictor names, "full" returns a matrix of p values.


Integer vector of indices of filtered parameters (type = "index") or character vector of names (type = "names") of filtered parameters in order of linear model AIC. Any variables in force_vars which are incorporated into all models are listed first. If type = "full" a matrix of AIC values, sigma, the residual standard error (see summary.lm), t-statistic and p-values for the tested predictor is returned.

nestedcv documentation built on Dec. 5, 2022, 5:25 p.m.