Dear Matias,
If step.lmrobdetMM() is called in a function, it fails. For instance, consider this function:
test <- function(formula, dat) {
fm <- lmrobdetMM(formula, dat)
step.lmrobdetMM(fm, formula, "backward")
}
The call of test(formula = stack.loss ~ Air.Flow + Water.Temp + Acid.Conc., dat = stackloss) terminates with Error in eval(mf, parent.frame()) : object 'dat' not found.
The issue is due to the call of update() in Line 135 of function drop1.lmrobdetMM(); see here R/RFPE.R, that is
curobj <- update(object, curfrm)
If we replace this line by
curobj <- update(object, curfrm, data = object$model)
the issue is resolved. However, this change assumes that lmrobdetMM() has been called with argument model = TRUE, otherwise it fails. The current implementation does not impose this assumption. So, in order for the proposed change (feature request) to work correctly, we need (at least) a guard in step.lmrobdetMM() which checks that object$model is not NULL and otherwise terminates with an error. Another solution is something along the lines
curobj <- if(is.null(object$model))
update(object, curfrm)
else
update(object, curfrm, data = object$model)
However, I have not studied or tested this if-statement ... Beyond that, I have not looked into the problem in any greater detail.
Kind regards, Tobias
Dear Matias,
If
step.lmrobdetMM()is called in a function, it fails. For instance, consider this function:The call of
test(formula = stack.loss ~ Air.Flow + Water.Temp + Acid.Conc., dat = stackloss)terminates withError in eval(mf, parent.frame()) : object 'dat' not found.The issue is due to the call of
update()in Line 135 of functiondrop1.lmrobdetMM(); see here R/RFPE.R, that isIf we replace this line by
the issue is resolved. However, this change assumes that
lmrobdetMM()has been called with argumentmodel = TRUE, otherwise it fails. The current implementation does not impose this assumption. So, in order for the proposed change (feature request) to work correctly, we need (at least) a guard instep.lmrobdetMM()which checks thatobject$modelis notNULLand otherwise terminates with an error. Another solution is something along the linesHowever, I have not studied or tested this
if-statement ... Beyond that, I have not looked into the problem in any greater detail.Kind regards, Tobias