Double clustered standard errors for panel data

前端 未结 4 763
小鲜肉
小鲜肉 2020-12-09 00:33

I have a panel data set in R (time and cross section) and would like to compute standard errors that are clustered by two dimensions, because my residuals are correlated bot

4条回答
  •  抹茶落季
    2020-12-09 00:52

    Frank Harrell's package rms (which used to be named Design) has a function that I use often when clustering: robcov.

    See this part of ?robcov, for example.

    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.
    

提交回复
热议问题