gvlma包中的gvlma()函數,對線性模型假設進行綜合驗證(經過/不經過),同時還能作偏斜度、峯度、異方差性的評價dom
> library(gvlma) > gvmodel <- gvlma(fit) > summary(gvmodel) Call: lm(formula = Murder ~ Population + Illiteracy + Income + Frost, data = states) Residuals: Min 1Q Median 3Q Max -4.7960 -1.6495 -0.0811 1.4815 7.6210 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.235e+00 3.866e+00 0.319 0.7510 Population 2.237e-04 9.052e-05 2.471 0.0173 * Illiteracy 4.143e+00 8.744e-01 4.738 2.19e-05 *** Income 6.442e-05 6.837e-04 0.094 0.9253 Frost 5.813e-04 1.005e-02 0.058 0.9541 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 2.535 on 45 degrees of freedom Multiple R-squared: 0.567, Adjusted R-squared: 0.5285 F-statistic: 14.73 on 4 and 45 DF, p-value: 9.133e-08 ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM: Level of Significance = 0.05 Call: gvlma(x = fit) Value p-value Decision Global Stat 2.7728 0.5965 Assumptions acceptable. #Global Stat Skewness 1.5374 0.2150 Assumptions acceptable. Kurtosis 0.6376 0.4246 Assumptions acceptable. Link Function 0.1154 0.7341 Assumptions acceptable. Heteroscedasticity 0.4824 0.4873 Assumptions acceptable.
從輸出項Global Stat 中的文字欄能夠看出數據知足OLS迴歸模型全部的統計假設(p =0.597)。若Decision下的文字代表違反了假設條件(好比 p < 0.05),你能夠使用迴歸診斷改進的方法來判斷哪些假設沒有被知足函數