gpt4 book ai didi

r - 面板数据的双聚类标准误

转载 作者:行者123 更新时间:2023-12-04 05:33:34 26 4
gpt4 key购买 nike

我在 R(时间和横截面)中有一个面板数据集,并且想计算由二维聚类的标准误差,因为我的残差是双向相关的。谷歌搜索我发现 http://thetarzan.wordpress.com/2011/06/11/clustered-standard-errors-in-r/它提供了一个功能来做到这一点。这似乎有点临时,所以我想知道是否有一个已经过测试的包,这样做吗?

我知道 sandwich做 HAC 标准错误,但它不做双聚类(即沿二维)。

最佳答案

Frank Harrell 的包裹 rms (以前被命名为 Design )有一个我在聚类时经常使用的函数:robcov .

查看?robcov的这一部分, 例如。

cluster: a variable indicating groupings. ‘cluster’ may be any type of
vector (factor, character, integer). NAs are not allowed.
Unique values of ‘cluster’ indicate possibly correlated
groupings of observations. Note the data used in the fit and
stored in ‘fit$x’ and ‘fit$y’ may have had observations
containing missing values deleted. It is assumed that if any
NAs were removed during the original model fitting, an
‘naresid’ function exists to restore NAs so that the rows of
the score matrix coincide with ‘cluster’. If ‘cluster’ is
omitted, it defaults to the integers 1,2,...,n to obtain the
"sandwich" robust covariance matrix estimate.

关于r - 面板数据的双聚类标准误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8389843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com