# Three-way clustered robust standard errors in R

Suppose I have the following data:

loan_id    borrower_id    loan_amount     lender_id     var     time

xxxx      xxxx            xxxx            xxxx         xxxx    20xx


Suppose that one borrower can have multiple lenders.

If I want to run the following regression:

loan_amount = var + \epsilon

Do I need to cluster by borrower_id, loan_id as well as time? Because a lender/borrower's characteristic might be correlated with the loan amount, and the characteristics might also be correlated through time. If so, am I looking at a three-way clustered robust standard error here?

Do you think the multiway clustered robust standard error in R will work in this case? For example:

vcov <- cluster.vcov(model, cbind(borrower_id, lender_id, petersen\$year))


and then use coeftest(m1, vcov) to get the clustered robust standard errors.

Do you think this makes sense?

• What is your variable "var" about ? – Alex. C-L - Reinstate Monica Sep 26 '19 at 21:42
• It could be age, for instance. It could be other things too. – Jinhua Wang Sep 26 '19 at 21:53