lin_pow: Fit the log-log version of the power model

View source: R/mod_linear_power.R

lin_powR Documentation

Fit the log-log version of the power model

Description

Fit the log-log version of the power model to SAR data and return parameter values, summary statistics and the fitted values.

Usage

lin_pow(data, con = 1, logT = log, compare = FALSE, normaTest =
  "none", homoTest = "none", homoCor = "spearman")

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.

con

The constant to add to the species richness values in cases where one of the islands has zero species.

logT

The log-transformation to apply to the area and richness values. Can be any of log(default), log2 or log10.

compare

Fit the standard (non-linear) power model and return the z-value for comparison (default: compare = FALSE).

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".

Details

A check is made for any islands with zero species. If any zero species islands are found, a constant (default: con = 1) is added to each species richness value to enable log transformation. Natural logarithms are used as default, but log2 and log10 can be used instead using the logT argument.

The compare argument can be used to compare the c and z values calculated using the log-log power model with that calculated using the non-linear power model. Note that the log-log function returns log(c).

Value

A list of class "sars" with up to seven elements. The first element is an object of class 'summary.lm'. This is the summary of the linear model fit using the lm function and the user's data. The second element is a numeric vector of the model's fitted values, and the third contains the log-transformed observed data. The remaining elements depend on the function arguments selected and can include the results of the non-linear power model fit, the log-transformation function used (i.e. logT) and the results of any residuals normality and heterogeneity tests.

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

Examples

data(galap)
fit <- lin_pow(galap, con = 1)
summary(fit)
plot(fit)

txm676/mmSAR2 documentation built on Nov. 21, 2024, 5:03 a.m.