Let's say I have data on firms (nested within countries). Some firms are multinational, others only have a single instance. The dependent variable is revenue. What is the appropriate way to account for the clustering structure of this relationship?
If using a mixed effects approach, my intuition is to treat country-firmID as a nested random effect like so
lmer(log_revenue ~ scale(country_gdp) + scale(country_population) + scale(employee_count) + I(scale(employee_count)^2) + (1|country/firmID), data = df)
However, in some versions of this specification I get
Error: number of levels of each grouping factor must be < number of observations, but I'm not sure how the total number of levels of a grouping factor are being calculated. Some FirmIDs are in more than one country, and some are in the same country more than once.
In other versions of the specification I get the error:
convergence code 3 from bobyqa: bobyqa -- a trust region step failed to reduce qunable to evaluate scaled gradient Hessian is numerically singular: parameters are not uniquely determinedModel may not have converged with 1 eigenvalue close to zero: 0.0e+00
Re-running the code by assuming country and firm random effects runs without convergence issues, but I don't think it's appropriate to not account for the nested nature of firms and countries:
lmer(log_revenue ~ scale(country_gdp) + scale(country_population) + scale(employee_count) + I(scale(employee_count)^2) + (1|firmID) +(1|country), data = df)
More generally, is this the right way to model the relationship -- or, is it more appropriate to do something like this -
felm(log_revenue ~ scale(country_gdp) + scale(country_population) + scale(employee_count) + I(scale(employee_count)^2) | firmID | 0 | country, data = df)
Where I add fixed effects for firm, and cluster by country. Conceptually, what is the difference between these two approaches, as they tend to yield similar results?
As mentioned in the comment below, I'm particularly interested in understanding the intuition behind the difference between the following:
(1|country\firmID) adding fixed effects at both the country and firmID level, and adding fixed effects for firmID and clustering standard errors at the country level.