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("car-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('car') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "Anova" > > ### * Anova > > flush(stderr()); flush(stdout()) > > ### Name: Anova > ### Title: Anova Tables for Linear and Generalized Linear Models > ### Aliases: Anova Anova.lm Anova.aov Anova.II.lm Anova.III.lm Anova.glm > ### Anova.II.F.glm Anova.II.LR.glm Anova.II.Wald.glm Anova.III.F.glm > ### Anova.III.LR.glm Anova.III.Wald.glm Anova.multinom Anova.II.multinom > ### Anova.III.multinom Anova.polr Anova.II.polr Anova.III.polr > ### Keywords: htest models regression > > ### ** Examples > > data(Moore) > mod<-lm(conformity~fcategory*partner.status, data=Moore, + contrasts=list(fcategory=contr.sum, partner.status=contr.sum)) > Anova(mod) Anova Table (Type II tests) Response: conformity Sum Sq Df F value Pr(>F) fcategory 11.61 2 0.2770 0.759564 partner.status 212.21 1 10.1207 0.002874 ** fcategory:partner.status 175.49 2 4.1846 0.022572 * Residuals 817.76 39 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ## Anova Table (Type II tests) > ## > ## Response: conformity > ## Sum Sq Df F value Pr(>F) > ## fcategory 11.61 2 0.2770 0.759564 > ## partner.status 212.21 1 10.1207 0.002874 > ## fcategory:partner.status 175.49 2 4.1846 0.022572 > ## Residuals 817.76 39 > Anova(mod, type="III") Anova Table (Type III tests) Response: conformity Sum Sq Df F value Pr(>F) (Intercept) 5752.8 1 274.3592 < 2.2e-16 *** fcategory 36.0 2 0.8589 0.431492 partner.status 239.6 1 11.4250 0.001657 ** fcategory:partner.status 175.5 2 4.1846 0.022572 * Residuals 817.8 39 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ## Anova Table (Type III tests) > ## > ## Response: conformity > ## Sum Sq Df F value Pr(>F) > ## (Intercept) 5752.8 1 274.3592 < 2.2e-16 > ## fcategory 36.0 2 0.8589 0.431492 > ## partner.status 239.6 1 11.4250 0.001657 > ## fcategory:partner.status 175.5 2 4.1846 0.022572 > ## Residuals 817.8 39 > > > > cleanEx(); ..nameEx <- "Ask" > > ### * Ask > > flush(stderr()); flush(stdout()) > > ### Name: Ask > ### Title: Change Argument to a Function Interactively > ### Aliases: Ask > ### Keywords: iplot misc > > ### ** Examples > > ## Not run: > ##D data(UN) > ##D attach(UN) > ##D > ##D # enter the power-transformation parameter > ##D # start with 1 > ##D Ask(p, function(p) qq.plot(box.cox(gdp, p), > ##D ylab=paste("transformed gdp, power =",p))) > ##D > ##D # enter an expression that evaluates to a 2-vector > ##D # of powers; e.g., start with c(1,1); then interactively > ##D # identify points in each plot > ##D Ask(p, function(p) scatterplot(box.cox(gdp,p[1]), > ##D box.cox(infant.mortality, p[2]), > ##D xlab=paste("transformed GDP/capita, power =",p[1]), > ##D ylab=paste("transformed infant mortality, power =",p[2]), > ##D labels=rownames(UN))) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "Contrasts" > > ### * Contrasts > > flush(stderr()); flush(stdout()) > > ### Name: Contrasts > ### Title: Functions to Construct Contrasts > ### Aliases: Contrasts contr.Treatment contr.Sum contr.Helmert > ### Keywords: models regression > > ### ** Examples > > # contr.Treatment vs. contr.treatment in the base package: > > data(Prestige) > lm(prestige ~ (income + education)*type, data=Prestige, + contrasts=list(type="contr.Treatment")) Call: lm(formula = prestige ~ (income + education) * type, data = Prestige, contrasts = list(type = "contr.Treatment")) Coefficients: (Intercept) income education 2.275753 0.003522 1.713275 type[T.prof] type[T.wc] income:type[T.prof] 15.351896 -33.536652 -0.002903 income:type[T.wc] education:type[T.prof] education:type[T.wc] -0.002072 1.387809 4.290875 > > ## Call: > ## lm(formula = prestige ~ (income + education) * type, data = Prestige, > ## contrasts = list(type = "contr.Treatment")) > ## > ## Coefficients: > ## (Intercept) income education > ## 2.275753 0.003522 1.713275 > ## type[T.prof] type[T.wc] income:type[T.prof] > ## 15.351896 -33.536652 -0.002903 > ## income:type[T.wc] education:type[T.prof] education:type[T.wc] > ## -0.002072 1.387809 4.290875 > > lm(prestige ~ (income + education)*type, data=Prestige, + contrasts=list(type="contr.treatment")) Call: lm(formula = prestige ~ (income + education) * type, data = Prestige, contrasts = list(type = "contr.treatment")) Coefficients: (Intercept) income education typeprof 2.275753 0.003522 1.713275 15.351896 typewc income:typeprof income:typewc education:typeprof -33.536652 -0.002903 -0.002072 1.387809 education:typewc 4.290875 > > ## Call: > ## lm(formula = prestige ~ (income + education) * type, data = Prestige, > ## contrasts = list(type = "contr.treatment")) > ## > ## Coefficients: > ## (Intercept) income education > ## 2.275753 0.003522 1.713275 > ## typeprof typewc income:typeprof > ## 15.351896 -33.536652 -0.002903 > ## income:typewc education:typeprof education:typewc > ## -0.002072 1.387809 4.290875 > > > > cleanEx(); ..nameEx <- "Ellipses" > > ### * Ellipses > > flush(stderr()); flush(stdout()) > > ### Name: Ellipses > ### Title: Ellipses, Data Ellipses, and Confidence Ellipses > ### Aliases: ellipse data.ellipse confidence.ellipse confidence.ellipse.lm > ### confidence.ellipse.glm > ### Keywords: hplot aplot > > ### ** Examples > > data(Prestige) > attach(Prestige) > data.ellipse(income, education, levels=0.1*1:9, lty=2) > confidence.ellipse(lm(prestige~income+education), Scheffe=TRUE) > > > > cleanEx(); ..nameEx <- "Transformation.Axes" > > ### * Transformation.Axes > > flush(stderr()); flush(stdout()) > > ### Name: Transformation Axes > ### Title: Axes for Transformed Variables > ### Aliases: power.axis box.cox.axis prob.axis > ### Keywords: aplot > > ### ** Examples > > data(UN) > UN<-na.omit(UN) > attach(UN) > par(mar=c(5, 4, 4, 4)+.1) > > plot(log(gdp, 10), log(infant.mortality, 10)) > power.axis(0, base=10, side="above", + at=c(50,200,500,2000,5000,20000),grid=TRUE, axis.title="GDP per capita") > power.axis(0, base=10, side="right", + at=c(5,10,20,50,100), grid=TRUE, axis.title="infant mortality rate per 1000") > > plot(box.cox(gdp, 0), box.cox(infant.mortality, 0)) > box.cox.axis(0, side="above", + grid=TRUE, axis.title="GDP per capita") > box.cox.axis(0, side="right", + grid=TRUE, axis.title="infant mortality rate per 1000") > > qq.plot(logit(infant.mortality/1000)) > prob.axis() > > qq.plot(logit(infant.mortality/1000)) > prob.axis(c(.005, .01, .02, .04, .08, .16)) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "Var" > > ### * Var > > flush(stderr()); flush(stdout()) > > ### Name: Var > ### Title: Variance-Covariance Matrices (deprecated) > ### Aliases: Var Var.default Var.lm Var.glm > ### Keywords: misc > > ### ** Examples > > data(Davis) > attach(Davis) > Var(cbind(weight, repwt), na.rm=TRUE) weight repwt weight 233.8781 176.1014 repwt 176.1014 189.7966 > ## weight repwt > ## weight 233.8781 176.1014 > ## repwt 176.1014 189.7966 > > Var(lm(weight~repwt)) (Intercept) repwt (Intercept) 9.2228211 -0.134640952 repwt -0.1346410 0.002051736 > ## (Intercept) repwt > ## (Intercept) 9.2228211 -0.134640952 > ## repwt -0.1346410 0.002051736 > > > > cleanEx(); ..nameEx <- "av.plots" > > ### * av.plots > > flush(stderr()); flush(stdout()) > > ### Name: av.plots > ### Title: Added-Variable Plots > ### Aliases: av.plots avp av.plot av.plot.lm av.plot.glm > ### Keywords: hplot regression > > ### ** Examples > > ## Not run: > ##D data(Duncan) > ##D av.plots(lm(prestige~income+education+type, data=Duncan)) > ##D > ##D data(Womenlf) > ##D av.plots(glm(partic != "not.work" ~ hincome + children, > ##D data=Womenlf, family=binomial)) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "box.cox" > > ### * box.cox > > flush(stderr()); flush(stdout()) > > ### Name: box.cox > ### Title: Box-Cox Family of Transformations > ### Aliases: box.cox bc > ### Keywords: manip regression > > ### ** Examples > > box.cox(1:10, 2) [1] 0.0 1.5 4.0 7.5 12.0 17.5 24.0 31.5 40.0 49.5 > ## [1] 0.0 1.5 4.0 7.5 12.0 17.5 24.0 31.5 40.0 49.5 > box.cox(-5:5, 2) Warning in box.cox(-5:5, 2) : start = 6 added to data prior to transformation [1] 0.0 1.5 4.0 7.5 12.0 17.5 24.0 31.5 40.0 49.5 60.0 > ## [1] 0.0 1.5 4.0 7.5 12.0 17.5 24.0 31.5 40.0 49.5 60.0 > ## Warning message: > ## start = 6 added to data prior to transformation in: box.cox(-5:5, 2) > options(digits=4) > box.cox(-5:5, 0, start=6) [1] 0.0000 0.6931 1.0986 1.3863 1.6094 1.7918 1.9459 2.0794 2.1972 2.3026 [11] 2.3979 > ## [1] 0.0000 0.6931 1.0986 1.3863 1.6094 1.7918 1.9459 2.0794 2.1972 > ## [10] 2.3026 2.3979 > > > > cleanEx(); ..nameEx <- "box.cox.powers" > > ### * box.cox.powers > > flush(stderr()); flush(stdout()) > > ### Name: box.cox.powers > ### Title: Multivariate Unconditional Box-Cox Transformations > ### Aliases: box.cox.powers print.box.cox.powers summary.box.cox.powers > ### Keywords: multivariate models > > ### ** Examples > > data(Prestige) > attach(Prestige) > box.cox.powers(cbind(income, education)) Box-Cox Transformations to Multinormality Est.Power Std.Err. Wald(Power=0) Wald(Power=1) income 0.2617 0.1014 2.580 -7.280 education 0.4242 0.4033 1.052 -1.428 L.R. test, all powers = 0: 7.694 df = 2 p = 0.0213 L.R. test, all powers = 1: 48.8727 df = 2 p = 0 > ## Box-Cox Transformations to Multinormality > ## > ## Est.Power Std.Err. Wald(Power=0) Wald(Power=1) > ## income 0.2617 0.1014 2.580 -7.280 > ## education 0.4242 0.4033 1.052 -1.428 > ## > ## L.R. test, all powers = 0: 7.694 df = 2 p = 0.0213 > ## L.R. test, all powers = 1: 48.8727 df = 2 p = 0 > plot(income, education) > plot(box.cox(income, .26), box.cox(education, .42)) > > box.cox.powers(income) Box-Cox Transformation to Normality Est.Power Std.Err. Wald(Power=0) Wald(Power=1) 0.1793 0.1108 1.618 -7.406 L.R. test, power = 0: 2.7103 df = 1 p = 0.0997 L.R. test, power = 1: 47.261 df = 1 p = 0 > ## Box-Cox Transformation to Normality > ## > ## Est.Power Std.Err. Wald(Power=0) Wald(Power=1) > ## 0.1793 0.1108 1.618 -7.406 > ## > ## L.R. test, power = 0: 2.7103 df = 1 p = 0.0997 > ## L.R. test, power = 1: 47.261 df = 1 p = 0 > qq.plot(income) > qq.plot(income^.18) > > > > cleanEx(); ..nameEx <- "box.cox.var" > > ### * box.cox.var > > flush(stderr()); flush(stdout()) > > ### Name: box.cox.var > ### Title: Constructed Variable for Box-Cox Transformation > ### Aliases: box.cox.var > ### Keywords: manip regression > > ### ** Examples > > data(Ornstein) > mod<-lm(interlocks+1~assets, data=Ornstein) > mod.aux<-update(mod, .~.+box.cox.var(interlocks+1)) > summary(mod.aux) Call: lm(formula = interlocks + 1 ~ assets + box.cox.var(interlocks + 1), data = Ornstein) Residuals: Min 1Q Median 3Q Max -23.189 -6.701 0.541 6.773 12.051 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.46e+01 5.43e-01 26.9 <2e-16 *** assets -7.14e-05 5.12e-05 -1.4 0.16 box.cox.var(interlocks + 1) 7.43e-01 4.14e-02 18.0 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 7.25 on 245 degrees of freedom Multiple R-Squared: 0.799, Adjusted R-squared: 0.797 F-statistic: 486 on 2 and 245 DF, p-value: <2e-16 > ## Call: > ## lm(formula = interlocks + 1 ~ assets + box.cox.var(interlocks + > ## 1), data = Ornstein) > ## > ## Residuals: > ## Min 1Q Median 3Q Max > ## -23.189 -6.701 0.541 6.773 12.051 > ## > ## Coefficients: > ## Estimate Std. Error t value Pr(>|t|) > ## (Intercept) 1.461e+01 5.426e-01 26.920 <2e-16 > ## assets -7.142e-05 5.119e-05 -1.395 0.164 > ## box.cox.var(interlocks + 1) 7.427e-01 4.136e-02 17.956 <2e-16 > ## > ## Residual standard error: 7.247 on 245 degrees of freedom > ## Multiple R-Squared: 0.7986, Adjusted R-squared: 0.797 > ## F-statistic: 485.7 on 2 and 245 degrees of freedom, p-value: 0 > av.plots(mod.aux, "box.cox.var(interlocks + 1)") numeric(0) > > > > cleanEx(); ..nameEx <- "box.tidwell" > > ### * box.tidwell > > flush(stderr()); flush(stdout()) > > ### Name: box.tidwell > ### Title: Box-Tidwell Transformations > ### Aliases: box.tidwell box.tidwell.formula box.tidwell.default > ### print.box.tidwell > ### Keywords: regression > > ### ** Examples > > data(Prestige) > box.tidwell(prestige~income+education, ~ poly(women,2), data=Prestige) income education Initial Power -0.91030 2.24354 Score Statistic -5.30129 2.40556 p-value 0.00000 0.01615 MLE of Power -0.03777 2.19283 iterations = 12 > ## income education > ## Initial Power -0.91030 2.24354 > ## Score Statistic -5.30129 2.40556 > ## p-value 0.00000 0.01615 > ## MLE of Power -0.03777 2.19283 > > > > cleanEx(); ..nameEx <- "ceres.plots" > > ### * ceres.plots > > flush(stderr()); flush(stdout()) > > ### Name: ceres.plots > ### Title: Ceres Plots > ### Aliases: ceres.plots ceres.plot ceres.plot.lm ceres.plot.glm > ### Keywords: hplot regression > > ### ** Examples > > ## Not run: > ##D data(Prestige) > ##D ceres.plots(lm(prestige~income+education+type, data=Prestige)) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "cookd" > > ### * cookd > > flush(stderr()); flush(stdout()) > > ### Name: Cook's Distances > ### Title: Cook's Distances for Linear and Generalized Linear Models > ### Aliases: cookd > ### Keywords: regression models > > ### ** Examples > > data(Duncan) > attach(Duncan) > mod <- lm(prestige ~ income + education) > plot(cookd(mod)) > > > > cleanEx(); ..nameEx <- "cr.plots" > > ### * cr.plots > > flush(stderr()); flush(stdout()) > > ### Name: cr.plots > ### Title: Component+Residual (Partial Residual) Plots > ### Aliases: cr.plots crp cr.plot cr.plot.lm cr.plot.glm > ### Keywords: hplot regression > > ### ** Examples > > ## Not run: > ##D data(Womenlf) > ##D cr.plots(glm(partic != "not.work" ~ hincome + children, > ##D data=Womenlf, family=binomial)) > ##D > ##D data(Prestige) > ##D cr.plots(lm(prestige~income+education, data=Prestige), > ##D variable="income") > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "durbin.watson" > > ### * durbin.watson > > flush(stderr()); flush(stdout()) > > ### Name: durbin.watson > ### Title: Durbin-Watson Test for Autocorrelated Errors > ### Aliases: durbin.watson durbin.watson.lm durbin.watson.default > ### print.durbin.watson > ### Keywords: regression ts > > ### ** Examples > > data(Hartnagel) > durbin.watson(lm(fconvict ~ tfr + partic + degrees + mconvict, data=Hartnagel)) lag Autocorrelation D-W Statistic p-value 1 0.6883 0.6169 0 Alternative hypothesis: rho != 0 > ## lag Autocorrelation D-W Statistic p-value > ## 1 0.688345 0.6168636 0 > ## Alternative hypothesis: rho != 0 > > > > cleanEx(); ..nameEx <- "hccm" > > ### * hccm > > flush(stderr()); flush(stdout()) > > ### Name: hccm > ### Title: Heteroscedasticity-Corrected Covariance Matrices > ### Aliases: hccm hccm.lm hccm.default > ### Keywords: regression > > ### ** Examples > > options(digits=4) > data(Ornstein) > mod<-lm(interlocks~assets+nation, data=Ornstein) > Var(mod) (Intercept) assets nationOTH nationUK nationUS (Intercept) 1.079e+00 -1.588e-05 -1.037e+00 -1.057e+00 -1.032e+00 assets -1.588e-05 1.642e-09 1.155e-05 1.362e-05 1.109e-05 nationOTH -1.037e+00 1.155e-05 7.019e+00 1.021e+00 1.003e+00 nationUK -1.057e+00 1.362e-05 1.021e+00 7.405e+00 1.017e+00 nationUS -1.032e+00 1.109e-05 1.003e+00 1.017e+00 2.128e+00 > ## (Intercept) assets nationOTH nationUK nationUS > ## (Intercept) 1.079e+00 -1.588e-05 -1.037e+00 -1.057e+00 -1.032e+00 > ## assets -1.588e-05 1.642e-09 1.155e-05 1.362e-05 1.109e-05 > ## nationOTH -1.037e+00 1.155e-05 7.019e+00 1.021e+00 1.003e+00 > ## nationUK -1.057e+00 1.362e-05 1.021e+00 7.405e+00 1.017e+00 > ## nationUS -1.032e+00 1.109e-05 1.003e+00 1.017e+00 2.128e+00 > hccm(mod) (Intercept) assets nationOTH nationUK nationUS (Intercept) 1.664e+00 -3.957e-05 -1.569e+00 -1.611e+00 -1.572e+00 assets -3.957e-05 6.752e-09 2.275e-05 3.051e-05 2.231e-05 nationOTH -1.569e+00 2.275e-05 8.209e+00 1.539e+00 1.520e+00 nationUK -1.611e+00 3.051e-05 1.539e+00 4.476e+00 1.543e+00 nationUS -1.572e+00 2.231e-05 1.520e+00 1.543e+00 1.946e+00 > ## (Intercept) assets nationOTH nationUK nationUS > ## (Intercept) 1.664e+00 -3.957e-05 -1.569e+00 -1.611e+00 -1.572e+00 > ## assets -3.957e-05 6.752e-09 2.275e-05 3.051e-05 2.231e-05 > ## nationOTH -1.569e+00 2.275e-05 8.209e+00 1.539e+00 1.520e+00 > ## nationUK -1.611e+00 3.051e-05 1.539e+00 4.476e+00 1.543e+00 > ## nationUS -1.572e+00 2.231e-05 1.520e+00 1.543e+00 1.946e+00 > > > > cleanEx(); ..nameEx <- "influence.plot" > > ### * influence.plot > > flush(stderr()); flush(stdout()) > > ### Name: influence.plot > ### Title: Regression Influence Plot > ### Aliases: influence.plot influence.plot.lm > ### Keywords: regression > > ### ** Examples > > ## Not run: > ##D data(Duncan) > ##D influence.plot(lm(prestige ~ income + education, data=Duncan)) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "leverage.plots" > > ### * leverage.plots > > flush(stderr()); flush(stdout()) > > ### Name: leverage.plots > ### Title: Regression Leverage Plots > ### Aliases: leverage.plots leverage.plot leverage.plot.lm > ### leverage.plot.glm > ### Keywords: hplot regression > > ### ** Examples > > ## Not run: > ##D data(Duncan) > ##D leverage.plots(lm(prestige~(income+education)*type, data=Duncan)) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "linear.hypothesis" > > ### * linear.hypothesis > > flush(stderr()); flush(stdout()) > > ### Name: linear.hypothesis > ### Title: Test Linear Hypothesis > ### Aliases: linear.hypothesis lht linear.hypothesis.lm > ### linear.hypothesis.glm > ### Keywords: htest models regression > > ### ** Examples > > data(Davis) > mod<-lm(weight~repwt, data=Davis) > linear.hypothesis(mod, diag(2), c(0,1)) Linear hypothesis test Model 1: weight ~ repwt Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 181 12828 2 183 13074 -2 -246 1.74 0.18 > > ## use asymptotic Chi-squared statistic > linear.hypothesis(mod, diag(2), c(0,1), test = "Chisq") Linear hypothesis test Model 1: weight ~ repwt Model 2: restricted model Res.Df RSS Df Sum of Sq Chisq Pr(>Chisq) 1 181 12828 2 183 13074 -2 -246 3.47 0.18 > > ## use HC3 standard errors via > ## white.adjust option > linear.hypothesis(mod, diag(2), c(0,1), white.adjust = TRUE) Linear hypothesis test Model 1: weight ~ repwt Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 181 12828 2 183 13308 -2 -480 3.39 0.036 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ## covariance matrix *function* > linear.hypothesis(mod, diag(2), c(0,1), vcov = hccm) Linear hypothesis test Model 1: weight ~ repwt Model 2: restricted model Res.Df Df F Pr(>F) 1 181 2 183 -2 3.39 0.036 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ## covariance matrix *estimate* > linear.hypothesis(mod, diag(2), c(0,1), vcov = hccm(mod, type = "hc3")) Linear hypothesis test Model 1: weight ~ repwt Model 2: restricted model Res.Df Df F Pr(>F) 1 181 2 183 -2 3.39 0.036 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > > > cleanEx(); ..nameEx <- "logit" > > ### * logit > > flush(stderr()); flush(stdout()) > > ### Name: logit > ### Title: Logit Transformation > ### Aliases: logit > ### Keywords: manip > > ### ** Examples > > options(digits=4) > logit(.1*0:10) Warning in logit(0.1 * 0:10) : Proportions remapped to (0.025,0.975) [1] -3.6636 -1.9924 -1.2950 -0.8001 -0.3847 0.0000 0.3847 0.8001 1.2950 [10] 1.9924 3.6636 > ## [1] -3.6636 -1.9924 -1.2950 -0.8001 -0.3847 0.0000 0.3847 > ## [8] 0.8001 1.2950 1.9924 3.6636 > ## Warning message: > ## Proportions remapped to (0.025,0.975) in: logit(0.1 * 0:10) > > logit(.1*0:10, adjust=0) [1] -Inf -2.1972 -1.3863 -0.8473 -0.4055 0.0000 0.4055 0.8473 1.3863 [10] 2.1972 Inf > ## [1] -Inf -2.1972 -1.3863 -0.8473 -0.4055 0.0000 0.4055 > ## [8] 0.8473 1.3863 2.1972 Inf > > > > cleanEx(); ..nameEx <- "n.bins" > > ### * n.bins > > flush(stderr()); flush(stdout()) > > ### Name: n.bins > ### Title: Number of Bins for Histogram > ### Aliases: n.bins > ### Keywords: dplot > > ### ** Examples > > data(UN) > attach(UN) > n.bins(gdp) [1] 19 > ## [1] 19 > n.bins(gdp, "sturges") [1] 9 > ## [1] 9 > n.bins(gdp, "scott") [1] 8 > ## [1] 8 > n.bins(gdp, "simple") [1] 22 > ## [1] 22 > hist(gdp) > hist(gdp, nclass=n.bins(gdp)) > > > > cleanEx(); ..nameEx <- "ncv.test" > > ### * ncv.test > > flush(stderr()); flush(stdout()) > > ### Name: ncv.test > ### Title: Score Test for Non-Constant Error Variance > ### Aliases: ncv.test ncv.test.lm ncv.test.glm > ### Keywords: htest regression > > ### ** Examples > > data(Ornstein) > mod<-lm(interlocks~assets+sector+nation, data=Ornstein) > ncv.test(mod) $formula ~fitted.values $formula.name [1] "Variance" $ChiSquare [1] 46.99 $Df [1] 1 $p [1] 7.152e-12 $test [1] "Non-constant Variance Score Test" attr(,"class") [1] "chisq.test" > ## Non-constant Variance Score Test > ## Variance formula: ~ fitted.values > ## Chisquare = 46.98537 Df = 1 p = 7.151835e-12 > ncv.test(mod, ~ assets+sector+nation, data=Ornstein) $formula ~assets + sector + nation $formula.name [1] "Variance" $ChiSquare [1] 74.74 $Df [1] 13 $p [1] 1.066e-10 $test [1] "Non-constant Variance Score Test" attr(,"class") [1] "chisq.test" > ## Non-constant Variance Score Test > ## Variance formula: ~ assets + sector + nation > ## Chisquare = 74.73535 Df = 13 p = 1.066320e-10 > > > > cleanEx(); ..nameEx <- "outlier.test" > > ### * outlier.test > > flush(stderr()); flush(stdout()) > > ### Name: outlier.test > ### Title: Bonferroni Outlier Test > ### Aliases: outlier.test outlier.test.lm outlier.test.glm > ### print.outlier.test > ### Keywords: regression htest > > ### ** Examples > > data(Duncan) > outlier.test(lm(prestige~income+education, data=Duncan)) max|rstudent| = 3.135, degrees of freedom = 41, unadjusted p = 0.003177, Bonferroni p = 0.143 Observation: minister > ## max|rstudent| df unadjusted p Bonferroni p > ## 3.134519 41 0.003177202 0.1429741 > ## > ## Observation: minister > > > > cleanEx(); ..nameEx <- "panel.car" > > ### * panel.car > > flush(stderr()); flush(stdout()) > > ### Name: panel.car > ### Title: Panel Function Coplots > ### Aliases: panel.car > ### Keywords: aplot > > ### ** Examples > > data(Prestige) > coplot(prestige~income|education, panel=panel.car, + col="red", data=Prestige) > > > > cleanEx(); ..nameEx <- "qq.plot" > > ### * qq.plot > > flush(stderr()); flush(stdout()) > > ### Name: qq.plot > ### Title: Quantile-Comparison Plots > ### Aliases: qq.plot qqp qq.plot.default qq.plot.lm qq.plot.glm > ### Keywords: distribution univar regression > > ### ** Examples > > x<-rchisq(100, df=2) > qq.plot(x) > qq.plot(x, dist="chisq", df=2) > > data(Ornstein) > mod<-lm(interlocks~assets+sector+nation, data=Ornstein) > qq.plot(mod, sim=TRUE) numeric(0) > > > > cleanEx(); ..nameEx <- "recode" > > ### * recode > > flush(stderr()); flush(stdout()) > > ### Name: recode > ### Title: Recode a Variable > ### Aliases: recode > ### Keywords: manip > > ### ** Examples > > x<-rep(1:3,3) > x [1] 1 2 3 1 2 3 1 2 3 > ## [1] 1 2 3 1 2 3 1 2 3 > recode(x, "c(1,2)='A'; else='B'") [1] "A" "A" "B" "A" "A" "B" "A" "A" "B" > ## [1] "A" "A" "B" "A" "A" "B" "A" "A" "B" > recode(x, "1:2='A'; 3='B'") [1] "A" "A" "B" "A" "A" "B" "A" "A" "B" > ## [1] "A" "A" "B" "A" "A" "B" "A" "A" "B" > > > > cleanEx(); ..nameEx <- "reg.line" > > ### * reg.line > > flush(stderr()); flush(stdout()) > > ### Name: reg.line > ### Title: Plot Regression Line > ### Aliases: reg.line > ### Keywords: aplot > > ### ** Examples > > data(Davis) > attach(Davis) > mod.M<-lm(repwt~weight, subset=sex=="M") > mod.F<-lm(repwt~weight, subset=sex=="F") > plot(weight, repwt, pch=c(1,2)[sex]) > reg.line(mod.M) > reg.line(mod.F, lty=2) > > > > cleanEx(); ..nameEx <- "scatterplot" > > ### * scatterplot > > flush(stderr()); flush(stdout()) > > ### Name: scatterplot > ### Title: Scatterplots with Boxplots > ### Aliases: scatterplot scatterplot.formula scatterplot.default sp > ### Keywords: hplot > > ### ** Examples > > data(Prestige) > scatterplot(prestige ~ income|type, data=Prestige, span=1, legend=FALSE) > > data(Vocab) > scatterplot(vocabulary ~ education, jitter=list(x=1, y=1), data=Vocab) > > ## Not run: > ##D data(UN) > ##D scatterplot(infant.mortality ~ gdp, labels=row.names(UN), data=UN) > ##D > ##D scatterplot(infant.mortality ~ gdp, log="xy", labels=row.names(UN), data=UN) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "scatterplot.matrix" > > ### * scatterplot.matrix > > flush(stderr()); flush(stdout()) > > ### Name: scatterplot.matrix > ### Title: Scatterplot Matrices > ### Aliases: scatterplot.matrix scatterplot.matrix.formula > ### scatterplot.matrix.default spm > ### Keywords: hplot > > ### ** Examples > > data(Duncan) > scatterplot.matrix(~income + education + prestige | type, data=Duncan) > scatterplot.matrix(~income + education + prestige, + transform=TRUE, data=Duncan) > > > > cleanEx(); ..nameEx <- "some" > > ### * some > > flush(stderr()); flush(stdout()) > > ### Name: some > ### Title: Sample a Few Elements of an Object > ### Aliases: some some.data.frame some.matrix some.default > ### Keywords: utilities > > ### ** Examples > > some(data.frame(z=rnorm(100), u=runif(100))) z u 7 0.48743 0.5628 10 -0.30539 0.7179 17 -0.01619 0.6496 37 -0.39429 0.6894 45 -0.68876 0.4150 49 -0.11235 0.4601 68 1.46555 0.7547 76 0.29145 0.1922 95 1.58683 0.5069 96 0.55849 0.6814 > > > > cleanEx(); ..nameEx <- "spread.level.plot" > > ### * spread.level.plot > > flush(stderr()); flush(stdout()) > > ### Name: spread.level.plot > ### Title: Spread-Level Plots > ### Aliases: spread.level.plot slp spread.level.plot.formula > ### spread.level.plot.default spread.level.plot.lm > ### print.spread.level.plot > ### Keywords: hplot regression > > ### ** Examples > > data(Ornstein) > attach(Ornstein) > spread.level.plot(interlocks+1~nation) Loading required package: MASS LowerHinge Median UpperHinge Hinge-Spread US 2 6.0 13 11 UK 4 9.0 14 10 CAN 6 13.0 30 24 OTH 4 15.5 24 20 Suggested power transformation: 0.1534 > ## $Statistics > ## LowerHinge Median UpperHinge Hinge-Spread > ## US 2 6.0 13 11 > ## UK 4 9.0 14 10 > ## CAN 6 13.0 30 24 > ## OTH 4 15.5 24 20 > ## > ## $PowerTransformation > ## [1] 0.1534487 > mod<-lm(interlocks ~ assets + sector + nation) > slp(mod) Warning in spread.level.plot.lm(x, ...) : Start = 3 added to fitted values to avoid 0 or negative values. Suggested power transformation: 0.3222 > ## $PowerTransformation > ## [1] 0.3222165 > ## > ## Warning message: > ## Start = 3 added to fitted values to avoid 0 or negative values. in: spread.level.plot.lm(x, ...) > > > > cleanEx(); ..nameEx <- "subsets" > > ### * subsets > > flush(stderr()); flush(stdout()) > > ### Name: subsets > ### Title: Plot Output from regsubsets Function in leaps package > ### Aliases: subsets subsets.regsubsets > ### Keywords: hplot regression > > ### ** Examples > > ## Not run: > ##D library(leaps) > ##D data(Ericksen) > ##D subsets(regsubsets(undercount ~ ., data=Ericksen)) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "symbox" > > ### * symbox > > flush(stderr()); flush(stdout()) > > ### Name: symbox > ### Title: Boxplots for transformations to symmetry > ### Aliases: symbox > ### Keywords: hplot > > ### ** Examples > > data(Prestige) > symbox(Prestige$income) > > > > cleanEx(); ..nameEx <- "vif" > > ### * vif > > flush(stderr()); flush(stdout()) > > ### Name: vif > ### Title: Variance Inflation Factors > ### Aliases: vif vif.lm > ### Keywords: regression > > ### ** Examples > > data(Duncan) > vif(lm(prestige~income+education, data=Duncan)) income education 2.105 2.105 > ## income education > ## 2.104900 2.104900 > vif(lm(prestige~income+education+type, data=Duncan)) GVIF Df GVIF^(1/2Df) income 2.209 1 1.486 education 5.298 1 2.302 type 5.099 2 1.503 > ## GVIF Df GVIF^(1/2Df) > ## income 2.209178 1 1.486330 > ## education 5.297584 1 2.301648 > ## type 5.098592 2 1.502666 > > > > cleanEx(); ..nameEx <- "which.names" > > ### * which.names > > flush(stderr()); flush(stdout()) > > ### Name: which.names > ### Title: Position of Row Names > ### Aliases: which.names > ### Keywords: utilities > > ### ** Examples > > data(Duncan) > which.names(c('minister', 'conductor'), Duncan) [1] 6 16 > ## [1] 6 16 > > > > ### *