Skip to content

Issue/ feature request: step.lmrobdetMM #9

@tobiasschoch

Description

@tobiasschoch

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions