我正在尝试在 R 中拟合线性时间序列模型。我的第一种方法是使用 lm:
> m1 = lm(logp~logg, data = data)
> summary(m1)
Call:
lm(formula = logp ~ logg, data = data)
Residuals:
Min 1Q Median 3Q Max
-0.56209 -0.21766 -0.02728 0.20243 0.82112
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.14218 0.59651 3.591 0.000556 ***
logg -0.57819 0.04931 -11.725 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2921 on 83 degrees of freedom
Multiple R-squared: 0.6236, Adjusted R-squared: 0.619
F-statistic: 137.5 on 1 and 83 DF, p-value: < 2.2e-16
但是,我意识到残差是自相关的,我想对此进行补偿。所以我用 gls 代替:
> m2 = gls(logp~logg, data = data, correlation=corAR1(form=~1))
> summary(m2)
Generalized least squares fit by REML
Model: logp ~ logg
Data: data
AIC BIC logLik
-83.1498 -73.47444 45.5749
Correlation Structure: AR(1)
Formula: ~1
Parameter estimate(s):
Phi
0.9313839
Coefficients:
Value Std.Error t-value p-value
(Intercept) 4.82358 1.1435778 4.217972 1e-04
logg -0.35891 0.0925918 -3.876257 2e-04
Correlation:
(Intr)
logg 0.986
Standardized residuals:
Min Q1 Med Q3 Max
-1.5206442 -0.7602385 -0.2905489 0.6310135 2.7341294
Residual standard error: 0.3788309
Degrees of freedom: 85 total; 83 residual
我的理解是参数估计应该仍然相同,但 t 统计量应该不同,如此处所示。但是,我得到了非常不同的参数估计。这是为什么?我做错了什么,还是我误解了统计数据?
当我比较拟合值时m1$fitted.values
,m2$fitted
它们完全相同。这让我相信来自 gls 的参数估计应该以不同于来自 lm 的方式来解释,但是如何解释呢?