fitweibull {cardidates} R Documentation

## Fit Four or Six Parametric Weibull Functions

### Description

Fit a four- or six-parametric Weibull function to environmental data.

### Usage

```fitweibull6(x, y = NULL, p0 = NULL, linint = -1, maxit = 2000)

fitweibull4(x, y = NULL, p0 = c(0.1, 50, 5, 100), linint = -1, maxit = 1000)
```

### Arguments

 `x, y` the x (in day of year) and y coordinates of a set of points. Alternatively, a single argument x can be provided. `p0` initial parameters for optimization. In case of `p0 = NA` a heuristic algorithm to derive initial values is used for `fitweibull6`. `linint` control parameter to select interpolation behavior. Negative values (default) specify automatic selection heuristic, zero disables interpolation. A positive value is interpreted as mandatory interpolation time step. `maxit` maximum number of iterations passed to the optimisation functions.

### Details

Function `fitweibull6` uses extensive heuristics to derive initial parameters for the optimization. It is intended to work with data which are defined over an interval between 0 and 365, e.g. environmental data and especially for plankton blooms. Please note that the function does internal transformation:

y_{rel} = y_i / y_{max}

Note that additional data points are inserted between original measurements by linear interpolation with time step = 1 before curve fitting if the number of original data points is too low (currently n < 35). You can set `linint = 0` to switch interpolation off.

`fitweibull4` has only built-in heuristics for data interpolation but not for guessing initial parameters which must be supplied as vector `p0` in the call.

### Value

A list with components:

 `p` vector of fitted parameters, `ymax` maximum y value used for transformation, `r2` coefficient of determination between transformed and fitted y values, `fit` data frame with the following columns: `x`~data (original or interpolated) used for curve fitting, `y`~data (transformed-original or interpolated) used for curve fitting, `f`~estimated function values.

### Note

Note that the heuristics works optimal if unnecessary leading and trailing data are removed before the call.

### Author(s)

Susanne Rolinski (original algorithm) and Thomas Petzoldt (package).

Maintainer: Thomas Petzoldt <thomas.petzoldt@tu-dresden.de>

### References

Rolinski, S., Horn, H., Petzoldt, T., & Paul, L. (2007): Identification of cardinal dates in phytoplankton time series to enable the analysis of long-term trends. Oecologia 153, 997 - 1008. http://dx.doi.org/10.1007/s00442-007-0783-2.

`weibull4`, `weibull6`, `CDW` `peakwindow`, `cardidates`

### Examples

```## create some test data
set.seed(123)
x <- seq(0, 360, length = 20)
y <- abs(rnorm(20, mean = 1, sd = 0.1))
y[5:10] <- c(2, 4, 7, 3, 4, 2)

## fit Weibull function with 6 free parameters
res <- fitweibull6(x, y)

## show some properties
res\$r2
p <- res\$p
o <- res\$fit
f <- res\$ymax

## fit 6 parameter Weibull with user-provided start parameters

x <- seq(0, 150)
y <- fweibull6(x, c(0.8, 40, 5, 0.2, 80, 5)) + rnorm(x, sd = 0.1)
plot(x, y)
res <- fitweibull6(x, y, p0 = c(0, 40, 1, 1, 60, 0))
plot(res)
```

[Package cardidates version 0.4.8 Index]