R: Functions For Constructing Effect Displays for Many Modeling...

EffectMethods {effects} | R Documentation

## Functions For Constructing Effect Displays for Many Modeling Paradigms

### Description

The `Effect`, `effect` and `predictorEffects` methods are used to draw effects plots to visualize a fitted regression surface. These plots can be drawn at least in principle for any model that uses a linear predictor. Methods for modeling paradigms than the basic `lm`, `glm`, `multinom` and `polr` methods are documented here.

### Usage

    ## Default S3 method:
    Effect(focal.predictors, mod,  ...,
        sources=NULL)

    ## S3 method for class 'gls'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'clm2'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'clmm'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'clm'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'merMod'
    Effect(focal.predictors, mod, ...,
        KR=FALSE)

    ## S3 method for class 'rlmerMod'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'lme'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'poLCA'
    Effect(focal.predictors, mod, ...)

    ## S3 method for class 'mlm'
    Effect(focal.predictors, mod, response, ...)

    ## S3 method for class 'betareg'
    Effect(focal.predictors, mod,  ...)

### Arguments

`focal.predictors` | a character vector of one or more predictors in the model in any order.
`mod` | a fitted model object of the appropriate class.
`...` | additional arguments passed to other `Effect`. See `Effect` for all the arguments included.
`response` | for an `"mlm"` object, a vector containing the name(s) or indices of one or more response variable(s). The default is to use all responses in the model.
`sources` | This argument appears only in the default method for `Effect`, and allows the user to draw effects plots for fitting methods for which there are not existing methods in the effects package. Seven arguments are provided: type the default is `"glm"`, which assumes the modeling method shares characteristics with a generalized linear model, including a univariate response, a linear predictor, and possibly a error family and link function. call For S3 objects, the default is `ojbect$call`, returning the call that created the object. This is used to harvest standard arguments like `data`, `subset`, `family` an d`weights`. formula the formula for the linear predictor, defaulting to `formula(object)`. If the formula may include terms for random effects that will be ignored. family if the model object includes an error family, but it is not returned by `family(object)`, specify the family with this argument; otherwise it can be ignored. link if the model object has a link function but not a family, specify the link with this argument; otherwise it can be ignored. coefficients The estimates of the coefficents in the linear predictor, with default `coef(object)`. vcov the estimated variance covariance materix to be used in computing errors in the effects plots; default is codevcov(object).
`KR` | if `TRUE` and the pbkrtest package is installed, use the Kenward-Roger coefficient covariance matrix to compute effect standard errors for linear mixed models fit with `lmer` in the lme4 package. The default is `FALSE` because the computation can be very slow.

### Details

Most of these methods simply call the `Effect.default` method with the appropriate values in the arguement `sources`. See the vignettte Effect Methods in the vignettes for the effects package. All the iteresting work is done by the methods described in `Effect`.

### Value

See `Effect`

### Author(s)

John Fox jfox@mcmaster.ca, Sanford Weisberg sandy@umn.edu

### References

Vignette for this package

### See Also

`Effect` and the links therein.

### Examples

    ## Not run:
    # lme
    require(nlme)
    fm1 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
    plot(predictorEffects(fm1))

    # gls
    library(nlme)
    g <- gls(Employed ~ GNP + Population,
             correlation=corAR1(form= ~ Year), data=longley)
    print(predictorEffects(g))

    # lmer  uses method Effect.lmerMod
    if("package:nlme"
    require(lme4)
    data("Orthodont", package="nlme")
    fm2 <- lmer(distance ~ age + Sex + (1 |Subject), data = Orthodont)
    plot(allEffects(fm2))

    # glmer  uses method Effect.lmerMod
    require(lme4)
    gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
                  data = cbpp, family = binomial)
    as.data.frame(predictorEffect("period", gm1))

    # rlmer  uses method Effect.rlmerMod
    require(robustlmm)
    fm3 <- rlmer(distance ~ age + Sex + (1 |Subject), data = Orthodont)
    plot(effect("age:Sex", fm3))
    plot(predictorEffects(fm3, ~ age + Sex))

    # clm in ordinal
    require(ordinal)
    require(MASS)
    mod.wvs1 <- clm(poverty ~ gender + religion + degree + country*poly(age,3),data=WVS)
    plot(Effect(c("country", "age"), mod.wvs1), lines=list(multiline=TRUE))

    # clm2
    require(ordinal)
    require(MASS)
    v2 <- clm2(poverty ~ gender + religion + degree + country*poly(age,3),data=WVS)
    as.data.frame(emod2 <- Effect(c("country", "age"), v2))

    # clmm
    require(ordinal)
    require(MASS)
    mm1 <- clmm(SURENESS ~ PROD + (1|RESP) + (1|RESP:PROD), data = soup,
                link = "logit", threshold = "flexible")
    as.data.frame(Effect("PROD", mm1))

    # poLCA
    library(poLCA)
    data(election)
    f2a <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,
                 MORALB,CARESB,KNOWB,LEADB,DISHONB,INTELB)~PARTY
    nes2a <- poLCA(f2a,election,nclass=3,nrep=5)    # log-likelihood: -16222.32
    allEffects(nes2a)

    # betareg from the betareg package
    library(betareg)
    library(effects4)
    data("GasolineYield", package = "betareg")
    gy_logit <- betareg(yield ~ batch + temp, data = GasolineYield)
    summary(gy_logit)
    Effect("batch", gy_logit)
    predictorEffects(gy_logit)

    ## End(Not run)

[Package effects version 4.0-1 Index]