predict.LV: Predict trajectory of a Lotka-Volterra system from estimated...

View source: R/solve_system.R

predict.LVR Documentation

Predict trajectory of a Lotka-Volterra system from estimated coefficients

Description

This function utilizes the deSolve package in order to simulate a Lotka-Volterra system with fitted coefficients. Hence, it can be used for predictions.

Usage

## S3 method for class 'LV'
predict(object, start, times, ...)

Arguments

object

An object of class LV_fit returned from a suitable fitting function such as ridge_fit, containing the Lotka-Volterra coefficients

start

The vector of the microbial community at the start of the simulation. The OTUs must be in the same order as in the fit argument.

times

The time points to include in the simulation

...

Additional parameters to the function ode used to solve the system

Details

By default, the lsoda is the method used, but this can be changed by passing an method argument

Value

An object of type OTU_time_series, where the table is a matrix of type deSolve

See Also

ridge_fit, deSolve-package

Examples

library(micInt)
library(phyloseq)
data("seawater")
subsetted_seawater <- subset_samples(seawater, Reactor == 2)
systems <- integralSystem(OTU_time_series(subsetted_seawater,"Week"), kind = "log_integral")
fit_1 <- ridge_fit(systems,weights = c(self = 10,interaction = 1))
fit_2 <- ridge_fit(systems,weights = c(self = 1,interaction = 1))
prediction_1 <- predict(fit_1,start = rep(1,nrow(fit_1)),times = c(1,2,3,4,5))
prediction_2 <- predict(fit_2,start = rep(1,nrow(fit_2)),times = c(1,2,3,4,5))
plot_trajectory(list(fit_1=prediction_1,fit_2 =prediction_2))



AlmaasLab/micInt documentation built on April 1, 2022, 10:37 a.m.