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("qvcalc-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('qvcalc') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "indentPrint" > > ### * indentPrint > > flush(stderr()); flush(stdout()) > > ### Name: indentPrint > ### Title: Print with Line Indentation > ### Aliases: indentPrint > ### Keywords: IO > > ### ** Examples > > indentPrint("this indented by 10 spaces", indent=10) [1] "this indented by 10 spaces" > > > > cleanEx(); ..nameEx <- "qvcalc" > > ### * qvcalc > > flush(stderr()); flush(stdout()) > > ### Name: qvcalc > ### Title: Quasi Variances for Model Coefficients > ### Aliases: qvcalc summary.qv plot.qv > ### Keywords: models regression > > ### ** Examples > > ## Overdispersed Poisson loglinear model for ship damage data > ## from McCullagh and Nelder (1989), Sec 6.3.2 > library(MASS) > data(ships) > ships$year <- as.factor(ships$year) > ships$period <- as.factor(ships$period) > shipmodel <- glm(formula = incidents ~ type + year + period, + family = quasipoisson, + data = ships, subset = (service > 0), offset = log(service)) > shiptype.qvs <- qvcalc(shipmodel, "type") > summary(shiptype.qvs, digits=4) Model call: glm(formula = incidents ~ type + year + period, family = quasipoisson, data = ships, subset = (service > 0), offset = log(service)) Factor name: type estimate SE quasiSE quasiVar A 0.00000 0.0000 0.2010 0.04039 B -0.54334 0.2309 0.1127 0.01270 C -0.68740 0.4279 0.3752 0.14081 D -0.07596 0.3779 0.3239 0.10490 E 0.32558 0.3067 0.2322 0.05390 Worst relative errors in SEs of simple contrasts (%): -0.7 0.9 Worst relative errors over *all* contrasts (%): -2.1 1.6 > plot(shiptype.qvs) > ## Not run: > ##D ## Example of a negative quasi variance > ##D ## Requires the "car" package > ##D library(car) > ##D data(Prestige) > ##D attach(Prestige) > ##D mymodel <- lm(prestige ~ type + education) > ##D library(qvcalc) > ##D type.qvs <- qvcalc(mymodel, "type") > ##D ## Warning message: > ##D ## NaNs produced in: sqrt(qv) > ##D summary(type.qvs) > ##D ## Model call: lm(formula = prestige ~ type + education) > ##D ## Factor name: type > ##D ## estimate SE quasiSE quasiVar > ##D ## bc 0.000000 0.000000 2.874361 8.261952 > ##D ## prof 6.142444 4.258961 3.142737 9.876793 > ##D ## wc -5.458495 2.690667 NaN -1.022262 > ##D ## Worst relative errors in SEs of simple contrasts (%): 0 0 > ##D ## Worst relative errors over *all* contrasts (%): 0 0 > ##D plot(type.qvs) > ##D ## Error in plot.qv(type.qvs) : No comparison intervals available, > ##D ## since one of the quasi variances is negative. See ?qvcalc for more. > ## End(Not run) > > > > cleanEx(); ..nameEx <- "worstErrors" > > ### * worstErrors > > flush(stderr()); flush(stdout()) > > ### Name: worstErrors > ### Title: Accuracy of a Quasi-variance Approximation > ### Aliases: worstErrors > ### Keywords: regression models > > ### ** Examples > > ## Overdispersed Poisson loglinear model for ship damage data > ## from McCullagh and Nelder (1989), Sec 6.3.2 > library(MASS) > data(ships) > ships$year <- as.factor(ships$year) > ships$period <- as.factor(ships$period) > shipmodel <- glm(formula = incidents ~ type + year + period, + family = quasipoisson, + data = ships, subset = (service > 0), offset = log(service)) > shiptype.qvs <- qvcalc(shipmodel, "type") > summary(shiptype.qvs, digits=4) Model call: glm(formula = incidents ~ type + year + period, family = quasipoisson, data = ships, subset = (service > 0), offset = log(service)) Factor name: type estimate SE quasiSE quasiVar A 0.00000 0.0000 0.2010 0.04039 B -0.54334 0.2309 0.1127 0.01270 C -0.68740 0.4279 0.3752 0.14081 D -0.07596 0.3779 0.3239 0.10490 E 0.32558 0.3067 0.2322 0.05390 Worst relative errors in SEs of simple contrasts (%): -0.7 0.9 Worst relative errors over *all* contrasts (%): -2.1 1.6 > worstErrors(shiptype.qvs) [1] -0.02099427 0.01563661 > > > > ### *