Skip to content

Commit

Permalink
fix for #126
Browse files Browse the repository at this point in the history
  • Loading branch information
jchiquet committed Sep 10, 2024
1 parent 1e3b8e5 commit ba5cf32
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/utils-zipln.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ extract_model_zi <- function(call, envir) {
call_args <- c(as.list(call_args), list(xlev = attr(call$formula, "xlevels"), na.action = NULL))

## Extract terms for ZI and PLN components
terms <- .extract_terms_zi(as.formula(call$formula, env = envir))
terms <- .extract_terms_zi(as.formula(eval(call$formula, env = envir)))
## eval the call in the parent environment with adjustement due to ZI terms
call_args$formula <- terms$formula
frame <- do.call(stats::model.frame, call_args, envir = envir)

## Save level for predict function
xlevels <- list(PLN = .getXlevels(terms$PLN, frame))
if (!is.null(terms$ZI)) xlevels$ZI = .getXlevels(terms$ZI, frame)
attr(call$formula, "xlevels") <- xlevels
if (!is.null(xlevels$PLN)) attr(call$formula, "xlevels") <- xlevels

## Create the set of matrices to fit the PLN model
X <- model.matrix(terms$PLN, frame, xlev = xlevels$PLN)
Expand Down

0 comments on commit ba5cf32

Please sign in to comment.