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("relimp-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('relimp') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "R.to.Tcl" > > ### * R.to.Tcl > > flush(stderr()); flush(stdout()) > > ### Name: R.to.Tcl > ### Title: Convert a Character Vector to Tcl Format > ### Aliases: R.to.Tcl > ### Keywords: utilities > > ### ** Examples > > R.to.Tcl(c("apple","banana")) [1] "{apple} {banana}" > > > > cleanEx(); ..nameEx <- "Tcl.to.R" > > ### * Tcl.to.R > > flush(stderr()); flush(stdout()) > > ### Name: Tcl.to.R > ### Title: Convert a Tcl List to R Character Vector > ### Aliases: Tcl.to.R > ### Keywords: utilities > > ### ** Examples > > Tcl.to.R("{apple} {banana} {pear}") [1] "apple" "banana" "pear" > > > > cleanEx(); ..nameEx <- "pickFrom" > > ### * pickFrom > > flush(stderr()); flush(stdout()) > > ### Name: pickFrom > ### Title: Pick Subsets from a Vector > ### Aliases: pickFrom > ### Keywords: utilities > > ### ** Examples > > ## This cannot be run by example() but should be OK when pasted > ## into an interactive R session > ## Not run: > ##D pickFrom(c("apple", "banana", "plum", "grapefruit"), nsets = 2, > ##D setlabels = c("Fruits I like", "Fruits I tolerate")) > ## End(Not run) > > > cleanEx(); ..nameEx <- "relimp" > > ### * relimp > > flush(stderr()); flush(stdout()) > > ### Name: relimp > ### Title: Relative Importance of Predictors in a Regression Model > ### Aliases: relimp print.relimp > ### Keywords: models regression > > ### ** Examples > > x <- rnorm(100) > z <- rnorm(100) > w <- rnorm(100) > y <- 3+ 2*x + z + w + rnorm(100) > test <- lm(y ~ x +z +w) > print(test) Call: lm(formula = y ~ x + z + w) Coefficients: (Intercept) x z w 3.053 1.942 0.945 1.105 > relimp(test, 2, 3) # compares effects of x and z Relative importance summary for model lm(formula = y ~ x + z + w) Numerator effects ("set1") Denominator effects ("set2") 1 x z Ratio of effect standard deviations: 1.927 Log(sd ratio): 0.656 (se 0.125) Approximate 95% confidence interval for log(sd ratio): (0.411,0.901) Approximate 95% confidence interval for sd ratio: (1.508,2.462) > relimp(test, 2, 3:4) # compares effect of x with that of (z,w) combined Relative importance summary for model lm(formula = y ~ x + z + w) Numerator effects ("set1") Denominator effects ("set2") 1 x z 2 w Ratio of effect standard deviations: 1.227 Log(sd ratio): 0.204 (se 0.092) Approximate 95% confidence interval for log(sd ratio): (0.025,0.384) Approximate 95% confidence interval for sd ratio: (1.025,1.468) > ## > ## Data on housing and satisfaction, from Venables and Ripley > ## -- multinomial logit model > library(MASS) > library(nnet) > data(housing) > house.mult <- multinom(Sat ~ Infl + Type + Cont, weights = Freq, + data = housing) # weights: 24 (14 variable) initial value 1846.767257 iter 10 value 1747.045232 final value 1735.041933 converged > relimp(house.mult, set1 = 2:3, set2 = 7, response.cat = "High") Relative importance summary for model multinom(formula = Sat ~ Infl + Type + Cont, data = housing, weights = Freq) response category High Numerator effects ("set1") Denominator effects ("set2") 1 InflMedium ContHigh 2 InflHigh Ratio of effect standard deviations: 2.736 Log(sd ratio): 1.007 (se 0.264) Approximate 95% confidence interval for log(sd ratio): (0.489,1.524) Approximate 95% confidence interval for sd ratio: (1.631,4.591) > > > > cleanEx(); ..nameEx <- "relrelimp" > > ### * relrelimp > > flush(stderr()); flush(stdout()) > > ### Name: relrelimp > ### Title: Comparison of Relative Importances in a Multinomial Logit Model > ### Aliases: relrelimp > ### Keywords: models regression > > ### ** Examples > > ## Data on housing and satisfaction, from Venables and Ripley > library(MASS) > library(nnet) > data(housing) > house.mult <- multinom(Sat ~ Infl + Type + Cont, weights = Freq, + data = housing) # weights: 24 (14 variable) initial value 1846.767257 iter 10 value 1747.045232 final value 1735.041933 converged > relrelimp(house.mult, set1 = 2:3, set2 = 7, + label1 = "Influence", label2 = "Contact", + response.cat1 = "Medium", response.cat2 = "High") $model multinom(formula = Sat ~ Infl + Type + Cont, data = housing, weights = Freq) $response.category [1] "Medium" "High" $dispersion NULL $sets $sets$Influence [1] "InflMedium" "InflHigh" $sets$Contact [1] "ContHigh" $log.ratio [1] 0.4276920 1.0066176 -0.5789257 $se.log.ratio [1] 0.4232093 0.2639887 0.3766682 attr(,"class") [1] "relrelimp" > ## Computes the relative contribution of Influence and Contact in > ## each of the two logistic regressions (Med/Low and High/Low), and > ## compares those two relative-contribution measures. > > > > cleanEx(); ..nameEx <- "showData" > > ### * showData > > flush(stderr()); flush(stdout()) > > ### Name: showData > ### Title: Display a Data Frame in a Tk Text Widget > ### Aliases: showData > ### Keywords: utilities > > ### ** Examples > > ## This cannot be run by example() but should be OK when pasted > ## into an interactive R session > ## Not run: > ##D data(mtcars) > ##D showData(mtcars) > ## End(Not run) > > > > ### *