@@ -78,11 +78,11 @@ predict.wbm <- function(object, newdata = NULL, se.fit = FALSE,
78
78
allow.new.levels = TRUE , na.action = na.pass , ... ) {
79
79
80
80
# Need to re-process data when raw is FALSE
81
- if (! is.null(newdata ) & raw == FALSE ) {
81
+ if (! is.null(newdata ) && raw == FALSE ) {
82
82
newdata <- process_nonraw_newdata(object , newdata , re.form )
83
83
}
84
84
85
- if (raw == TRUE & ! is.null(newdata )) {
85
+ if (raw == TRUE && ! is.null(newdata )) {
86
86
newdata <- process_raw_newdata(object , newdata )
87
87
}
88
88
@@ -156,12 +156,12 @@ process_nonraw_newdata <- function(object, newdata, re.form) {
156
156
}
157
157
158
158
process_raw_newdata <- function (object , newdata ) {
159
- ints <- attr( object @ frame , " interactions" )
159
+ ints <- object @ call_info $ interactions
160
160
if (! is.null(ints )) {
161
161
ints <- gsub(" :" , " *" , ints )
162
162
ints <- gsub(" (^.*)(?=\\ *)" , " `\\ 1`" , ints , perl = TRUE )
163
163
ints <- gsub(" (?<=\\ *)(.*$)" , " `\\ 1`" , ints , perl = TRUE )
164
- demean <- attr( object @ frame , " interaction.style" ) == " double-demean"
164
+ demean <- object @ call_info $ interaction.style == " double-demean"
165
165
if (object @ call_info $ model %in% c(" between" , " contextual" , " random" )) {
166
166
demean <- FALSE
167
167
}
@@ -397,14 +397,19 @@ make_predictions.wbm <- function(model, pred, pred.values = NULL, at = NULL,
397
397
boot = FALSE , sims = 1000 , progress = " txt" , set.offset = NULL ,
398
398
new_data = NULL , return .orig.data = FALSE , partial.residuals = FALSE ,
399
399
message = TRUE , raw = TRUE , ... ) {
400
-
400
+
401
401
# Check if user provided own new_data
402
402
if (is.null(new_data )) {
403
+ meanvars <- model @ call_info $ meanvars
404
+ if (! is.null(meanvars )) {
405
+ meanvarlist <- lapply(data [meanvars ], mean , na.rm = TRUE )
406
+ at <- c(at , meanvarlist )
407
+ }
403
408
# Get the data ready with make_new_data()
404
409
pm <- jtools :: make_new_data(model , pred , pred.values = pred.values , at = at ,
405
410
data = data , center = center , set.offset = set.offset )
406
411
} else {pm <- new_data }
407
-
412
+
408
413
resp <- jtools :: get_response_name(model )
409
414
link_or_lm <- ifelse(family(model )$ link == " identity" ,
410
415
yes = " response" , no = " link" )
@@ -416,7 +421,7 @@ make_predictions.wbm <- function(model, pred, pred.values = NULL, at = NULL,
416
421
}
417
422
418
423
# Do the predictions using built-in prediction method if robust is FALSE
419
- if (interval == FALSE & is.null(model.offset(model.frame(model )))) {
424
+ if (interval == FALSE && is.null(model.offset(model.frame(model )))) {
420
425
predicted <- as.data.frame(predict(model , newdata = pm ,
421
426
type = link_or_lm ,
422
427
re.form = re.form ,
0 commit comments