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("ellipse-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('ellipse') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ellipse" > > ### * ellipse > > flush(stderr()); flush(stdout()) > > ### Name: ellipse > ### Title: Make an ellipse > ### Aliases: ellipse ellipse.default > ### Keywords: dplot > > ### ** Examples > > # Plot an ellipse corresponding to a 95% probability region for a > # bivariate normal distribution with mean 0, unit variances and > # correlation 0.8. > plot(ellipse(0.8), type = 'l') > > > > cleanEx(); ..nameEx <- "ellipse.arima0" > > ### * ellipse.arima0 > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.arima0 > ### Title: Outline an approximate pairwise confidence region > ### Aliases: ellipse.arima0 > ### Keywords: dplot ts > > ### ** Examples > > data(USAccDeaths) > fit <- arima0(USAccDeaths, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1))) > # Plot the approximate 95% confidence region for the first two parameters > # of the model > plot(ellipse(fit), type = 'l') > points(fit$coef[1], fit$coef[2]) > > > > cleanEx(); ..nameEx <- "ellipse.glm" > > ### * ellipse.glm > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.glm > ### Title: Outline an approximate pairwise confidence region > ### Aliases: ellipse.glm > ### Keywords: dplot regression > > ### ** Examples > > ## Dobson (1990) Page 93: Randomized Controlled Trial : > > counts <- c(18,17,15,20,10,20,25,13,12) > outcome <- gl(3,1,9) > treatment <- gl(3,3) > glm.D93 <- glm(counts ~ outcome + treatment, family=poisson()) > > # Plot an approximate 95 % confidence region for the two Outcome parameters > > plot(ellipse(glm.D93, which = c(2,3)), type = 'l') > points(glm.D93$coefficients[2], glm.D93$coefficients[3]) > > > > cleanEx(); ..nameEx <- "ellipse.lm" > > ### * ellipse.lm > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.lm > ### Title: Outline a pairwise confidence region for a linear model fit. > ### Aliases: ellipse.lm > ### Keywords: dplot regression > > ### ** Examples > > # Plot the estimate and joint 90% confidence region for the displacement and cylinder > # count linear coefficients in the mtcars dataset > data(mtcars) > fit <- lm(mpg ~ disp + cyl , mtcars) > plot(ellipse(fit, which = c('disp', 'cyl'), level = 0.90), type = 'l') > points(fit$coefficients['disp'], fit$coefficients['cyl']) > > > > cleanEx(); ..nameEx <- "ellipse.nls" > > ### * ellipse.nls > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.nls > ### Title: Outline an approximate pairwise confidence region > ### Aliases: ellipse.nls > ### Keywords: dplot nonlinear > > ### ** Examples > > # Plot an approximate 95% confidence region for the weight and displacement > # parameters in the Michaelis Menten model > data(Puromycin) > fit <- nls(rate ~ Vm*conc/(K + conc), data = Puromycin, subset = state=="treated", + start = list(K = 0.05, Vm = 200)) > plot(ellipse(fit,which=c('Vm','K')), type = 'l') > params <- fit$m$getPars() > points(params['Vm'],params['K']) > > > > cleanEx(); ..nameEx <- "ellipse.profile" > > ### * ellipse.profile > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.profile > ### Title: Pairwise profile sketch > ### Aliases: ellipse.profile > ### Keywords: dplot models > > ### ** Examples > > # Plot an approximate 95% confidence region for the Puromycin > # parameters Vm and K, and overlay the ellipsoidal region > > data(Puromycin) > Purboth <- nls(formula = rate ~ ((Vm + delV * (state == "treated")) + * conc)/(K + conc), data = Puromycin, + start = list(Vm = 160, delV = 40, K = 0.05)) > Pur.prof <- profile(Purboth) > plot(ellipse(Pur.prof, which = c('Vm', 'K')), type = 'l') > lines(ellipse(Purboth, which = c('Vm', 'K')), lty = 2) > params <- Purboth$m$getPars() > points(params['Vm'],params['K']) > > > > cleanEx(); ..nameEx <- "ellipse.profile.glm" > > ### * ellipse.profile.glm > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.profile.glm > ### Title: Pairwise profile sketch for GLM profiles > ### Aliases: ellipse.profile.glm > ### Keywords: dplot models > > ### ** Examples > > ## MASS has a pairs.profile function that conflicts with ours, so > ## do a little trickery here > noMASS <- is.na(match('package:MASS', search())) > if (noMASS) require(MASS) Loading required package: MASS [1] TRUE > > ## Dobson (1990) Page 93: Randomized Controlled Trial : > > counts <- c(18,17,15,20,10,20,25,13,12) > outcome <- gl(3,1,9) > treatment <- gl(3,3) > glm.D93 <- glm(counts ~ outcome + treatment, family=poisson()) > > ## Plot an approximate 95% confidence region for the two outcome variables > prof.D93 <- profile(glm.D93) > plot(ellipse(prof.D93, which = 2:3), type = 'l') > lines(ellipse(glm.D93, which = 2:3), lty = 2) > params <- glm.D93$coefficients > points(params[2],params[3]) > > ## Clean up our trickery > if (noMASS) detach('package:MASS') > > > > > cleanEx(); ..nameEx <- "ellipse.profile.nls" > > ### * ellipse.profile.nls > > flush(stderr()); flush(stdout()) > > ### Name: ellipse.profile.nls > ### Title: Pairwise profile sketch > ### Aliases: ellipse.profile.nls > ### Keywords: dplot models > > ### ** Examples > > # Plot an approximate 95% confidence region for the Puromycin > # parameters Vm and K, and overlay the ellipsoidal region > data(Puromycin) > Purboth <- nls(formula = rate ~ ((Vm + delV * (state == "treated")) + * conc)/(K + conc), data = Puromycin, + start = list(Vm = 160, delV = 40, K = 0.05)) > Pur.prof <- profile(Purboth) > plot(ellipse(Pur.prof, which = c('Vm', 'K')), type = 'l') > lines(ellipse(Purboth, which = c('Vm', 'K')), lty = 2) > params <- Purboth$m$getPars() > points(params['Vm'],params['K']) > > > > cleanEx(); ..nameEx <- "pairs.profile" > > ### * pairs.profile > > flush(stderr()); flush(stdout()) > > ### Name: pairs.profile > ### Title: Profile pairs > ### Aliases: pairs.profile > ### Keywords: dplot regression nonlinear > > ### ** Examples > > # Plot everything for the Puromycin data > data(Puromycin) > Purboth <- nls(formula = rate ~ ((Vm + delV * (state == "treated")) + * conc)/(K + conc), data = Puromycin, + start = list(Vm = 160, delV = 40, K = 0.05)) > Pur.prof <- profile(Purboth) > pairs(Pur.prof, plot.ellipse = TRUE) > > > > cleanEx(); ..nameEx <- "plotcorr" > > ### * plotcorr > > flush(stderr()); flush(stdout()) > > ### Name: plotcorr > ### Title: Plot correlation matrix ellipses > ### Aliases: plotcorr > ### Keywords: hplot > > ### ** Examples > > save.par <- par(ask = interactive()) > > # Plot the correlation matrix for the mtcars data full model fit > data(mtcars) > fit <- lm(mpg ~ ., mtcars) > plotcorr(summary(fit, correlation = TRUE)$correlation) > > # Plot a second figure with numbers in place of the > # ellipses > plotcorr(summary(fit, correlation = TRUE)$correlation, numbers = TRUE) > > # Colour the ellipses to emphasize the differences > corr.mtcars <- cor(mtcars) > ord <- order(corr.mtcars[1,]) > xc <- corr.mtcars[ord, ord] > plotcorr(xc, col=cm.colors(11)[5*xc + 6]) > > plotcorr(xc, col=cm.colors(11)[5*xc + 6], type = "upper") > plotcorr(xc, col=cm.colors(11)[5*xc + 6], type = "lower", diag = TRUE) > par(save.par) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > ### *