cv_langmuirNLM {adsoRptionCV}R Documentation

Cross-Validation Analysis for Langmuir Isotherm Non-linear Model with Clustering-based Fold Assignment

Description

Performs K-fold or leave-one-out cross-validation (LOOCV) on the Langmuir isotherm non-linear model: Qe = (Qmax * Ce) / (b + Ce) where Qmax is the maximum adsorption capacity and b is the Langmuir constant. Supports optional clustering-based fold assignment and visualization of fold MSEs.

Arguments

Ce

Numeric vector of equilibrium concentrations (Ce). Must be positive.

Qe

Numeric vector of amounts adsorbed (Qe). Must be positive and same length as Ce.

K

Integer. Number of folds to use in K-fold CV (default is 10). Ignored if loocv = TRUE.

seed

Integer. Random seed for reproducibility (default is 123).

loocv

Logical. If TRUE, performs leave-one-out cross-validation (overrides K).

plot

Logical. If TRUE, displays a barplot of fold MSEs (default is FALSE).

use_clustering

Logical. If TRUE, assigns folds using k-means clustering on the data (default FALSE).

Value

A list with the following components:

mean_mse

The average mean squared error across all folds.

fold_mse

A numeric vector of MSEs for each fold.

Author(s)

Paul Angelo C. Manlapaz

References

Montgomery, D.C., Peck, E.A., & Vining, G.G. (2012). Introduction to Linear Regression Analysis, 5th ed. Wiley.

Examples

Ce <- c(0.01353, 0.04648, 0.13239, 0.27714, 0.41600, 0.63607, 0.80435, 1.10327, 1.58223)
Qe <- c(0.03409, 0.06025, 0.10622, 0.12842, 0.15299, 0.15379, 0.15735, 0.15735, 0.16607)
cv_langmuirNLM(Ce, Qe, K = 5, seed = 123, plot = TRUE, use_clustering = TRUE)
cv_langmuirNLM(Ce, Qe, loocv = TRUE, plot = TRUE)


[Package adsoRptionCV version 0.1.0 Index]