Skip to content
Prev 10855 / 20628 Next

plot log transformed variable with Effects package

Ben Bolker <bbolker at ...> writes:
with a bit more work, I have come up with a way to
hack the effects package to make this work.  The function below
needs to be defined, then the arguments of the effects:::mer.to.glm
function have to be changed from

function(mod, data=model.frame(mod))

to

function(mod, data=xdata(mod))

You can hack the package yourself and/or request the maintainer
to add this capability ...
                                    
## modeled after stats::expand.model.frame
## expand the model frame to include any variables present
## in the original 'data' object but missing from the model frame
## potentially fragile:
##  * depends on 'data' still being present in the original environment
##  * doesn't check for any potential mishaps
xdata <- function(model, envir=environment(formula(model))) {
    fr <- model.frame(model)
    data <- eval(getCall(model)$data,envir)
    ## find missing variables
    newvars <- setdiff(all.vars(formula(model)),names(fr))
    if (length(newvars)>0) {
        fr <- data.frame(fr,data[newvars],check.names=FALSE)
    }
    fr
}