predict,growthrates_fit-method | R Documentation |
Class-specific methods of package growthrates to make predictions.
## S4 method for signature 'growthrates_fit' predict(object, ...) ## S4 method for signature 'smooth.spline_fit' predict(object, newdata = NULL, ..., type = c("exponential", "spline")) ## S4 method for signature 'easylinear_fit' predict(object, newdata = NULL, ..., type = c("exponential", "no_lag")) ## S4 method for signature 'nonlinear_fit' predict(object, newdata, ...) ## S4 method for signature 'multiple_fits' predict(object, ...)
object |
name of a 'growthrates' object for which prediction is desired. |
... |
additional arguments affecting the predictions produced. |
newdata |
an optional data frame with column 'time' for new time steps with which to predict. |
type |
type of predict. Can be |
The implementation of the predict methods is still experimental and under discussion.
methods
, predict.smooth.spline
,
predict.lm
, predict.nls
data(bactgrowth) splitted.data <- multisplit(bactgrowth, c("strain", "conc", "replicate")) ## get table from single experiment dat <- splitted.data[[1]] ## --- linear fit ----------------------------------------------------------- fit <- fit_easylinear(dat$time, dat$value) plot(fit) pr <- predict(fit) lines(pr[,1:2], col="blue", lwd=2, lty="dashed") pr <- predict(fit, newdata=list(time=seq(2, 6, .1)), type="no_lag") lines(pr[,1:2], col="magenta") ## --- spline fit ----------------------------------------------------------- fit1 <- fit_spline(dat$time, dat$value, spar=0.5) coef(fit1) summary(fit1) plot(fit1) pr <- predict(fit1) lines(pr[,1:2], lwd=2, col="blue", lty="dashed") pr <- predict(fit1, newdata=list(time=2:10), type="spline") lines(pr[,1:2], lwd=2, col="cyan") ## --- nonlinear fit -------------------------------------------------------- dat <- splitted.data[["T:0:2"]] p <- c(y0 = 0.02, mumax = .5, K = 0.05, h0 = 1) fit2 <- fit_growthmodel(grow_baranyi, p=p, time=dat$time, y=dat$value) ## prediction for given data predict(fit2) ## prediction for new data pr <- predict(fit2, newdata=data.frame(time=seq(0, 50, 0.1))) plot(fit2, xlim=c(0, 50)) lines(pr[, c("time", "y")], lty="dashed", col="red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.