Learn R Programming

DiversityOccupancy (version 1.0.5)

model.diversity: Find the best GLM model explaining the alpha divesity of the species

Description

This function takes a diversityoccu object and heuristically searches for the glm that best explains the alpha diversity of the modelled species.

Usage

model.diversity(DivOcc, method = "h", delta = 2, squared = FALSE)

Arguments

DivOcc
is an object returned by the divesityoccu function of this package
method
The method to be used to explore the candidate set of models. If "h" an exhaustive screening is undertaken. If "g" the genetic algorithm is employed (recommended for large candidate sets). If "l", a very fast exhaustive branch-and-bound algorithm is used. Package leaps must then be loaded, and this can only be applied to linear models with covariates and no interactions.
delta
The number of models that will be returned will be the ones that have a maximum AICc difference with the top model equal to delta.
squared,
if FALSE (Default), only GLMs with linear components will be evaluated; If TRUE, GLMs with both linear and quadratic components will be evaluated. WARNING if squared is TRUE, the number of parameters duplicates and the models grow exponentially, this may result in to many variables for a CPU to compute.

Value

An object with the best fitted model, the coefficients of that model, a table with the top 5 fitted models ranked by AICc and the data used for the model

Details

This function fits every first order glm possible and ranks them by AICc.

See Also

diversityoccu

Examples

Run this code
## Not run: 
# #Load the data
# data("IslandBirds")
# data("Daily_Cov")
# data("siteCov")
# 
# #Model the abundance for  5 bat species and calculate alpha diversity from that
# 
# BirdDiversity <-diversityoccu(pres = IslandBirds, sitecov = siteCov,
# obscov = Daily_Cov,spp =  5, form = ~ Day + Wind + Time + Rain +
# Noise ~ Elev + AgroFo + SecVec + Wetland + Upland)
# 
# #Select the best model that explains diversity using genetic algorithms
# set.seed(123)
# glm.Birdiversity <- model.diversity(BirdDiversity, method = "g")
# 
# #see the best models
# 
# glm.Birdiversity$Best.model
# 
# #plot the response of diversity to individual variables
# 
# plot(glm.Birdiversity, elev)
# 
# #To add the quadratic components of models
# 
# glm.birdiversity <- model.diversity(BirdDiversity , method = "g", squared = TRUE)
# 
# responseplot.diver(glm.birdiversity, Elev)
# ## End(Not run)

Run the code above in your browser using DataLab