| Title: | Drying Kinetic Models Comparison and Analysis |
| Version: | 1.0.0 |
| Description: | Fits multiple thin-layer drying kinetic models to experimental moisture ratio data, compares model performance using statistical criteria, performs residual diagnostics, identifies the best-fitting model, and exports results to Word documents. Twenty models from Ertekin and Firat (2017) <doi:10.1016/j.jfoodeng.2016.09.030> are fitted using the Levenberg-Marquardt algorithm described in Marquardt (1963) <doi:10.1137/0111030>. |
| License: | MIT + file LICENSE |
| Depends: | R (≥ 4.1.0) |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 7.3.3 |
| Imports: | readxl, lmtest, minpack.lm, tseries, officer, flextable |
| Suggests: | knitr, rmarkdown |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-07-12 07:50:54 UTC; Sanand |
| Author: | Joshy C G [aut, cre], Devika S [aut] |
| Maintainer: | Joshy C G <cgjoshy@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-21 11:10:08 UTC |
dryingkineticmodels: Drying Kinetic Models Comparison and Analysis
Description
Fits multiple thin-layer drying kinetic models to experimental moisture ratio data, compares model performance using statistical criteria, performs residual diagnostics, identifies the best-fitting model, and exports results to Word documents. Twenty models from Ertekin and Firat (2017) doi:10.1016/j.jfoodeng.2016.09.030 are fitted using the Levenberg-Marquardt algorithm described in Marquardt (1963) doi:10.1137/0111030.
Author(s)
Maintainer: Joshy C G cgjoshy@gmail.com
Authors:
Devika S devikas2104@gmail.com
ANOVA Table for the Best NLS Model
Description
Computes and prints a regression ANOVA table for a fitted nonlinear least squares model.
Usage
anova_nls(best_model, dat)
Arguments
best_model |
A model result list (the |
dat |
A data frame with columns |
Value
A data frame containing the ANOVA table with columns
Source, Sum of Squares, df,
Mean Square, F Value, and Pr(>F).
The table is also printed to the console.
Compare Fitted Drying Kinetic Models
Description
Computes goodness-of-fit statistics for all successfully fitted models and returns a ranked comparison table.
Usage
compare_models(results)
Arguments
results |
A named list of model results as returned by
|
Value
A data frame with one row per successfully fitted model
(models with R^2 \le 0 are excluded), sorted by a composite
rank score based on R^2, RMSE, and \chi^2. Columns are:
- Kinetic Drying Models
Model name.
- Functional Form
Equation of the model.
- R2
Coefficient of determination.
- RMSE
Root mean square error.
- MAE
Mean absolute error.
- chi2
Reduced chi-squared statistic.
- RSS
Residual sum of squares.
- Estimated Coefficients
Parameter estimates as a character string.
Interpret Residual Diagnostic Tests
Description
Runs four residual diagnostic tests on the best model and prints a plain-language interpretation of each result.
Usage
diagnostic_interpretation(best_model, verbose = FALSE)
Arguments
best_model |
A model result list (the |
verbose |
Logical. If |
Value
A list (returned invisibly) with elements shapiro,
dw, bp, and runs — the raw test objects from
shapiro.test,
dwtest,
bptest, and
runs.test respectively.
Drying Kinetic Model Comparison and Analysis
Description
Fits 20 thin-layer drying kinetic models to experimental moisture
ratio data, ranks them by a composite goodness-of-fit criterion
(R^2, RMSE, and \chi^2), identifies the best model,
predicts moisture ratio (MR) using the best model,
performs residual diagnostic tests, and exports a fully formatted
report to a Word document.
Usage
dryingkineticmodels(
file_path,
verbose = FALSE,
models = NULL,
export_word = FALSE
)
Arguments
file_path |
Either a character string giving the path to an
|
verbose |
Logical. If |
models |
Optional character vector naming which of the 20
models to fit (see Details for valid names). If |
export_word |
Logical. If |
Details
The function expects the input to have at least two numeric columns. The first numeric column is treated as drying time as 'time' and the second as moisture ratio as 'MR'. Reorder your columns in Excel if needed before calling the function.
The 20 models fitted are: Lewis, Page, Modified Page,
Henderson & Pabis, Logarithmic, Two-Term, Two-Term Exponential,
Diffusion Approximation, Wang & Singh, Midilli-Kucuk,
Modified Henderson & Pabis, Verma, Weibull, Aghbashlo et al.,
Jena & Das, Hii et al., Parabolic, Thompson, Demir et al., and
Thin-Layer Exponential-Linear. The corresponding names to use with
the models argument are "Lewis", "Page",
"Modified_Page", "Henderson_Pabis",
"Logarithmic", "Two_Term",
"Two_Term_Exponential", "Diffusion_Approximation",
"Wang_Singh", "Midilli_Kucuk",
"Modified_Henderson_Pabis", "Verma", "Weibull",
"Aghbashlo", "Jena_Das", "Hii_et_al",
"Parabolic", "Thompson", "Demir_et_al", and
"Thin_Layer_ExpLin".
Starting values are obtained via a coarse grid search using
nlsLM, making the fitting robust across
a wide range of datasets without requiring manual starting value
specification.
Goodness-of-fit statistics reported are R^2, RMSE, MAE,
\chi^2, and RSS. Model ranking uses the combined rank of
R^2, RMSE, and \chi^2 following Goyal et al. (2007).
Residual diagnostics include the Shapiro-Wilk test (normality), Durbin-Watson test (autocorrelation), Breusch-Pagan test (homoscedasticity), and Runs test (randomness).
Value
A list (returned invisibly) with five elements:
- comparison_table
Data frame of all model fit statistics, sorted by composite rank.
- best_model
The result list for the best-fitting model.
- anova_table
ANOVA table for the best model.
- predicted_MR
Data frame containing observed time, observed MR, predicted MR, residuals, and 95\ the best-fitting model.
- columns_used
Data frame recording which input columns were used as TIME and MR. Always check this to confirm correct column selection, especially when
verbose = FALSE.
References
Goyal, R. K., Kingsly, A. R. P., Manikantan, M. R., & Ilyas, S. M. (2007). Mathematical modelling of thin layer drying kinetics of plum in a tunnel dryer. Journal of Food Engineering, 79(1), 176–180. doi:10.1016/j.jfoodeng.2006.01.041
Examples
# Small, fast toy example (runs automatically during R CMD check)
toy_df <- data.frame(
time = c(0, 30, 60, 90, 120, 150),
MR = c(1.00, 0.72, 0.51, 0.36, 0.26, 0.18)
)
toy_result <- dryingkineticmodels(toy_df, models = c("Lewis", "Page"),
export_word = FALSE)
toy_result$comparison_table
# Fuller example using a bundled sample dataset (slower, includes Word export)
sample_file <- system.file("extdata", "sample_drying_data.csv",
package = "dryingkineticmodels")
df <- read.csv(sample_file)
result <- dryingkineticmodels(df, export_word = TRUE)
Fit All Twenty Drying Kinetic Models
Description
Calls all individual model-fitting functions and returns results as a named list.
Usage
fit_all_models(dat, models = NULL)
Arguments
dat |
A data frame with columns |
models |
Optional character vector of model names to fit. If
|
Value
A named list. Each element is the list returned by the
corresponding fit_*() function. Length 20 if models
is NULL, otherwise length(models).
Extract and Summarise the Best Model
Description
Identifies the top-ranked model from the comparison table, prints its coefficients, fit statistics, hypothesis test results, and runs residual diagnostics.
Usage
get_best_model(results, comparison, dat, verbose = FALSE)
Arguments
results |
A named list of model results as returned by
|
comparison |
A data frame as returned by |
dat |
A data frame with columns |
verbose |
Logical. If |
Value
The model result list for the best model (the
success = TRUE list returned by the corresponding
fit_*() function).
Two-Stage Grid Search for NLS Fitting
Description
Performs a coarse grid search over a parameter grid and returns the
best-fitting nonlinear least squares model using nlsLM.
Usage
grid_search_fit_2stage(
formula,
data,
param_grid,
control = minpack.lm::nls.lm.control(maxiter = 200)
)
Arguments
formula |
A nonlinear model formula. |
data |
A data frame containing the variables in |
param_grid |
A named list of numeric vectors defining the grid of starting values for each parameter. |
control |
Control parameters passed to
|
Value
The best-fitting nls object, or NULL if all
starting value combinations failed to converge.
Plot Residual Diagnostics
Description
Produces a 2x2 panel of residual diagnostic plots: residuals vs fitted values, histogram of residuals, normal Q-Q plot, and a residual sequence plot.
Usage
residual_diagnostics(best_model)
Arguments
best_model |
A model result list (the |
Value
Called for its side effect (plots). Returns NULL
invisibly.