fit_spline | R Documentation |
Determine maximum growth rates from the first derivative of a smoothing spline.
fit_spline(time, y, optgrid = length(time), ...)
time |
vector of independent variable. |
y |
vector of dependent variable (concentration of organisms). |
optgrid |
number of steps on the x-axis used for the optimum search . algorithm. The default should work in most cases, as long as the data are equally spaced. A smaller number may lead to non-detectable speed-up, but has the risk that the search gets trapped in a local minimum. |
... |
other parameters passed to |
The method was inspired by an algorithm of Kahm et al. (2010), with different settings and assumptions. In the moment, spline fitting is always done with log-transformed data, assuming exponential growth at the time point of the maximum of the first derivative of the spline fit.
All the hard work is done by function smooth.spline
from package
stats, that is highly user configurable. Normally, smoothness is
automatically determined via cross-validation. This works well in many cases,
whereas manual adjustment is required otherwise, e.g. by setting spar
to a fixed value [0, 1] that also disables cross-validation.
object with parameters of the fit
Kahm, M., Hasenbrink, G., Lichtenberg-Frate, H., Ludwig, J., Kschischo, M. 2010. grofit: Fitting Biological Growth Curves with R. Journal of Statistical Software, 33(7), 1-21, doi: 10.18637/jss.v033.i07
Other fitting functions:
all_easylinear()
,
all_growthmodels()
,
all_splines()
,
fit_easylinear()
,
fit_growthmodel()
data(bactgrowth) splitted.data <- multisplit(bactgrowth, c("strain", "conc", "replicate")) dat <- splitted.data[[2]] time <- dat$time y <- dat$value ## automatic smoothing with cv res <- fit_spline(time, y) plot(res, log="y") plot(res) coef(res) ## a more difficult data set dat <- splitted.data[[56]] time <- dat$time y <- dat$value ## default parameters res <- fit_spline(time, y) plot(res, log="y") ## small optgrid, trapped in local minimum res <- fit_spline(time, y, optgrid=5) plot(res, log="y") ## manually selected smoothing parameter res <- fit_spline(time, y, spar=.5) plot(res, log="y") plot(res, ylim=c(0.005, 0.03))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.