I think I found a bug in predict.mfp2(). See the following code:
# load data
data(wage1, package = "wooldridge")
wage <- wage1
# set up model matrix
X <- model.matrix(lwage ~ -1 + educ + exper, data = wage)
# fit with mfp
fit.mfp <- mfp2::mfp2(X, wage$lwage, verbose = FALSE)
d.plot <- expand.grid(exper = mean(wage$exper),
educ = 1:20)
d.plot$mfp <- predict(fit.mfp, newdata = d.plot)
Here, I get an error in the predict function. I think the reason is that exper is constant and therefore transform_vector_fp() does not add the second power because it thinks it is a binary variable. Is this intended? I think this check should only be necessary when fitting a model, but not when preparing newdata for prediction.
I think a quick way to fix it could be to add a ... in prepare_newdata_for_predict() so that I could add check_binary = FALSE when calling predict(). But not sure if this is the best way to deal with this.
I think I found a bug in
predict.mfp2()
. See the following code:Here, I get an error in the predict function. I think the reason is that
exper
is constant and thereforetransform_vector_fp()
does not add the second power because it thinks it is a binary variable. Is this intended? I think this check should only be necessary when fitting a model, but not when preparingnewdata
for prediction.I think a quick way to fix it could be to add a
...
inprepare_newdata_for_predict()
so that I could addcheck_binary = FALSE
when callingpredict()
. But not sure if this is the best way to deal with this.