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")
Run the code above in your browser using DataLab