Replicate EViews' MA() function in R regression

162 views Asked by At

I'm taking some models that were built in EViews and putting them into R. I'm having trouble replicating EViews' MA function.

I tried using the lag of the regressions residuals, but this isn't quite the same. I've seen some mentions that this is an ARIMA regression.. Is there no way to replicate MA from EViews in an lm regression?

For example in 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)

Outputs:

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

Where in 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   

How do I replicate the MA(1) variable in R?

0

There are 0 answers