Learn R Programming

phylocurve (version 2.1.1)

nonlinear.fit: Fit nonlinear curves to species data

Description

Transforms raw data into regression curves using the drm function in the drc package. The response data can be constrained between minima and maxima (for example, the default sets any negative predicted y value to 0).

Usage

nonlinear.fit(data, x_variable, y_variable, fct = LL2.3(),
  min_x = -Inf, max_x = Inf, min_y = 0, max_y = Inf, eval_length = 30, ...)

Arguments

data

Data frame with function-valued species data along with a column named "species"

x_variable

The name of the column in data corresponding to the predictor (x) variable

y_variable

The name of the column in data corresponding to the response (y) variable

fct

Function type to pass to drm. Use getMeanFunctions for a full list.

min_x

Lower range to remove from raw x data

max_x

Upper range to remove from raw x data

min_y

Lower range to remove from predicted response (for example, for response data in which only positive values are allowed, the min_y can be set to 0 (the default)).

max_y

Upper range to remove from predicted response.

eval_length

How many points to evaluate along the range of x.

Optional further arguments to pass to the drm function.

Value

X

X (formatted for phylocurve.generalized)

Y

Y (formatted for phylocurve.generalized)

Examples

Run this code
# NOT RUN {
x_length <- 50
nspecies <- 25
sim_data <- sim.curves(nspecies = nspecies,x_length = x_length)

# Fit nonlinear curves to raw data
curve_data <- nonlinear.fit(data = sim_data$data,x_variable = "x",y_variable = "y",min_y = 0)

# Align curve data using dynamic time warping
# NOT RUN (takes several minutes)
# P <- phylocurve.generalized(tree = sim_data$tree,X = curve_data$X,Y = curve_data$Y)
# }

Run the code above in your browser using DataLab