glm_ai_plus: Fit a Generalized Linear Models on abundance data

View source: R/glm_ai_plus.R

glm_ai_plusR Documentation

Fit a Generalized Linear Models on abundance data

Description

glm_ai_plus returns a GLM model on abundance data. It can run a StepAIC if specified. It runs the GLMs, plot the residuals analysis graphs and return the GLM outputs.

Usage

glm_ai_plus(tableau_ab, parameters, formula_select, summary = FALSE, type = 2)

Arguments

tableau_ab

table of abundance data, extracted from the output of table_pres_abs

parameters

list of parameters to test

formula_select

if "auto", the function select which formula as the lowest AIC. Else, run the selected formula.

summary

To show residuals plots.

type

To study marginal effects with Anova type III in case of interaction

Value

glm_ai_plus can either return the best GLM model based on AIC comparison, or return the outputs of the GLM based on the formula given in formula_select

Examples

data(tableau_sc)
list_param <- c("annee", "saison")
table_ex <- table_pres_abs(tableau_sc, esp="PSEUDOTOLITHUS ELONGATUS", list_param=c("annee", "saison", "strate"), espece_id='nom_taxonomique', var_eff_list=c("surface_chalutee"), catch_col='total_capture', limit=0.0001)
table_ex_abundance <- filter(table_ex, presence==1)
param <- param_use(table_ex_abundance, list_param)
for (i in 1:length(param)){
table_ex_abundance[,param[i]] <- as.factor(table_ex_abundance[,param[i]])
table_ex_abundance[,param[i]] <- droplevels(table_ex_abundance[,param[i]])
contrasts(table_ex_abundance[,param[i]]) <- contr.sum(levels(table_ex_abundance[,param[i]]))
}
glm_ai_plus(table_ex_abundance, param, formula_select = "auto")

polehalieutique/demerstem documentation built on Aug. 4, 2024, 5:12 a.m.