多次元回帰分析 poly()
概要
poly()を使用して多次元回帰分析を行う。
ここでは三次、二次、一次をそれぞれ行っている。
> summary(lm(w$ppc ~ poly(w$t, 3, raw = TRUE)))
Call:
lm(formula = w$ppc ~ poly(w$t, 3, raw = TRUE))
Residuals:
Min 1Q Median 3Q Max
-2.5715 -1.3851 -0.4419 0.4873 8.8414
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.410e+03 5.033e+02 2.802 0.00758 **
poly(w$t, 3, raw = TRUE)1 -6.887e+00 2.608e+00 -2.641 0.01147 *
poly(w$t, 3, raw = TRUE)2 1.128e-02 4.469e-03 2.524 0.01538 *
poly(w$t, 3, raw = TRUE)3 -6.175e-06 2.536e-06 -2.434 0.01914 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.341 on 43 degrees of freedom
Multiple R-squared: 0.5928, Adjusted R-squared: 0.5644
F-statistic: 20.86 on 3 and 43 DF, p-value: 1.7e-08
> summary(lm(w$ppc ~ poly(w$t, 2, raw = TRUE)))
Call:
lm(formula = w$ppc ~ poly(w$t, 2, raw = TRUE))
Residuals:
Min 1Q Median 3Q Max
-3.1088 -1.3481 -0.8031 0.7610 9.5028
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.903e+02 4.876e+01 3.902 0.000323 ***
poly(w$t, 2, raw = TRUE)1 -5.502e-01 1.624e-01 -3.387 0.001497 **
poly(w$t, 2, raw = TRUE)2 4.040e-04 1.352e-04 2.988 0.004583 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.469 on 44 degrees of freedom
Multiple R-squared: 0.5366, Adjusted R-squared: 0.5156
F-statistic: 25.48 on 2 and 44 DF, p-value: 4.468e-08
> summary(lm(w$ppc ~ poly(w$t, 1, raw = TRUE)))
Call:
lm(formula = w$ppc ~ poly(w$t, 1, raw = TRUE))
Residuals:
Min 1Q Median 3Q Max
-3.7578 -1.6103 -0.2002 0.5953 9.3452
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 45.82955 6.88475 6.657 3.30e-08 ***
poly(w$t, 1, raw = TRUE) -0.06583 0.01101 -5.978 3.37e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.677 on 45 degrees of freedom
Multiple R-squared: 0.4426, Adjusted R-squared: 0.4303
F-statistic: 35.74 on 1 and 45 DF, p-value: 3.365e-07
> summary(lm(w$ppc ~ w$t))
Call:
lm(formula = w$ppc ~ w$t)
Residuals:
Min 1Q Median 3Q Max
-3.7578 -1.6103 -0.2002 0.5953 9.3452
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 45.82955 6.88475 6.657 3.30e-08 ***
w$t -0.06583 0.01101 -5.978 3.37e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.677 on 45 degrees of freedom
Multiple R-squared: 0.4426, Adjusted R-squared: 0.4303
F-statistic: 35.74 on 1 and 45 DF, p-value: 3.365e-07
データ
> head(w)
t r p lm total ppc
1 626.4641 北海道 5382 618.3664 11452172 2.107395
2 663.3135 青森県 1308 626.3410 2939581 4.429664
3 667.7703 岩手県 1280 626.4630 2853692 2.273438
4 637.5874 宮城県 2334 623.0764 5123632 2.437875
5 690.0909 秋田県 1023 627.7264 2306048 1.422287
6 673.9591 山形県 1124 627.1957 2522271 1.706406
この記事が気に入ったらサポートをしてみませんか?