在R回归中复制EViews的MA()函数

时间:2018-09-18 14:26:52

标签: r eviews

我正在使用EViews中内置的一些模型,并将其放入R中。我在复制EViews的MA函数时遇到麻烦。

我尝试使用回归残差的滞后时间,但这并不完全相同。我已经看到一些提及,这是一个ARIMA回归。是否无法通过MA回归从EViews复制lm

例如在R中:

set.seed(2)
a = data.frame(a = 1:6, 
               b = runif(6, 0.0, 1.0), 
               c = runif(6, 0.0, 1.0))

fit_C = lm(c ~ a + b, data = a)
a$C.pred = predict.lm(fit_C, a)
a$C.resid = a$c - a$C.pred
fit_C = lm(c ~ a + b + lag(C.resid, 1), data = a)
summary(fit_C)

输出:

Call:
lm(formula = c ~ a + b + lag(C.resid, 1), data = a)

Residuals:
         1          2          3          4          5          6 
-1.779e-17 -1.131e-17  5.474e-17 -5.218e-18 -1.959e-17 -8.320e-19 

Coefficients:
                  Estimate Std. Error    t value Pr(>|t|)    
(Intercept)      4.327e-01  4.279e-17  1.011e+16   <2e-16 ***
a               -3.998e-02  1.353e-17 -2.954e+15   <2e-16 ***
b                2.889e-01  7.278e-17  3.969e+15   <2e-16 ***
lag(C.resid, 1)  1.000e+00  8.241e-17  1.213e+16   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 4.389e-17 on 2 degrees of freedom
Multiple R-squared:      1, Adjusted R-squared:      1 
F-statistic: 5.444e+31 on 3 and 2 DF,  p-value: < 2.2e-16

在EViews中:

Dependent Variable: C01             
Method: Least Squares               
Date: 09/18/18   Time: 10:24                
Sample: 1 6             
Included observations: 6                
Convergence achieved after 9 iterations             
MA Backcast: 0              

Variable    Coefficient Std. Error  t-Statistic Prob.  

C   0.892941    0.147320    6.061254    0.0262
A   -0.101365   0.041651    -2.433684   0.1354
B   0.063370    0.257874    0.245740    0.8288
MA(1)   -0.982901   0.058536    -16.79134   0.0035

R-squared   0.933603        Mean dependent var      0.462030
Adjusted R-squared  0.834008        S.D. dependent var      0.250812
S.E. of regression  0.102186        Akaike info criterion       -1.489321
Sum squared resid   0.020884        Schwarz criterion       -1.628148
Log likelihood  8.467963        Hannan-Quinn criter.        -2.045057
F-statistic 9.373951        Durbin-Watson stat      2.907407
Prob(F-statistic)   0.097923            

Inverted MA Roots         .98   

如何在R中复制MA(1)变量?

0 个答案:

没有答案