b
m<-lm(crim~.,data = Boston)
summary(m)
##
## Call:
## lm(formula = crim ~ ., data = Boston)
##
## Residuals:
## Min 1Q Median 3Q
## -9.9237390943432 -2.1197715348446 -0.3533348302087 1.0187970696539
## Max
## 75.0511785694575
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.0332275226344976 7.2349030308290310 2.35431 0.0189491
## zn 0.0448552146700317 0.0187340706387292 2.39431 0.0170249
## indus -0.0638548235877007 0.0834072406727293 -0.76558 0.4442940
## chas -0.7491336105105995 1.1801467723714198 -0.63478 0.5258670
## nox -10.3135349120666842 5.2755363149054073 -1.95497 0.0511520
## rm 0.4301305058640464 0.6128303094666474 0.70188 0.4830888
## age 0.0014516434361821 0.0179251276827142 0.08098 0.9354878
## dis -0.9871757255028882 0.2818172657905536 -3.50289 0.0005022
## rad 0.5882085914734919 0.0880492738506307 6.68045 6.4605e-11
## tax -0.0037800163848591 0.0051555868418552 -0.73319 0.4637927
## ptratio -0.2710805584722512 0.1864504941616461 -1.45390 0.1466113
## black -0.0075375048884921 0.0036733215239152 -2.05196 0.0407023
## lstat 0.1262113764594996 0.0757248372790315 1.66671 0.0962084
## medv -0.1988868212656190 0.0605159897520774 -3.28652 0.0010868
##
## (Intercept) *
## zn *
## indus
## chas
## nox .
## rm
## age
## dis ***
## rad ***
## tax
## ptratio
## black *
## lstat .
## medv **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 6.4391982739401996 on 492 degrees of freedom
## Multiple R-squared: 0.45401038980421, Adjusted R-squared: 0.43958383506327
## F-statistic: 31.470465260541 on 13 and 492 DF, p-value: < 2.22044604925e-16
c
uni.coe<-sapply(x, function(x) { m<-lm(Boston$crim ~ x)
m$coefficients[2]})
m<-lm(crim~.,data = Boston)
plot(uni.coe,m$coefficients[-1],ylab = 'full.coe')

d
lapply(x, function(x) { m<-lm(Boston$crim ~ x + I(x^2) + I(x^3))
summary(m)})
## $zn
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -4.8210700762792 -4.6140025762792 -1.2942050762792 0.4731790778097
## Max
## 84.1301499237209
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.8460500762791e+00 4.3298463654730e-01 11.19220 < 2.22e-16
## x -3.3218841472213e-01 1.0980813950251e-01 -3.02517 0.0026123
## I(x^2) 6.4826336527385e-03 3.8607278646367e-03 1.67912 0.0937505
## I(x^3) -3.7757925278318e-05 3.1386150894709e-05 -1.20301 0.2295386
##
## (Intercept) ***
## x **
## I(x^2) .
## I(x^3)
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 8.3722071728541003 on 502 degrees of freedom
## Multiple R-squared: 0.058241974222583, Adjusted R-squared: 0.052613938211961
## F-statistic: 10.348543277381 on 3 and 502 DF, p-value: 1.28129325849e-06
##
##
## $indus
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -8.2784560767506 -2.5135676346500 0.0535570375577 0.7639784915506
## Max
## 79.7127315155538
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.66256827868588397 1.57398333248029099 2.32694 0.020365
## x -1.96521293430683874 0.48199005778718990 -4.07729 5.2971e-05
## I(x^2) 0.25193729792732944 0.03932212447290314 6.40701 3.4202e-10
## I(x^3) -0.00697600854021407 0.00095665955969848 -7.29205 1.1964e-12
##
## (Intercept) *
## x ***
## I(x^2) ***
## I(x^3) ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 7.4231209547035002 on 502 degrees of freedom
## Multiple R-squared: 0.25965785791957, Adjusted R-squared: 0.25523350248881
## F-statistic: 58.688290754025 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $chas
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -3.7381268365181 -3.6607043365180 -3.4350468365180 0.0184248011829
## Max
## 85.2317531634820
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.74444683651805 0.39611112235384 9.45302 < 2e-16 ***
## x -1.89277655080378 1.50611548365537 -1.25673 0.20943
## I(x^2) NA NA NA NA
## I(x^3) NA NA NA NA
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 8.5966152647359007 on 504 degrees of freedom
## Multiple R-squared: 0.0031238689633056, Adjusted R-squared: 0.0011459401318836
## F-statistic: 1.5793636826962 on 1 and 504 DF, p-value: 0.2094345015352
##
##
## $nox
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -9.1099512146499 -2.0678263279106 -0.2547383146506 0.7387433349973
## Max
## 78.3024230170744
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 233.086590663052 33.643101169498 6.92821 1.3119e-11 ***
## x -1279.371251662180 170.397473255529 -7.50816 2.7584e-13 ***
## I(x^2) 2248.544052564005 279.899272947518 8.03340 6.8113e-15 ***
## I(x^3) -1245.702873746836 149.281639892936 -8.34465 6.9611e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 7.2336050301916996 on 502 degrees of freedom
## Multiple R-squared: 0.29697789562874, Adjusted R-squared: 0.29277656831178
## F-statistic: 70.686683808212 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $rm
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -18.4850427719025 -3.4675212148648 -2.2212421602579 -0.0148709586322
## Max
## 87.2185956762054
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 112.62459631864809 64.51723593751805 1.74565 0.081483 .
## x -39.15013633707651 31.31149150152691 -1.25034 0.211756
## I(x^2) 4.55089591485317 5.00986166730385 0.90839 0.364109
## I(x^3) -0.17447695018089 0.26374704610868 -0.66153 0.508575
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 8.329675785029 on 502 degrees of freedom
## Multiple R-squared: 0.067786061168787, Adjusted R-squared: 0.062215061534337
## F-statistic: 12.167665700356 on 3 and 502 DF, p-value: 1.0673927032238e-07
##
##
## $age
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -9.7624242923309 -2.6728191652813 -0.5163346187213 0.0189634733803
## Max
## 82.8422952372915
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.5487634036758e+00 2.7691404743808e+00 -0.92042 0.3577971
## x 2.7365313056117e-01 1.8637963541052e-01 1.46826 0.1426608
## I(x^2) -7.2295955756739e-03 3.6369953305316e-03 -1.98779 0.0473773
## I(x^3) 5.7453070396629e-05 2.1093552298322e-05 2.72373 0.0066799
##
## (Intercept)
## x
## I(x^2) *
## I(x^3) **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 7.8397026505126002 on 502 degrees of freedom
## Multiple R-squared: 0.17423099358657, Adjusted R-squared: 0.16929611904625
## F-statistic: 35.306063439518 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $dis
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -10.7567245560297 -2.5881570432624 0.0309925523167 1.2665308812104
## Max
## 76.3783926329046
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.047611563456542 2.445869712784547 12.28504 < 2.22e-16
## x -15.554353488051415 1.735967449587628 -8.96005 < 2.22e-16
## I(x^2) 2.452072169574368 0.346419441147264 7.07833 4.9412e-12
## I(x^3) -0.118598636902677 0.020400401592936 -5.81354 1.0888e-08
##
## (Intercept) ***
## x ***
## I(x^2) ***
## I(x^3) ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 7.331478998213 on 502 degrees of freedom
## Multiple R-squared: 0.27782477308674, Adjusted R-squared: 0.27350898487809
## F-statistic: 64.374051657638 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $rad
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -10.3805547092502 -0.4117729243100 -0.2690159062635 0.1788220744300
## Max
## 76.2170752907498
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.6055447455773891 2.0501076772804443 -0.29537 0.76783
## x 0.5127360382142074 1.0435967468264635 0.49132 0.62342
## I(x^2) -0.0751773634412612 0.1485430319742770 -0.50610 0.61301
## I(x^3) 0.0032089963744107 0.0045640098932814 0.70311 0.48231
##
## Residual standard error: 6.6824017464515997 on 502 degrees of freedom
## Multiple R-squared: 0.40003687202422, Adjusted R-squared: 0.39645143500445
## F-statistic: 111.57269527196 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $tax
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -13.2730275445485 -1.3891720336251 0.0456625600364 0.5360050624478
## Max
## 76.9495700951911
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.9183581466934e+01 1.1795546491086e+01 1.62634 0.10450
## x -1.5330961299173e-01 9.5678057374337e-02 -1.60235 0.10971
## I(x^2) 3.6082664616684e-04 2.4254627771577e-04 1.48766 0.13747
## I(x^3) -2.2037151311693e-07 1.8887051581871e-07 -1.16679 0.24385
##
## Residual standard error: 6.8537073690599 on 502 degrees of freedom
## Multiple R-squared: 0.36888207966296, Adjusted R-squared: 0.36511045862509
## F-statistic: 97.804651092733 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $ptratio
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -6.8334181714603 -4.1462619807084 -1.6548217553738 1.4076072966502
## Max
## 82.6970935033851
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 477.184046102470688 156.794977501185116 3.04336 0.0024621 **
## x -82.360537720755971 27.643942470939695 -2.97933 0.0030287 **
## I(x^2) 4.635347225616539 1.608321153573414 2.88210 0.0041196 **
## I(x^3) -0.084760322418781 0.030897492258947 -2.74328 0.0063005 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 8.1215830269989002 on 502 degrees of freedom
## Multiple R-squared: 0.11378157744695, Adjusted R-squared: 0.10848545141576
## F-statistic: 21.483925566876 on 3 and 502 DF, p-value: 4.1713144900396e-13
##
##
## $black
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -13.0962998882951 -2.3430458019337 -2.1280967498499 -1.4385817223205
## Max
## 86.7903187877959
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.8263700346007e+01 2.3049032642809e+00 7.92385 1.4971e-14
## x -8.3558047490680e-02 5.6327509777117e-02 -1.48343 0.13859
## I(x^2) 2.1374036896543e-04 2.9841927193253e-04 0.71624 0.47418
## I(x^3) -2.6524533116676e-07 4.3642636765405e-07 -0.60777 0.54362
##
## (Intercept) ***
## x
## I(x^2)
## I(x^3)
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 7.9546427351430999 on 502 degrees of freedom
## Multiple R-squared: 0.14983982880221, Adjusted R-squared: 0.14475919032891
## F-statistic: 29.492322586982 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $lstat
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -15.2335688128664 -2.1512725548201 -0.4864200593337 0.0657174964431
## Max
## 83.3529752353371
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.20096558118800822 2.02864515802087109 0.59200 0.554115
## x -0.44906558716479489 0.46489110921973897 -0.96596 0.334530
## I(x^2) 0.05577941585471223 0.03011560719835643 1.85218 0.064587 .
## I(x^3) -0.00085737033900152 0.00056516672120355 -1.51702 0.129891
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 7.6294360930289002 on 502 degrees of freedom
## Multiple R-squared: 0.21793243242226, Adjusted R-squared: 0.21325872185904
## F-statistic: 46.62942419618 on 3 and 502 DF, p-value: < 2.22044604925e-16
##
##
## $medv
##
## Call:
## lm(formula = Boston$crim ~ x + I(x^2) + I(x^3))
##
## Residuals:
## Min 1Q Median 3Q
## -24.4265770495305 -1.9755086043100 -0.4366109107804 0.4388915832577
## Max
## 73.6545621633528
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 53.16553809437311884 3.35631053507376631 15.84047 < 2.22e-16
## x -5.09483054344755804 0.43383205249650014 -11.74379 < 2.22e-16
## I(x^2) 0.15549649000059157 0.01719044221649928 9.04552 < 2.22e-16
## I(x^3) -0.00149010277183318 0.00020378954152637 -7.31197 1.0465e-12
##
## (Intercept) ***
## x ***
## I(x^2) ***
## I(x^3) ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.050000000000000003 '.'
## 0.10000000000000001 ' ' 1
##
## Residual standard error: 6.5691520012923004 on 502 degrees of freedom
## Multiple R-squared: 0.42020025656342, Adjusted R-squared: 0.41673531785762
## F-statistic: 121.27206055925 on 3 and 502 DF, p-value: < 2.22044604925e-16