Ich passe ein Arima
(2,0,0) Modell mit dem forecast
Paket in R auf dem usconsumption
Datensatz. Wenn ich jedoch die gleiche Anpassung unter Verwendung von lm
nachbilde, erhalte ich unterschiedliche Koeffizienten. Mein Verständnis ist, dass sie gleich sein sollten. Unten ist mein Code.Arima und lm geben nicht die gleichen Koeffizienten in R
> library(forecast)
> library(fpp)
>
> #load data
> data("usconsumption")
>
> #create equivalent data frame from time-series
> lagpad <- function(x, k=1) {
+ c(rep(NA, k), x)[1 : length(x)]
+ }
>
> usconsumpdf <- as.data.frame(usconsumption)
> usconsumpdf$consumptionLag1 <- lagpad(usconsumpdf$consumption)
> usconsumpdf$consumptionLag2 <- lagpad(usconsumpdf$consumption, 2)
>
> #create arima and lm models
> arima1 <- Arima(usconsumption[,1], xreg=usconsumption[,2], order=c(2,0,0))
> lm1 <- lm(consumption~consumptionLag1+consumptionLag2+income, data=usconsumpdf)
>
> #show coefficients
> arima1
Series: usconsumption[, 1]
ARIMA(2,0,0) with non-zero mean
Coefficients:
ar1 ar2 intercept usconsumption[, 2]
0.1325 0.2924 0.5641 0.2578
s.e. 0.0826 0.0747 0.0883 0.0530
sigma^2 estimated as 0.3538: log likelihood=-145.59
AIC=301.19 AICc=301.57 BIC=316.69
> summary(lm1)
Call:
lm(formula = consumption ~ consumptionLag1 + consumptionLag2 +
income, data = usconsumpdf)
Residuals:
Min 1Q Median 3Q Max
-2.22400 -0.31689 -0.01079 0.34280 1.43839
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.27373 0.08031 3.408 0.000829 ***
consumptionLag1 0.16423 0.07547 2.176 0.031039 *
consumptionLag2 0.21857 0.07198 3.037 0.002800 **
income 0.26670 0.05247 5.082 1.04e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5952 on 158 degrees of freedom
(2 observations deleted due to missingness)
Multiple R-squared: 0.2853, Adjusted R-squared: 0.2717
F-statistic: 21.02 on 3 and 158 DF, p-value: 1.637e-11
Danke, Alex. Ich verstehe immer noch nicht, wie ARIMA im Vergleich zu OLS passt. Haben Sie eine Erklärung oder eine gute Ressource, die die beiden vergleicht? –
Ich denke, das wäre eine Frage für http://stats.stackexchange.com/ und wäre off-topic für Stack-Überlauf. – Alex
Danke, ja, ich habe dort gepostet: http://stats.stackexchange.com/questions/223379/arima-and-lm-not-giving-same-ecoegifers-in-r?noredirect=1#comment422746_223379 –