Skip to content

predict() should not require response variable to be present in newdata #461

@danielinteractive

Description

@danielinteractive

Reprex:

library("mmrm")

fit <- mmrm(
  formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
  data = fev_data
)

predict(fit, subset(fev_data, select = - FEV1))

fails with:

Error in eval(predvars, data, env) : object 'FEV1' not found

because h_mmrm_tmb_data() is invoked and this uses the full_formula which includes the response variable from the fit.

Reported originally in vincentarelbundock/marginaleffects#1000 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions