# Fixed effect and clustering with 3 dimensional data

I have a sample of banks. These vary across time, rating agency and across countries.

UPDATE: I trying to capture the effect of a regulatory change (dummy variable, 0/1) on a banks credit rating.

I am using monthly data and each bank has a set of characteristics that vary (e.g. size, profitability etc). There ends up being multiple instances for each bank in each period as a bank may be rated by more than one rating agency. Hence I define the data as follows:

//newID to make it 2d panel
egen newID = group(indexnumber moodys fitch)

//define panel
xtset newID edate1


My aim is to control for country and time effects using interacted country and year dummies. While controlling for bank heterogeneity by including a number of bank control variables.

How best would I go about doing this?

Should I:

• Include country and year interacting dummies and cluster at bank level (current doing this)
• Include bank and year dummies and cluster at a country level

Original post:

I was previously including country and year interacted fixed effects to control for variation across countries and years. I was also clustering at the bank level. e.g.

regress depVar indepVar i.country#i.year, vce(cluster bankID)


Having done some more research some people indicate it is best to cluster at the highest level (e.g. country). Then to run it with bank level fixed effects. e.g.

regress depVar indepVar i.bankID i.year, vce(cluster country)

I am worried that if I cluster like this, I wont control for changing country effects. I already include many control variables to control for variation on a bank level.

Would I be better using the built in xtreg in stata. If so will:

xtreg depVar indepVar, fe vce(cluster country)


be equivalent to:

regress depVar indepVar i.bankID i.year, vce(cluster country)

• Welcome to Cross Validated. I'm curious about your question; what is the question that you are trying to answer? – Candamir Nov 7 '18 at 17:02
• Thanks, happy to be here!! Please see my update, I trying to capture the effect of a regulatory change on a banks credit rating, I know that using a diff-in-diff is optimal, but it isnt appropriate for my particular setting. – Laurence_jj Nov 8 '18 at 16:42

If your panel is set correctly (xtset bankID year), both of the last commands give you the same estimates. The standard errors will be however too high for OLS. Note that if you want to have both interactions and dummies, you'd need to specify country##year. (This may not work for old Stat versions)