> dim(bostonc) [1] 506 21 > names(bostonc) [1] "Obs" "Town" "Townno" "Tract" "Lon" "Lat" "Medv" [8] "Cmedv" "Crim" "Zn" "Indus" "Chas" "Nox" "Rm" [15] "Age" "Dis" "Rad" "Tax" "Ptratio" "B" "Lstat" > write.table(bostonc,"bostonc.txt") > x <- bostonc[,] > x[,"Rm2"] <- x[,"Rm"]^2 > x[,"Nox2"] <- x[,"Nox"]^2 > x[,"LogCmedv"] <- log(x[,"Cmedv"]) > xna <- c("Crim","Zn","Indus","Chas","Nox2","Rm2","Age","Dis","Rad","Tax","Ptratio","B","Lstat","LogCmedv") > bostondata <- x[,xna] > dim(bostondata) [1] 506 14 > names(bostondata) [1] "Crim" "Zn" "Indus" "Chas" "Nox2" "Rm2" [7] "Age" "Dis" "Rad" "Tax" "Ptratio" "B" [13] "Lstat" "LogCmedv" > write.table(bostondata,"bostondata.txt") > a <- lm(LogCmedv~.,bostondata) > summary(a) Call: lm(formula = LogCmedv ~ ., data = bostondata) Residuals: Min 1Q Median 3Q Max -0.72917 -0.09510 -0.01151 0.08944 0.86119 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.0570899 0.1438249 28.209 < 2e-16 *** Crim -0.0101775 0.0012790 -7.957 1.22e-14 *** Zn 0.0012167 0.0005349 2.275 0.02336 * Indus 0.0028600 0.0023911 1.196 0.23224 Chas 0.1018526 0.0335716 3.034 0.00254 ** Nox2 -0.5695311 0.1109699 -5.132 4.13e-07 *** Rm2 0.0081943 0.0012592 6.508 1.88e-10 *** Age -0.0000446 0.0005083 -0.088 0.93013 Dis -0.0460458 0.0076691 -6.004 3.74e-09 *** Rad 0.0132174 0.0025796 5.124 4.31e-07 *** Tax -0.0006288 0.0001464 -4.295 2.10e-05 *** Ptratio -0.0359785 0.0051508 -6.985 9.29e-12 *** B 0.0004136 0.0001045 3.958 8.67e-05 *** Lstat -0.0283357 0.0019653 -14.418 < 2e-16 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 0.1847 on 492 degrees of freedom Multiple R-Squared: 0.8005, Adjusted R-squared: 0.7953 F-statistic: 151.9 on 13 and 492 DF, p-value: < 2.2e-16 > bostondata[c(9,72,89,130,164,269,343,373,451,477),] Crim Zn Indus Chas Nox2 Rm2 Age Dis Rad Tax Ptratio 9 0.21124 12.5 7.87 0 0.274576 31.70816 100.0 6.0821 5 311 15.2 72 0.15876 0.0 10.81 0 0.170569 35.53352 17.5 5.2873 4 305 19.2 89 0.05660 0.0 3.41 0 0.239121 49.09805 86.3 3.4217 2 270 17.8 130 0.88125 0.0 21.89 0 0.389376 31.77577 94.7 1.9799 4 437 21.2 164 1.51902 0.0 19.58 1 0.366025 70.14062 93.9 2.1620 5 403 14.7 269 0.54050 20.0 3.97 0 0.330625 55.80090 52.6 2.8720 5 264 13.0 343 0.02498 0.0 1.89 0 0.268324 42.77160 59.7 6.2669 1 422 15.9 373 8.26725 0.0 18.10 1 0.446224 34.51562 89.6 1.1296 24 666 20.2 451 6.71772 0.0 18.10 0 0.508369 45.54900 92.6 2.3236 24 666 20.2 477 4.87141 0.0 18.10 0 0.376996 42.04226 93.6 2.3053 24 666 20.2 B Lstat LogCmedv 9 386.63 29.93 2.803360 72 376.94 9.88 3.077312 89 396.90 5.50 3.161247 130 396.90 18.34 2.660260 164 388.45 3.32 3.912023 269 390.30 3.16 3.772761 343 389.96 8.65 2.803360 373 347.88 8.88 3.912023 451 0.32 17.44 2.595255 477 396.21 18.68 2.815409