fitweibull {cardidates}R Documentation

Fit Four or Six Parametric Weibull Functions


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


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)


x, y

the x (in day of year) and y coordinates of a set of points. Alternatively, a single argument x can be provided.


initial parameters for optimization. In case of p0 = NA a heuristic algorithm to derive initial values is used for fitweibull6.


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.


maximum number of iterations passed to the optimisation functions.


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.


A list with components:


vector of fitted parameters,


maximum y value used for transformation,


coefficient of determination between transformed and fitted y values,


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 that the heuristics works optimal if unnecessary leading and trailing data are removed before the call.


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

Maintainer: Thomas Petzoldt <>


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.

See Also

weibull4, weibull6, CDW peakwindow, cardidates


## create some test data
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
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))

[Package cardidates version 0.4.8 Index]