sar_linear: Fit the linear model

View source: R/sar_linear.R

sar_linearR Documentation

Fit the linear model

Description

Fit the linear model to SAR data.

Usage

sar_linear(data, normaTest =  'none', homoTest = 'none', homoCor =
  'spearman', verb = TRUE)

Arguments

data

A dataset in the form of a dataframe with two columns: the first with island/site areas, and the second with the species richness of each island/site.

normaTest

The test used to test the normality of the residuals of the model. Can be any of 'lillie' (Lilliefors Kolmogorov-Smirnov test), 'shapiro' (Shapiro-Wilk test of normality), 'kolmo' (Kolmogorov-Smirnov test), or 'none' (no residuals normality test is undertaken; the default).

homoTest

The test used to check for homogeneity of the residuals of the model. Can be any of 'cor.fitted' (a correlation of the residuals with the model fitted values), 'cor.area' (a correlation of the residuals with the area values), or 'none' (no residuals homogeneity test is undertaken; the default).

homoCor

The correlation test to be used when homoTest != "none". Can be any of "spearman" (the default), "pearson", or "kendall".

verb

Whether or not to print certain warnings (default = TRUE).

Details

The model is fitted using linear regression and the lm function. Model validation can be undertaken by assessing the normality (normaTest) and homogeneity (homoTest) of the residuals and a warning is provided in summary.sars if either test is chosen and fails.

A selection of information criteria (e.g. AIC, BIC) are returned and can be used to compare models (see also sar_average).

Value

A list of class 'sars' with the following components:

  • par The model parameters

  • value Residual sum of squares

  • verge Logical code indicating model convergence

  • data Observed data

  • model A list of model information (e.g. the model name and formula)

  • calculated The fitted values of the model

  • residuals The model residuals

  • AIC The AIC value of the model

  • AICc The AICc value of the model

  • BIC The BIC value of the model

  • R2 The R2 value of the model

  • R2a The adjusted R2 value of the model

  • sigConf The model coefficients table

  • observed_shape The observed shape of the model fit

  • asymptote A logical value indicating whether the observed fit is asymptotic

  • normaTest The results of the residuals normality test

  • homoTest The results of the residuals homogeneity test

  • neg_check A logical value indicating whether negative fitted values have been returned

The summary.sars function returns a more useful summary of the model fit results, and the plot.sars plots the model fit.

Examples

data(galap)
fit <- sar_linear(galap)
summary(fit)
plot(fit)

sars documentation built on Dec. 28, 2022, 2:38 a.m.