Once you have ARMA errors, it is not a simple linear regression any more. So you would have to define what you mean by $R^2$. Perhaps the squared correlation of fitted to actuals? In that case:
cor(fitted(a),x3)^2
The fitted()
function will only work if you have loaded the forecast
package, but it looks like you have already done that judging from the output in your question.
In your case, you don't have ARMA errors, but you do have differencing. So it is equivalent to the linear model
b <- lm(diff(x3) ~ diff(dummy) - 1)
summary(b)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
diff(dummy) 17.766 1.149 15.46 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.149 on 98 degrees of freedom
Multiple R-squared: 0.7092, Adjusted R-squared: 0.7062
F-statistic: 239 on 1 and 98 DF, p-value: < 2.2e-16
Of course, that is a very different value of $R^2$ than just using the correlations as above because it is now being computed on the differences.
You will need define what you mean by $R^2$, and what you want to use it for. Once you move away from the usual regression set up with an intercept and iid errors, $R^2$ ceases to be uniquely defined and is not particularly useful.