View source: R/cross_validate.R
| cv.LV | R Documentation |
The function preforms k-fold cross-validation on a grid of regularization parameters
cv.LV(
time_series,
n_folds = length(time_series),
kind = "integral",
weights = expand.grid(self = 0.1 * 0:100, interaction = 0.1 * 0:100),
show_progress = TRUE,
parallel = FALSE,
ncpus = getOption("micInt.ncpus", 1L),
cl = NULL
)
time_series |
A list of |
n_folds |
The number of folds to apply. If missing, leave-one-out cross-validation is preformed. |
kind |
Charachter, one of |
weights |
A n times 2 data.frame containing the weights to be tried out. The two colmns are:
If missing, the cross validation is carried out over a quadratic grid from 0 to 10 in steps of 0.1 |
show_progress |
Logical, if |
parallel |
Should the analysis be run in parallel? |
ncpus |
If |
cl |
Custom cluster to use if |
In this setting, each time series is a “data point” in the cross-validation procedure, meaning that each fit is preformed on some of the time series and the other are used for validation.
An object of class cvLV, inheiriting data.frame containing the parameter values, and the two columns of cross-validation error:
'RMSE' The root mean square error of the right sides
'MAE' The mean absolute error of the right sides
P. H. Kloppers and J. C. Greeff. “Lotka-Volterra model parameter estimation using experiential data”. In: Appl. Math. Comput. 224 (Nov. 2013), pp. 817–825. ISSN: 0096-3003. DOI: https://doi.org/10.1016/j.amc.2013.08.093
library(micInt)
library(phyloseq)
library(magrittr)
data("seawater")
physeq_list <- subdivide_by_environment(seawater,"Reactor")
time_series <- lapply(physeq_list$phyloseq,OTU_time_series,
time_points ="Week")
systems <- integralSystem(time_series,kind = "integral")
cv_res <- cv.LV(time_series,n_folds = 3, kind = "integral",
weights = expand.grid(self= c(1,2),
interaction = c(1,2)
)
)
best_parameters <- cv_res[which.min(cv_res$RMSE),c("self","interaction")] %>% unlist()
fit <- ridge_fit(systems,best_parameters)
predict(fit,start = rep(1,nrow(fit)),times = c(0,1,4,6,10,20))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.