Type: | Package |
Title: | Bayesian Estimation of Adsorption Isotherms via MCMC |
Version: | 0.1.0 |
Author: | Paul Angelo C. Manlapaz
|
Maintainer: | Paul Angelo C. Manlapaz <pacmanlapaz@gmail.com> |
Description: | Provides tools for Bayesian parameter estimation of adsorption isotherm models using Markov Chain Monte Carlo (MCMC) methods. This package enables users to fit non-linear and linear adsorption isotherm models—Freundlich, Langmuir, and Temkin—within a probabilistic framework, capturing uncertainty and parameter correlations. It provides posterior summaries, 95% credible intervals, convergence diagnostics (Gelman-Rubin), and visualizations through trace and density plots. With this R package, researchers can rigorously analyze adsorption behavior in environmental and chemical systems using robust Bayesian inference. For more details, see Gilks et al. (1995) <doi:10.1201/b14835>, and Gamerman & Lopes (2006) <doi:10.1201/9781482296426>. |
License: | GPL-3 |
Encoding: | UTF-8 |
Imports: | MCMCpack, coda, stats, graphics |
Suggests: | testthat |
Config/testthat/edition: | 3 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-05-28 14:36:32 UTC; PTRI |
Repository: | CRAN |
Date/Publication: | 2025-05-30 09:30:12 UTC |
MCMC Analysis for Freundlich Isotherm Linear Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) to estimate the parameters of the Freundlich isotherm based on its linearized form: log(Qe) = log(Kf) + (1/n)log(Ce) This method provides a probabilistic interpretation of the model parameters and accounts for their uncertainties. It supports multiple MCMC chains and computes convergence diagnostics (Gelman-Rubin).
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- mcmc_results
An object of class
mcmc.list
containing posterior samples from all MCMC chains. Each chain includes samples of the intercept and slope.- Kf_mean
Posterior mean estimate of the Freundlich constant (Kf).
- n_mean
Posterior mean estimate of the Freundlich exponent (n).
- logKf_mean
Posterior mean of (log(Kf)) from the first MCMC chain.
- inv_n_mean
Posterior mean of (1/n) (the slope) from the first MCMC chain.
- logKf_sd
Posterior standard deviation of (log(Kf)), quantifying uncertainty in the intercept estimate.
- inv_n_sd
Posterior standard deviation of (1/n), quantifying uncertainty in the slope estimate.
- logKf_ci
95% credible interval for (log(Kf)) from the first MCMC chain, representing the posterior uncertainty in the intercept.
- inv_n_ci
95% credible interval for (1/n) from the first MCMC chain, representing the posterior uncertainty in the slope.
- gelman_diag
Gelman-Rubin diagnostic output from
coda::gelman.diag()
, used to assess convergence of the multiple MCMC chains. A potential scale reduction factor (PSRF) close to 1 indicates good convergence.- mcmc_summary
Summary statistics of the first MCMC chain, including means, standard deviations, quantiles, and sample sizes for each parameter.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_freundlichLM(Ce, Qe, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Freundlich Isotherm Non-linear Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) for the non-linear Freundlich isotherm model: Qe = Kf * Ce^(1/n) This approach is applied to obtain a probabilistic distribution of the model parameters, capturing uncertainties and potential correlations between them.
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- Kf_mean
Posterior mean estimate of Freundlich constant (Kf).
- n_mean
Posterior mean estimate of Freundlich exponent (n).
- logKf_mean
Posterior mean of (log(K_f)).
- inv_n_mean
Posterior mean of (1/n).
- logKf_sd
Posterior standard deviation for (log(Kf)).
- inv_n_sd
Posterior standard deviation for (1/n).
- logKf_ci
95% credible interval for (log(Kf)).
- inv_n_ci
95% credible interval for (1/n).
- gelman_diag
Gelman-Rubin diagnostics (only if multiple chains).
- mcmc_summary
Summary statistics for each parameter.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_freundlichNLM(Ce, Qe, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Langmuir Isotherm Linear (Form 1) Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) to estimate the parameters of the Langmuir isotherm based on its first linear form: Ce / Qe = 1 / (Qmax * b) + Ce / Qmax This method provides a probabilistic interpretation of the model parameters and accounts for their uncertainties. It supports multiple MCMC chains and computes convergence diagnostics (Gelman-Rubin).
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- mcmc_results
An object of class
mcmc.list
containing posterior samples from all MCMC chains.- Qmax_mean
Posterior mean estimate of (Qmax).
- b_mean
Posterior mean estimate of Langmuir constant (b).
- slope_mean
Posterior mean of the slope ((1/Qmax)).
- intercept_mean
Posterior mean of the intercept ((1/(Qmax*b))).
- slope_sd
Posterior standard deviation of the slope.
- intercept_sd
Posterior standard deviation of the intercept.
- slope_ci
95% credible interval for the slope.
- intercept_ci
95% credible interval for the intercept.
- gelman_diag
Gelman-Rubin convergence diagnostic.
- mcmc_summary
Summary statistics of the first MCMC chain.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_langmuirLM1(Ce, Qe, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Langmuir Isotherm Linear (Form 2) Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) to estimate the parameters of the Langmuir isotherm using its second linear form: 1 / Qe = 1 / Qmax + (1 / (Qmax * b)) * (1 / Ce) This method provides a probabilistic interpretation of the model parameters and accounts for their uncertainties. It supports multiple MCMC chains and computes convergence diagnostics (Gelman-Rubin).
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- mcmc_results
An object of class
mcmc.list
with posterior samples from all chains.- Qmax_mean
Posterior mean estimate of (Qmax).
- b_mean
Posterior mean estimate of (b).
- slope_mean
Posterior mean of slope (1 / (Qmax * b)).
- intercept_mean
Posterior mean of intercept ((1/Qmax)).
- slope_sd
Posterior standard deviation of the slope.
- intercept_sd
Posterior standard deviation of the intercept.
- slope_ci
95% credible interval for the slope.
- intercept_ci
95% credible interval for the intercept.
- gelman_diag
Gelman-Rubin convergence diagnostic.
- mcmc_summary
Summary statistics of the first MCMC chain.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_langmuirLM2(Ce, Qe, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Langmuir Isotherm Linear (Form 3) Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) to estimate the parameters of the Langmuir isotherm using its third linear form: Qe = Qmax - (1 / b) * (Qe / Ce) This method provides a probabilistic interpretation of the model parameters and accounts for their uncertainties. It supports multiple MCMC chains and computes convergence diagnostics (Gelman-Rubin).
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- mcmc_results
Combined posterior samples (mcmc.list).
- Qmax_mean
Posterior mean of Qmax.
- b_mean
Posterior mean of b.
- slope_mean
Posterior mean of slope (-1/b).
- intercept_mean
Posterior mean of Qmax.
- slope_sd
Standard deviation of slope.
- intercept_sd
Standard deviation of intercept.
- slope_ci
95% credible interval for slope.
- intercept_ci
95% credible interval for intercept.
- gelman_diag
Gelman-Rubin convergence diagnostic.
- mcmc_summary
Summary of main chain.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_langmuirLM3(Ce, Qe, burnin = 1000, mcmc = 10000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Langmuir Isotherm Linear (Form 4) Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) to estimate the parameters of the Langmuir isotherm using its fourth linear form: Qe / Ce = b * Qmax - b * Qe This method provides a probabilistic interpretation of the model parameters and accounts for their uncertainties. It supports multiple MCMC chains and computes convergence diagnostics (Gelman-Rubin).
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list with:
- mcmc_results
Combined posterior samples (mcmc.list).
- Qmax_mean
Posterior mean of Qmax.
- b_mean
Posterior mean of b.
- intercept_mean
Posterior mean of intercept (b * Qmax).
- intercept_sd
Posterior standard deviation of intercept.
- intercept_ci
95% credible interval for intercept.
- slope_mean
Posterior mean of slope (-b).
- slope_sd
Posterior standard deviation of slope.
- slope_ci
95% credible interval for slope.
- gelman_diag
Gelman-Rubin convergence diagnostics.
- mcmc_summary
Summary of the first MCMC chain.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_langmuirLM4(Ce, Qe, burnin = 1000, mcmc = 10000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Langmuir Isotherm Non-linear Model
Description
This function performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) simulation to estimate the parameters of the Langmuir isotherm using the non-linear model: Qe = (Qmax * KL * Ce) / (1 + KL * Ce) This approach is applied to obtain a probabilistic distribution of the model parameters, capturing uncertainties and potential correlations between them.
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- Qmax_mean
Posterior mean estimate of the Langmuir maximum adsorption capacity (Qmax).
- Kl_mean
Posterior mean estimate of the Langmuir constant (Kl).
- Qmax_sd
Posterior standard deviation for (Qmax).
- Kl_sd
Posterior standard deviation for (Kl).
- Qmax_ci
95% credible interval for (Qmax).
- Kl_ci
95% credible interval for (Kl).
- gelman_diag
Gelman-Rubin diagnostics (only if multiple chains).
- mcmc_summary
Summary statistics for each parameter.
Author(s)
Paul Angelo C. Manlapaz
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)
mcmc_langmuirNLM(Ce, Qe, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Temkin Isotherm Linear Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) to estimate the parameters of the Temkin isotherm based on its linearized form: Qe = aT + bT * log(Ce) This method provides a probabilistic interpretation of the model parameters and accounts for their uncertainties. It supports multiple MCMC chains and computes convergence diagnostics (Gelman-Rubin).
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
Temp |
Numeric value of temperature in Kelvin. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- mcmc_results
An object of class
mcmc.list
containing posterior samples from all MCMC chains.- aT_mean
Posterior mean estimate of Temkin constant (aT).
- bT_mean
Posterior mean estimate of Temkin constant (bT).
- aT_raw_mean
Posterior mean of the intercept (aT) from the linear model.
- bT_raw_mean
Posterior mean of the slope (b_T) from the linear model.
- aT_sd
Posterior standard deviation of (aT).
- bT_sd
Posterior standard deviation of (bT).
- aT_ci
95% credible interval for (aT).
- bT_ci
95% credible interval for (bT ).
- gelman_diag
Gelman-Rubin convergence diagnostic.
- mcmc_summary
Summary statistics from the first chain.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_temkinLM(Ce, Qe, 298, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)
MCMC Analysis for Temkin Isotherm Non-linear Model
Description
Performs Bayesian parameter estimation using Markov Chain Monte Carlo (MCMC) for the non-linear Temkin isotherm model: Qe = (R * T / b_T) * ln(A_T * Ce) This approach is applied to obtain a probabilistic distribution of the model parameters, capturing uncertainties and potential correlations between them.
Arguments
Ce |
Numeric vector of equilibrium concentrations. |
Qe |
Numeric vector of adsorbed amounts. |
Temp |
Numeric value of temperature in Kelvin. |
burnin |
Integer specifying the number of burn-in iterations (default is 1000). |
mcmc |
Integer specifying the total number of MCMC iterations (default is 5000). |
thin |
Integer specifying the thinning interval (default is 10). |
verbose |
Integer controlling the frequency of progress updates (default is 100). |
plot |
Logical; if TRUE, trace and density plots of the MCMC chains are shown (default is FALSE). |
n_chains |
Number of independent MCMC chains (default = 2). |
seed |
Optional integer for reproducibility. |
Value
A list containing:
- AT_mean
Posterior mean estimate of Temkin constant (AT).
- bT_mean
Posterior mean estimate of Temkin constant (bT).
- logAT_mean
Posterior mean of (log(AT)).
- bT_sd
Posterior standard deviation for (bT).
- logAT_sd
Posterior standard deviation for (log(AT)).
- logAT_ci
95% credible interval for (log(AT)).
- bT_ci
95% credible interval for (bT).
- gelman_diag
Gelman-Rubin diagnostics (only if multiple chains).
- mcmc_summary
Summary statistics for each parameter.
Author(s)
Paul Angelo C. Manlapaz
References
Gilks, W. R., Richardson, S., & Spiegelhalter, D. J. (1995). Markov Chain Monte Carlo in Practice. Chapman and Hall/CRC.
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)
mcmc_temkinNLM(Ce, Qe, 298, burnin = 1000, mcmc = 5000, thin = 10,
verbose = 100, plot = TRUE, n_chains = 2, seed = 123)