From 17af45b984d348505527140470c7fff204748ea6 Mon Sep 17 00:00:00 2001
From: Johannes Ranke <johannes.ranke@jrwb.de>
Date: Fri, 12 Sep 2025 22:16:13 +0200
Subject: Facilitate centering covariates

The motivation for this is to obtain confidence intervals for
covariate dependent parameters that are valid for a median/mean
value of the covariate.

Implementation by adding an argument to the 'saem' function, and
adapting the relevant functions working with 'saem' objects.

Vignettes, the template and tests were updated to use the new functionality.
---
 .../templates/hierarchical_kinetics/skeleton/skeleton.Rmd  | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd')

diff --git a/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd
index f0692b4c..f61413ba 100644
--- a/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd
+++ b/inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd
@@ -157,11 +157,12 @@ models for both of them is fitted.
 
 ```{r parent-best-pH}
 parent_best_pH_1 <- update(parent_best, covariates = covariates,
-  covariate_models = list(log_k_lambda_free ~ pH))
+  covariate_models = list(log_k_lambda_free ~ pH), center_covariates = "median")
 parent_best_pH_2 <- update(parent_best, covariates = covariates,
-  covariate_models = list(log_k_lambda_bound_free ~ pH))
+  covariate_models = list(log_k_lambda_bound_free ~ pH), center_covariates = "median")
 parent_best_pH_3 <- update(parent_best, covariates = covariates,
-  covariate_models = list(log_k_lambda_free ~ pH, log_k_lambda_bound_free ~ pH))
+  covariate_models = list(log_k_lambda_free ~ pH, log_k_lambda_bound_free ~ pH),
+  center_covariates = "median")
 ```
 
 The resulting models are compared.
@@ -244,6 +245,7 @@ model that was identified for the parent degradation, are attempted below.
 path_1 <- mhmkin(list(sforb_sep_const, sforb_sep_tc),
   no_random_effect = c("lambda_free_0", "log_k_lambda_free_bound"),
   covariates = covariates, covariate_models = list(log_k_lambda_bound_free ~ pH),
+  center_covariates = "median",
   cluster = cl_path)
 ```
 
@@ -297,6 +299,12 @@ are shown below.
 endpoints(path_1_refined)
 ```
 
+We can also show endpoints corresponding to a user defined pH value.
+
+```{r dependson = "parent-best-pH"}
+endpoints(path_1_refined, covariates = c(pH = 7))
+```
+
 ```{r}
 if (!is.null(cl_path)) stopCluster(cl_path)
 ```
-- 
cgit v1.2.3

