From b894b36f1e44d40105fcb3dc7255953760e60a3e Mon Sep 17 00:00:00 2001 From: Frank Weber <55132727+fweber144@users.noreply.github.com> Date: Sat, 8 Jan 2022 11:03:22 +0100 Subject: [PATCH] Fix issue #243 (#262) --- R/cv_varsel.R | 2 +- R/refmodel.R | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/R/cv_varsel.R b/R/cv_varsel.R index 7b9c6a5f7..a895acdf5 100644 --- a/R/cv_varsel.R +++ b/R/cv_varsel.R @@ -394,7 +394,7 @@ loo_varsel <- function(refmodel, method, nterms_max, ndraws, for (k in seq_along(submodels)) { mu_k <- refmodel$family$mu_fun(submodels[[k]]$sub_fit, obs = inds, - offset = refmodel$offset) + offset = refmodel$offset[inds]) log_lik_sub <- t(refmodel$family$ll_fun( mu_k, submodels[[k]]$dis, refmodel$y[inds], refmodel$wobs[inds] )) diff --git a/R/refmodel.R b/R/refmodel.R index e8a92aadc..ea715c071 100644 --- a/R/refmodel.R +++ b/R/refmodel.R @@ -567,6 +567,8 @@ init_refmodel <- function(object, data, formula, family, ref_predfun = NULL, newdata <- fetch_data(data, obs = obs, newdata = newdata) if (is.null(offset)) { offset <- rep(0, nrow(newdata)) + } else { + stopifnot(length(offset) %in% c(1L, nrow(newdata))) } family$linkinv(proj_predfun(fit, newdata = newdata) + offset) }