Models API¶
SARFit¶
sars.SARFit
dataclass
¶
Result of fitting a single SAR model.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
Short model identifier matching R sars function suffix (e.g. 'power'). |
params |
dict[str, float]
|
Fitted parameter values keyed by parameter name. |
r_squared |
float
|
Coefficient of determination in arithmetic space. |
aic |
float
|
Akaike Information Criterion (normal log-likelihood convention). |
aicc |
float
|
AIC corrected for small sample size. |
bic |
float
|
Bayesian Information Criterion. |
n |
int
|
Number of observations used in fit. |
converged |
bool
|
Whether the NLS solver converged. |
data |
DataFrame
|
Original data (columns: area, species). |
predict ¶
Predict species richness for given area value(s).
Fitting functions¶
sars.sar_power ¶
Fit the power law SAR model: S = c * A^z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
References
Arrhenius O (1921) Species and area. Journal of Ecology 9:95-99.
sars.sar_powerR ¶
Fit the power-R SAR model: S = f + c * A^z
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_loga ¶
Fit the logarithmic SAR model: S = c + z * log(A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
References
Gleason HA (1922) On the relation between species and area. Ecology 3:158-162.
sars.sar_linear ¶
Fit the linear SAR model: S = c + m * A
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_epm1 ¶
Fit the extended power model 1: S = c * A^z * exp(d * (log A)^2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_epm2 ¶
Fit the extended power model 2: S = c * A^(z1 * A^z2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_p1 ¶
Fit persistence function 1: S = c * A^z * exp(-d * A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_p2 ¶
Fit persistence function 2: S = c * A^z * exp(-d / A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_koba ¶
Fit the Kobayashi logarithmic model: S = c * log(1 + A/z)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_monod ¶
Fit the Monod model: S = d * A / (c + A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_negexpo ¶
Fit the negative exponential model: S = d * (1 - exp(-z * A))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_asymp ¶
Fit the asymptotic model: S = d - c * exp(-z * A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_ratio ¶
Fit the rational function model: S = (c + z * A) / (1 + d * A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_mmf ¶
Fit the Morgan-Mercer-Flodin model: S = d / (1 + c * A^(-z))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_gompertz ¶
Fit the Gompertz model: S = d * exp(-exp(-z * (A - c)))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_weibull3 ¶
Fit the 3-parameter Weibull model: S = d * (1 - exp(-c * A^z))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_weibull4 ¶
Fit the 4-parameter Weibull model: S = d * (1 - exp(-c * A^z))^f
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|
sars.sar_chapman ¶
Fit the Chapman-Richards model: S = d * (1 - exp(-z * A))^c
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame with columns 'area' and 'species'. |
required |
Returns:
| Type | Description |
|---|---|
SARFit
|
|