R語言多元線性迴歸

來源:互聯網
上載者:User

多元線性迴歸關鍵在於自變數篩選。一般採用後退法。


# 工業用電量的全變數迴歸lm.fullind <- lm(data[,10] ~ data[,3]+data[,5]+data[,6]+data[,7]+                   data[,14]+data[,15])summary(lm.fullind)

R語言中summary可以列印每個自變數的p值(“Pr(>|t|)”)

Call:lm(formula = data[, 10] ~ data[, 3] + data[, 5] + data[, 6] +     data[, 7] + data[, 14] + data[, 15])Residuals:   Min     1Q Median     3Q    Max -63.18 -19.56   5.48  17.19  53.79 Coefficients:              Estimate Std. Error t value Pr(>|t|)    (Intercept) 1832.67765  532.30742   3.443 0.001255 ** data[, 3]      0.11092    0.01781   6.227 1.43e-07 ***data[, 5]     -0.12608    0.03110  -4.054 0.000197 ***data[, 6]     -0.17146    0.07263  -2.361 0.022637 *  data[, 7]      0.27577    0.11750   2.347 0.023389 *  data[, 14]     4.11264    0.96517   4.261 0.000103 ***data[, 15]   -15.69347    4.80593  -3.265 0.002094 ** ---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 28.97 on 45 degrees of freedom  (22 observations deleted due to missingness)Multiple R-squared:  0.6968,Adjusted R-squared:  0.6564 F-statistic: 17.24 on 6 and 45 DF,  p-value: 3.155e-10
每次剔除p值最大的自變數,直至所有自變數後面都有*號即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.