Variable selection with multGLM

The ‘multGLM‘ function in the ‘fuzzySim‘ R package automatically calculates generalized linear models for one or more species, with a range of options for variable selection. However, you may want to build your final models with other methods (e.g. multimodel-inference with packages ‘glmulti’ or ‘MuMIn’, or other modelling algorithms such as those implemented in packages ‘dismo’, ‘biomod2’ or ‘sdm’), but still previously apply some of the variable selection methods implemented in ‘multGLM’. Since ‘fuzzySim’ package version 2.2.3 (currently available on R-Forge), function ‘multGLM’ includes an additional item in the output: a list of character vectors naming the variables selected for each model, following the specified criteria. So, you can use ‘multGLM’ with your desired selection criteria and then use the selected variables elsewhere, as below:


library(fuzzySim) # >2.2.3
data(rotif.env)
names(rotif.env)

# make models for 2 of the species in rotif.env using some selection criteria:

mods_multGLM <- multGLM(rotif.env, sp.cols = 18:19, var.cols = 5:17, id.col = 1,
FDR = TRUE, corSelect = TRUE, cor.thresh = 0.8, step = FALSE, trim = FALSE)
mods_multGLM$variables

# now use the selected variables elsewhere:

library(glmulti)
mod_glmulti_Abrigh <- glmulti(y = "Abrigh", xr = mods_multGLM$variables[["Abrigh"]], data = rotif.env, level = 1, method = "h", crit = "aic", fitfunction = "glm", family = binomial)
mod_glmulti_Abrigh
summary(mod_glmulti_Abrigh@objects[[1]])

Also, the ‘multGLM‘ function (since fuzzySim version 2.2.3) now also accepts column names (not only index numbers) as the ‘sp.cols‘, ‘var.cols‘ and ‘id.col‘ arguments.

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s