Skip to content

Commit 8868224

Browse files
authored
Merge pull request #548 from aloctavodia/reformulas
Use reformulas for formula processing functions
2 parents eead7db + 2b509ed commit 8868224

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ Imports:
5656
MASS,
5757
ordinal,
5858
nnet,
59-
mclogit
59+
mclogit,
60+
reformulas,
6061
Suggests:
6162
ggrepel,
6263
ggfortify,

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If you read this from a place other than <https://mc-stan.org/projpred/news/inde
99
* Added support for censored observations when using the latent projection (with response-scale analyses). This makes it possible, e.g., to use the latent projection for time-to-event models (also known as models for survival analysis). Due to this new feature, the function passed to argument `latent_ll_oscale` of `extend_family()` now needs to have an argument `cens`. See `?extend_family` (section "Latent projection") as well as the latent-projection vignette (section ["Censored observations (survival analysis)"](https://mc-stan.org/projpred/articles/latent.html#cens)) for more information and examples. Note that only the performance statistics `"elpd"`, `"mlpd"`, and `"gmpd"` take censoring into account (on response scale). (GitHub: #528)
1010

1111
## Minor changes
12-
12+
* Use `reformulas` package directly for formula processing functions. This package is already a dependency of `lme4` >= v1.1-38.
1313

1414
## Bug fixes
1515

R/divergence_minimizers.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ divmin <- function(
5252
sdivmin <- fit_glmer_callback
5353
if (getOption("projpred.PQL", FALSE)) {
5454
# Split up the formula into a fixed and a random part (note: we could also
55-
# use lme4::nobars() and lme4::findbars() here):
55+
# use reformulas::nobars() and reformulas::findbars() here):
5656
formula_random <- split_formula_random_gamm4(formula)
5757
projpred_formulas_no_random <- validate_response_formula(
5858
formula_random$formula
@@ -1342,11 +1342,11 @@ empty_intersection <- function(x, el_nm = "new") {
13421342
# "GPL (>=2)" (see <https://CRAN.R-project.org/package=lme4>).
13431343
mkNewReTrms_man <- function(re.form, newdata, xlevels, re, D = NULL) {
13441344
stopifnot(!is.null(newdata))
1345-
tt <- terms(lme4::subbars(re.form))
1345+
tt <- terms(reformulas::subbars(re.form))
13461346
rfd <- suppressWarnings(
13471347
model.frame(tt, newdata, na.action = na.pass, xlev = xlevels)
13481348
)
1349-
ReTrms <- lme4::mkReTrms(lme4::findbars(re.form[[2]]), rfd)
1349+
ReTrms <- reformulas::mkReTrms(reformulas::findbars(re.form[[2]]), rfd)
13501350
ns.re <- names(re)
13511351
nRnms <- names(Rcnms <- ReTrms$cnms)
13521352
if (!all(nRnms %in% ns.re)) {

tests/testthat/test_refmodel.R

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,17 @@ test_that(paste(
260260

261261
# Without `ynew`:
262262
expect_warning(
263-
predref_resp <- withCallingHandlers(
264-
predict(refmods[[tstsetup]], dat,
265-
weightsnew = wobs_crr,
266-
offsetnew = offs_crr,
267-
type = "response"),
263+
withCallingHandlers(
264+
predref_resp <- predict(refmods[[tstsetup]], dat, weightsnew = wobs_crr,
265+
offsetnew = offs_crr, type = "response"),
268266
warning = function(w) {
269-
if (grepl("nobars.*reformulas", conditionMessage(w))) {
267+
if (grepl("(nobars|subbars|findbars|mkReTrms).*reformulas", conditionMessage(w))) {
270268
invokeRestart("muffleWarning")
271269
}
272270
}
273271
),
274-
get_warn_wrhs_orhs(tstsetup,
275-
weightsnew = wobs_crr,
276-
offsetnew = offs_crr),
272+
get_warn_wrhs_orhs(tstsetup, weightsnew = wobs_crr,
273+
offsetnew = offs_crr),
277274
info = tstsetup
278275
)
279276

0 commit comments

Comments
 (0)