[英]Can I test autocorrelation from the generalized least squares model?
I am trying to use a generalized least square model ( gls
in R) on my panel data to deal with autocorrelation problem. 我试图在我的面板数据上使用广义最小二乘模型(R中的
gls
)来处理自相关问题。 I do not want to have any lags for any variables. 我不希望任何变量有任何滞后。
I am trying to use Durbin-Watson test ( dwtest
in R) to check the autocorrelation problem from my generalized least square model ( gls
). 我正在尝试使用Durbin-Watson测试(R中的
dwtest
)来检查来自我的广义最小二乘模型( gls
)的自相关问题。 However, I find that the dwtest
is not applicable over gls
function while it is applicable to other functions such as lm
. 但是,我发现
dwtest
不适用于gls
函数,而它适用于其他函数,如lm
。
Is there a way to check the autocorrelation problem from my gls
model? 有没有办法从我的
gls
模型中检查自相关问题?
Durbin-Watson test is designed to check for presence of autocorrelation in standard least-squares models (such as one fitted by lm
). Durbin-Watson测试旨在检查标准最小二乘模型(例如由
lm
拟合的模型)中是否存在自相关 。 If autocorrelation is detected, one can then capture it explicitly in the model using, for example, generalized least squares ( gls
in R). 如果检测到自相关,则可以使用例如广义最小二乘(R中的
gls
在模型中明确地捕获它。 My understanding is that Durbin-Watson is not appropriate to then test for "goodness of fit" in the resulting models, as gls
residuals may no longer follow the same distribution as residuals from the standard lm
model. 我的理解是,Durbin-Watson不适合在所得到的模型中测试“拟合优度”,因为
gls
残差可能不再遵循与标准lm
模型的残差相同的分布。 (Somebody with deeper knowledge of statistics should correct me, if I'm wrong). (如果我错了,对统计学有更深入了解的人应该纠正我)。
With that said, function durbinWatsonTest
from the car
package will accept arbitrary residuals and return the associated test statistic. 话虽如此,来自
car
包的函数durbinWatsonTest
将接受任意残差并返回相关的测试统计量。 You can therefore do something like this: 你可以这样做:
v <- gls( ... )$residuals
attr(v,"std") <- NULL # get rid of the additional attribute
car::durbinWatsonTest( v )
Note that durbinWatsonTest
will compute p-values only for lm
models (likely due to the considerations described above), but you can estimate them empirically by permuting your data / residuals. 请注意,
durbinWatsonTest
将仅为lm
模型计算p值(可能由于上述考虑因素),但您可以通过置换数据/残差来凭经验估算它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.