I would like to create a variable called spill which is given as the sum of the distances between vectors of each row multiplied by the stock value. For example, consider
I would like to create a vector which basically takes the distance between two firms at time t and generates the spill variable. For example, take for Firm A in the year 2001 it would be 0.204588 (which is the cosine distance between firm A and B at time t i.e, in 2001 ( 1, 4, 3,5) and (2,3,1,1) (i.e. similarity between the investments in us, euro, asia, africa) and then multiplied by 343, and then to calculate the distance between A and C in 2001 as .10528 * 345 , hence the spill variable is = .2 * 343+.1 * 345 = 103.1 for the year 2001 for firm A. Can anyone please advise?
Thank you!
firm | us | euro | asia | africa | stock | year |
A | 1 | 4 | 3 | 5 | 46 | 2001 |
A | 2 | 0 | 1 | 3 | 889 | 2002 |
B | 2 | 3 | 1 | 1 | 343 | 2001 |
B | 0 | 2 | 1 | 3 | 43 | 2002 |
C | 1 | 3 | 4 | 2 | 345 | 2001 |
Thank you!
Comment