R : Copyright 2001, The R Development Core Team Version 1.3.1 (2001-08-31) 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. 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. > data(cars) > carfit <- lm(dist ~ speed, data=cars) > summary(carfit) Call: lm(formula = dist ~ speed, data = cars) Residuals: Min 1Q Median 3Q Max -29.069 -9.525 -2.272 9.215 43.201 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -17.5791 6.7584 -2.601 0.0123 * speed 3.9324 0.4155 9.464 1.49e-12 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 15.38 on 48 degrees of freedom Multiple R-Squared: 0.6511, Adjusted R-squared: 0.6438 F-statistic: 89.57 on 1 and 48 DF, p-value: 1.49e-12 > plot(speed ~ dist, data=cars) > abline(carfit) > vcov <- summary(carfit)$sigma^2 * summary(carfit)$cov.unscaled > carfitunres <- lm(dist ~ speed + I(speed^2), data=cars) > carfitres <- lm(dist ~ speed, data=cars) > anova(carfitres,carfitunres) Analysis of Variance Table Model 1: dist ~ speed Model 2: dist ~ speed + I(speed^2) Res.Df RSS Df Sum of Sq F Pr(>F) 1 48 11353.5 2 47 10824.7 1 528.8 2.296 0.1364 > library(lmtest) > bptest(carfit) Breusch-Pagan-Test data: form1 BP = 4.3257, df = 2, p-value = 0.115 > dwtest(carfit) Durbin-Watson-Test data: DW = 1.6762, p-value = NA > carpred <- predict(carfit,se.fit=TRUE,interval="prediction") > carpred$fit[1,] fit lwr upr -1.84946 -34.49984 30.80092 >