This function is used to create a list of linear models using the lm() function with species richness (SR) as the response variable. Requires the function stndrd() from the 'caribmacro' package

sr_LM(
  SR,
  data,
  x_vars,
  geo_group,
  area = NULL,
  standardize = TRUE,
  log_sr = TRUE,
  log_area = FALSE,
  sq_area = FALSE,
  intercept = TRUE,
  complete.case = FALSE
)

Arguments

SR

A data frame in the format that is returned by SR_geo() that holds the species richness values for each species group and geographic feature of interest.

data

A data frame that holds the explanatory variables for each geographic feature of interest.

x_vars

A character or vector equal to the column name(s) in 'data' that hold the explanatory variables of interest.

geo_group

A character equal to the column name in 'SR' and 'data' in which the geographic feature names are stored. This needs to be equal for both the 'SR' and 'data' data frames.

area

Optional. A character or vector equal to the column name in 'data' that holds the area of each geographic feature. This argument is required if the log_area = TRUE and/or sq_area = TRUE.

standardize

Logical. If TRUE then the explanatory variables are standardized by mean centering and dividing by the standard deviation.

log_sr

Logical. If TRUE then the species richness is transformed by log(SR+1)

log_area

Logical. If TRUE then the geographic area is log transformed by log(area)

sq_area

Logical. If TRUE then the geographic area is squared (i.e. area^2). NOTE: if log_area = TRUE then this option will square log(area).

intercept

Logical. If TRUE (default), then the y-intercept is estimated. If FALSE, then the y-intercept is set to 0.

complete.case

Logical. If TRUE only complete cases will be included in the models. This argument should be set to TRUE if models will be passed to AIC_analysis(). Also, if TRUE then the data used for each model will be exported in the list for use in AIC_analysis().

Examples

if (FALSE) {

library(here)
library(reshape)

dat <- read.csv(file.path(here(), 'data_raw', 'IBT_Herp_Records_v6.csv'), header=TRUE)
geo <- read.csv(file.path(here(), 'data_raw', 'bank_data.csv'), header=TRUE)

coms <- com_matrix(species = "binomial",
                   geo_group = "bank",
                   taxa_group = "class",
                   status = "bnk_status",
                   stat_levels = c("N", "E"),
                   total = TRUE,
                   data = dat)

SR <- SR_geo(data = coms, geo_group = "bank")

## Requires the function stndrd()
lm.sr <- sr_LM(SR = SR,
               data = geo,
               x_vars = c('area', 'isoPC1', 'isoPC2'),
               geo_group = 'bank',
               area = 'area',
               log_area = TRUE,
               sq_area = TRUE,
               complete.case = TRUE)

}