psv_LM.Rd
This function is used to create a list of linear models using the lm()
function
with phylogenetic species variability (PSV) as the response variable.
Requires the function stndrd()
from the 'caribmacro' package
psv_LM(
PSV,
data,
x_vars,
geo_group,
area = NULL,
standardize = TRUE,
log_area = FALSE,
sq_area = FALSE,
complete.case = FALSE
)
A data frame in the format that is returned in the first slot of the result of
PSV_geo()
that holds the PSV values for each species group and geographic feature
of interest.
A data frame that holds the explanatory variables for each geographic feature of interest.
A character or vector equal to the column name(s) in 'data' that hold the explanatory variables of interest.
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.
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
.
Logical. If TRUE
then the explanatory variables are standardized by
mean centering and dividing by the standard deviation.
Logical. If TRUE
then the geographic area is log transformed by log(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).
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()
.
if (FALSE) {
library(here)
library(reshape)
library(phyr)
dat <- read.csv(file.path(here(), 'data_raw', 'IBT_Herp_Records_final.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)
PSV <- PSV_geo(data = coms, geo_group = "bank")
## Requires the function stndrd()
lm.psv <- PSV_lm(PSV = PSV[['PSV']],
data = geo,
x_vars = c('area', 'isoPC1', 'isoPC2'),
geo_group = 'bank',
area = 'area',
log_area = TRUE,
complete.case = TRUE)
}