inst/doc/Varselection_vignette.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(VariableSelection)

## -----------------------------------------------------------------------------
data("dat")
head(dat,5)

## -----------------------------------------------------------------------------
example1 <- modelselect.lm(formula = Y~X1+X2+X3+X4, data = dat)

## -----------------------------------------------------------------------------
head(example1$models)
example1$variables

## -----------------------------------------------------------------------------
example2 <- modelselect.lm(formula = Y~., data = dat)
example2$variables

## -----------------------------------------------------------------------------
example3 <- modelselect.lm(formula = Y~X1*X2+X3+X4+X5+X6, data = dat)
example3$variables

## -----------------------------------------------------------------------------
example5 <- modelselect.lm(formula = Y~X1+X2+X3+X4, data = dat, GA_var = 16, maxiterations = 2000, runs_til_stop = 1000, monitor = TRUE, popSize = 100)

## -----------------------------------------------------------------------------
lm_model <- lm.best(object = example1, method = "models")
lm_model$coefficients

## -----------------------------------------------------------------------------
lm_var <- lm.best(object = example2, method = "variables", threshold = 0.9)

## -----------------------------------------------------------------------------
summary(lm_model)

## -----------------------------------------------------------------------------
data("glmdat")
head(glmdat,5)

## -----------------------------------------------------------------------------
example.glm <- modelselect.glm(formula = Y~., family = "binomial", data = glmdat)
example.glm$variables

## -----------------------------------------------------------------------------
glm_model <- glm.best(object = example.glm, family = "binomial", method = "models", threshold = 0.95)

## -----------------------------------------------------------------------------
summary(glm_model)

Try the VariableSelection package in your browser

Any scripts or data that you put into this service are public.

VariableSelection documentation built on Feb. 17, 2026, 5:07 p.m.