Dear Statalist members,
Assume the following example:
In the above example, we have four firms (A, B, C, and D) each of which has different shareholders. From this example, we can observe that shareholder x1 and x20 appear in more than one firm. First, we see that x1 and x20 appear in firm A, while x1 appears also in firm C, and x20 in firm D. We can consider x1 and x20 as common owners, as they appear more than once in the dataset.
Let's denote the number of rivals as the number of other distinct firms a common owner appears. For example, firm A should have two rivals, because at least one of its common owners appears in two other firms (x1 in C and x20 in D). With similar logic, we can say that firm B should have zero common owners because none of its shareholders appears in any other firm; firm C should have one rival (firm A due to shareholder x1); firm D one rival (firm A due to shareholder x20).
How would one code this?
Thanks in advance.
Assume the following example:
Code:
input str5 (firm_id shareholder_id) A x1 A x100 A x150 A x20 B y1 B y2 B y3 B y4 C x1 C z1 C z2 C z3 D x20 D x1000 D x1001 D x1002 end
Let's denote the number of rivals as the number of other distinct firms a common owner appears. For example, firm A should have two rivals, because at least one of its common owners appears in two other firms (x1 in C and x20 in D). With similar logic, we can say that firm B should have zero common owners because none of its shareholders appears in any other firm; firm C should have one rival (firm A due to shareholder x1); firm D one rival (firm A due to shareholder x20).
How would one code this?
Thanks in advance.

Comment