predict,growthrates_fit-method {growthrates}R Documentation

Model Predictions for growthrates Fits

Description

Class-specific methods of package growthrates to make predictions.

Usage

## 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, ...)

Arguments

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 'exponential' or 'spline' for fit_spline, resp. code'exponential' or 'no_lag' for fit_easylinear.

Details

The implementation of the predict methods is still experimental and under discussion.

See Also

methods, predict.smooth.spline, predict.lm, predict.nls

Examples


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")

[Package growthrates version 0.8.4 Index]