用R进行多层回归分析

来自OBHRM百科
跳转至: 导航搜索

可以用R自带的函数lm()来做,或者用AutoModel包来完成

用AutoModel包进行多层回归分析

脚本与注释

library(AutoModel)  # 启用AutoModel包。如果没有安装,请先安装。安装方法,请在R控制台输入:install.packages("AutoModel")。
# 多层回归分析。因变量为y,第一层的自变量为:lag.quarterly.revenue,第二层新增的自变量为:price.index,income.level。数据来源AutoModel包自带的freeny数据
run_model("y", c("lag.quarterly.revenue"), c("price.index", "income.level"),dataset=freeny) 

结果

> run_model("y", c("lag.quarterly.revenue"), c("price.index", "income.level"),dataset=freeny)


REGRESSION OUTPUT

Durbin-Watson =  2.11 p value =  0.4729 

Partial Regression plots (all relationships should be linear):

Plot of studentized residuals: uniform distibution across predicted values requiredCorrelation Matrix for model (correlation >.70 indicates severe multicollinearity)

                            y lag.quarterly.revenue price.index income.level
y                      1.0000                0.9978     -0.9895       0.9839
lag.quarterly.revenue  0.9978                1.0000     -0.9894       0.9817
price.index           -0.9895               -0.9894      1.0000      -0.9539
income.level           0.9839                0.9817     -0.9539       1.0000

Variance inflation factor (<10 desired):

lag.quarterly.revenue           price.index          income.level 
               194.85                 78.58                 45.52 

Standardized Residuals (observations > 3.00 problematic):

No significant outliers

Cook's distance (values >.2 problematic):

1963.25 
 0.8918 

Normality of standardized model residuals:  Shapiro-Wilk (p-value):  0.5586 

Model change statistics

             R    R^2 Adj R^2 SE Est. Delta R^2  F Change df1 df2 p Fch Sig
Model 1 0.9978 0.9956  0.9955  0.0212    0.9956 8360.3793   1  37     0 ***
Model 2 0.9988 0.9977  0.9975  0.0159    0.0021   15.4599   2  35     0 ***
Model 1 : y ~ lag.quarterly.revenue 
Model 2 : y ~ lag.quarterly.revenue + price.index + income.level 

Model Coefficients

   Model                  term estimate std.error statistic p.value sig
 Model 1           (Intercept)  0.04169   0.10138    0.4112  0.6833    
 Model 1 lag.quarterly.revenue  0.99827   0.01092   91.4351  0.0000 ***
 Model 2           (Intercept)  4.97077   1.24046    4.0072  0.0003 ***
 Model 2 lag.quarterly.revenue  0.37305   0.11418    3.2673  0.0024  **
 Model 2           price.index -0.81887   0.17152   -4.7742  0.0000 ***
 Model 2          income.level  0.75435   0.14454    5.2189  0.0000 ***