1
$\begingroup$

I have a large panel data set featuring the purchases of 5000+ individuals over 2000+ time periods (days). I am looking to estimate pooled OLS regressions featuring double-clustered standard errors (where standard errors are clustered by both individual and time) but the dimensions of this problem are causing issues.

If i cluster standard errors by one dimension only (either individuals or time) I can quickly obtain parameter estimates (I am using both Stata and R). However, if I try to double-cluster my standard errors along both dimensions then the code takes hours to run and does not produce output.

Are there any ways to estimate these regressions given the large number of clusters? Some ad-hoc thoughts I have had are to split the panel into weekly or monthly sub-panels in order to reduce the dimensions of the problem but I am sure this is not sound.

Suggestions appreciated!

$\endgroup$
1
$\begingroup$

Which library you are using?

With lfe (https://cran.r-project.org/web/packages/lfe/index.html), I am able to fit a model with 2000 id's and 5000 obs per id fairly easily using my laptop with 4gb memory.

library(lfe)
rep(1:5000,2000) -> id
runif(length(1:5000)*2000) -> x
y <- rnorm(length(obss))

data.frame(y, id, x) -> df

model <- felm(y ~ x | 0 | 0 | id, data=df)

EDIT Estimatr library is another fairly efficient option: http://estimatr.declaredesign.org

$\endgroup$
  • $\begingroup$ I'm using this code to implemented the double-clustered standard errors. sites.google.com/site/waynelinchang/r-code I could be wrong, but felm is estimating a regression with fixed effects. I do not want to include fixed effects in my regression but just want to run OLS with standard errors clustered along the two dimensions. $\endgroup$ – Andrew Parkerson Apr 7 '18 at 0:47
  • 1
    $\begingroup$ You do not need to use FE's with felm. In my example above felm(y ~ x | 0 | 0 | id, data=df) the first 0 after a | implies OLS instead of FE regression. The example given in your link, summary(felm(y ~ x | 0 | 0 | firmid + year, data=df.petersen)) # cluster by both year and firm also estimates an OLS regression with firm+year clustering. $\endgroup$ – Otto Kässi Apr 7 '18 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.