From dd525f49b852376f24851f23c36d6c50f23dbf82 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 15 Mar 2023 19:06:02 +0100 Subject: Start parms and endpoints for covariates --- R/endpoints.R | 14 +++++++++++--- R/saem.R | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'R') diff --git a/R/endpoints.R b/R/endpoints.R index 4aec8aa8..0c26ffae 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -14,6 +14,10 @@ #' another object that has list components mkinmod containing an [mkinmod] #' degradation model, and two numeric vectors, bparms.optim and bparms.fixed, #' that contain parameter values for that model. +#' @param \dots Possibility to specify values for the covariates in the model. +#' In case more than one vector is given, they either have to be of the same +#' length, or of length one, in which case the respective covariate values are +#' recycled. #' @importFrom stats optimize #' @return A list with a matrix of dissipation times named distimes, and, if #' applicable, a vector of formation fractions named ff and, if the SFORB model @@ -34,17 +38,21 @@ #' } #' #' @export -endpoints <- function(fit) { - ep <- list() +endpoints <- function(fit, ...) { mkinmod <- fit$mkinmod - degparms <- c(fit$bparms.optim, fit$bparms.fixed) obs_vars <- names(mkinmod$spec) + + degparms <- c(fit$bparms.optim, fit$bparms.fixed) + + # Set up object to return + ep <- list() ep$ff <- vector() ep$SFORB <- vector() ep$distimes <- data.frame( DT50 = rep(NA, length(obs_vars)), DT90 = rep(NA, length(obs_vars)), row.names = obs_vars) + for (obs_var in obs_vars) { type = names(mkinmod$map[[obs_var]])[1] diff --git a/R/saem.R b/R/saem.R index 7eeec2bb..bddd3bfe 100644 --- a/R/saem.R +++ b/R/saem.R @@ -226,6 +226,8 @@ saem.mmkin <- function(object, transformations = transformations, transform_rates = object[[1]]$transform_rates, transform_fractions = object[[1]]$transform_fractions, + covariates = covariates, + covariate_models = covariate_models, sm = m_saemix, so = f_saemix, call = call, -- cgit v1.2.1