0
$\begingroup$

I'm running a regression in R's plm package similar to this post Clustered standard errors in R using plm (with fixed effects). I.e. panel data with fixed effects and the within-model from plm.

My Question is the following: I'm trying to figure out how to cluster my standard errors according to a different variable than the variable called state from the dataset Cigar, which is seemingly automatically used by the cluster = 'group' option in vcovHC. Specifically, if I e.g. have a variable called id, how can I tell vcovHC to use it as my cluster?

A very related question is the process of how vcocHC is selecting the variable for clustering, is it always just the first column in the dataset?

$\endgroup$
1
  • 1
    $\begingroup$ I removed clustering tag. Please be attentive selecting tags. $\endgroup$
    – ttnphns
    Commented Apr 5, 2016 at 18:37

1 Answer 1

3
$\begingroup$

When you fit a plm() you declare a certain set of indexes for cross-section group and time, respectively. When you call vcovHC(..., cluster = "group") subsequently, the grouping variable specified in the original plm() call is used.

So it seems you only have to use plm(..., index = c("id", "time")) instead of plm(..., index = c("state", "time")) or something along those lines.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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