R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("effects-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('effects') Loading required package: lattice Loading required package: grid > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "effect" > > ### * effect > > flush(stderr()); flush(stdout()) > > ### Name: effect > ### Title: Functions For Constructing Effect Plots > ### Aliases: effect effect.lm all.effects as.data.frame.effect > ### Keywords: hplot models > > ### ** Examples > > data(Cowles) > mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion, + data=Cowles, family=binomial) > eff.cowles <- all.effects(mod.cowles, xlevels=list(neuroticism=0:24, + extraversion=seq(0, 24, 6))) > eff.cowles model: volunteer ~ sex + neuroticism * extraversion sex effect sex female male 0.4409440 0.3811939 neuroticism*extraversion effect extraversion neuroticism 0 6 12 18 24 0 0.07801015 0.1871256 0.3851139 0.6301828 0.8225762 1 0.08635947 0.1963390 0.3870450 0.6200672 0.8083644 2 0.09550985 0.2058912 0.3889796 0.6098462 0.7933003 3 0.10551779 0.2157833 0.3909177 0.5995278 0.7773782 4 0.11643941 0.2260153 0.3928592 0.5891204 0.7605996 5 0.12832930 0.2365863 0.3948041 0.5786326 0.7429747 6 0.14123920 0.2474935 0.3967524 0.5680733 0.7245221 7 0.15521658 0.2587331 0.3987039 0.5574519 0.7052702 8 0.17030288 0.2702999 0.4006587 0.5467776 0.6852575 9 0.18653173 0.2821868 0.4026166 0.5360601 0.6645322 10 0.20392698 0.2943857 0.4045777 0.5253093 0.6431528 11 0.22250073 0.3068864 0.4065418 0.5145349 0.6211876 12 0.24225139 0.3196775 0.4085089 0.5037470 0.5987140 13 0.26316185 0.3327457 0.4104789 0.4929556 0.5758175 14 0.28519790 0.3460765 0.4124518 0.4821708 0.5525909 15 0.30830709 0.3596534 0.4144275 0.4714025 0.5291325 16 0.33241798 0.3734588 0.4164060 0.4606608 0.5055446 17 0.35744004 0.3874734 0.4183872 0.4499555 0.4819321 18 0.38326427 0.4016768 0.4203710 0.4392964 0.4584000 19 0.40976445 0.4160472 0.4223573 0.4286929 0.4350520 20 0.43679921 0.4305617 0.4243462 0.4181546 0.4119886 21 0.46421481 0.4451966 0.4263376 0.4076904 0.3893053 22 0.49184840 0.4599272 0.4283313 0.3973093 0.3670913 23 0.51953189 0.4747280 0.4303274 0.3870198 0.3454278 24 0.54709597 0.4895735 0.4323257 0.3768301 0.3243875 > ## Not run: > ##D model: volunteer ~ sex + neuroticism * extraversion > ##D > ##D sex effect > ##D sex > ##D female male > ##D 0.4409441 0.3811941 > ##D > ##D neuroticism*extraversion effect > ##D extraversion > ##D neuroticism 0 6 12 18 24 > ##D 0 0.07801066 0.1871263 0.3851143 0.6301824 0.8225756 > ##D 1 0.08636001 0.1963396 0.3870453 0.6200668 0.8083638 > ##D 2 0.09551039 0.2058918 0.3889798 0.6098458 0.7932997 > ##D 3 0.10551835 0.2157839 0.3909179 0.5995275 0.7773775 > ##D . . . > ##D 23 0.51953129 0.4747277 0.4303273 0.3870199 0.3454282 > ##D 24 0.54709527 0.4895731 0.4323256 0.3768303 0.3243880 > ##D > ## End(Not run) > plot(eff.cowles, 'sex', ylab="Prob(Volunteer)") > ## Not run: > ##D Loading required package: lattice > ##D > ## End(Not run) > > plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)", + ticks=list(at=c(.1,.25,.5,.75,.9))) > > plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE, + ylab="Prob(Volunteer)") > > plot(effect('sex:neuroticism:extraversion', mod.cowles, + xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))), multiline=TRUE) Warning in effect.lm("sex:neuroticism:extraversion", mod.cowles, xlevels = list(neuroticism = 0:24, : sex:neuroticism:extraversion does not appear in the model > ## Not run: > ##D Warning message: > ##D sex:neuroticism:extraversion does not appear in the model in: > ##D effect("sex:neuroticism:extraversion", mod.cowles, > ##D xlevels = list(neuroticism = 0:24, > ## End(Not run) > > data(Prestige) > mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2), + data=Prestige) > eff.pres <- all.effects(mod.pres, default.levels=50) > plot(eff.pres, ask=FALSE) > > > > > cleanEx(); ..nameEx <- "summary.effect" > > ### * summary.effect > > flush(stderr()); flush(stdout()) > > ### Name: summary.effect > ### Title: Summarizing, Printing, and Plotting Effects > ### Aliases: print.effect print.effect.list print.summary.effect > ### summary.effect summary.effect.list plot.effect plot.effect.list > ### Keywords: hplot models > > ### ** Examples > > data(Cowles) > mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion, + data=Cowles, family=binomial) > eff.cowles <- all.effects(mod.cowles, xlevels=list(neuroticism=0:24, + extraversion=seq(0, 24, 6))) > eff.cowles model: volunteer ~ sex + neuroticism * extraversion sex effect sex female male 0.4409440 0.3811939 neuroticism*extraversion effect extraversion neuroticism 0 6 12 18 24 0 0.07801015 0.1871256 0.3851139 0.6301828 0.8225762 1 0.08635947 0.1963390 0.3870450 0.6200672 0.8083644 2 0.09550985 0.2058912 0.3889796 0.6098462 0.7933003 3 0.10551779 0.2157833 0.3909177 0.5995278 0.7773782 4 0.11643941 0.2260153 0.3928592 0.5891204 0.7605996 5 0.12832930 0.2365863 0.3948041 0.5786326 0.7429747 6 0.14123920 0.2474935 0.3967524 0.5680733 0.7245221 7 0.15521658 0.2587331 0.3987039 0.5574519 0.7052702 8 0.17030288 0.2702999 0.4006587 0.5467776 0.6852575 9 0.18653173 0.2821868 0.4026166 0.5360601 0.6645322 10 0.20392698 0.2943857 0.4045777 0.5253093 0.6431528 11 0.22250073 0.3068864 0.4065418 0.5145349 0.6211876 12 0.24225139 0.3196775 0.4085089 0.5037470 0.5987140 13 0.26316185 0.3327457 0.4104789 0.4929556 0.5758175 14 0.28519790 0.3460765 0.4124518 0.4821708 0.5525909 15 0.30830709 0.3596534 0.4144275 0.4714025 0.5291325 16 0.33241798 0.3734588 0.4164060 0.4606608 0.5055446 17 0.35744004 0.3874734 0.4183872 0.4499555 0.4819321 18 0.38326427 0.4016768 0.4203710 0.4392964 0.4584000 19 0.40976445 0.4160472 0.4223573 0.4286929 0.4350520 20 0.43679921 0.4305617 0.4243462 0.4181546 0.4119886 21 0.46421481 0.4451966 0.4263376 0.4076904 0.3893053 22 0.49184840 0.4599272 0.4283313 0.3973093 0.3670913 23 0.51953189 0.4747280 0.4303274 0.3870198 0.3454278 24 0.54709597 0.4895735 0.4323257 0.3768301 0.3243875 > ## Not run: > ##D model: volunteer ~ sex + neuroticism * extraversion > ##D > ##D sex effect > ##D sex > ##D female male > ##D 0.4409441 0.3811941 > ##D > ##D neuroticism*extraversion effect > ##D extraversion > ##D neuroticism 0 6 12 18 24 > ##D 0 0.07801066 0.1871263 0.3851143 0.6301824 0.8225756 > ##D 1 0.08636001 0.1963396 0.3870453 0.6200668 0.8083638 > ##D 2 0.09551039 0.2058918 0.3889798 0.6098458 0.7932997 > ##D 3 0.10551835 0.2157839 0.3909179 0.5995275 0.7773775 > ##D . . . > ##D 23 0.51953129 0.4747277 0.4303273 0.3870199 0.3454282 > ##D 24 0.54709527 0.4895731 0.4323256 0.3768303 0.3243880 > ##D > ## End(Not run) > plot(eff.cowles, 'sex', ylab="Prob(Volunteer)") > ## Not run: > ##D Loading required package: lattice > ##D > ## End(Not run) > > plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)", + ticks=list(at=c(.1,.25,.5,.75,.9))) > > plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE, + ylab="Prob(Volunteer)") > > plot(effect('sex:neuroticism:extraversion', mod.cowles, + xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))), multiline=TRUE) Warning in effect.lm("sex:neuroticism:extraversion", mod.cowles, xlevels = list(neuroticism = 0:24, : sex:neuroticism:extraversion does not appear in the model > ## Not run: > ##D Warning message: > ##D sex:neuroticism:extraversion does not appear in the model in: > ##D effect("sex:neuroticism:extraversion", mod.cowles, > ##D xlevels = list(neuroticism = 0:24, > ## End(Not run) > > data(Prestige) > mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2), + data=Prestige) > eff.pres <- all.effects(mod.pres, default.levels=50) > plot(eff.pres, ask=FALSE) > > > > > ### *