Allocation
Overview
Allocation is similar to
attribution
and can usually be recast as an attribution. An allocation problem
starts with a function
{% value_1 = f(x_{1}, x_{2} , ... ,x_{n}) %}
Instead of asking how to attribute changes in the value of the function to changes in the underlying variables, it asks
how can we represent the value of the function at one point as a sum of contributions from the underlying
variables.
Allocation can be recast as an attribution when the value of the function is zero when all variables are zero.
In that case,
{% \Delta f = f(x_{1}, x_{2} , ... ,x_{n}) %}
and
{% \Delta x_i = x_i %}
Eulers Theorem
Eulers Theorem, states that for a function which is homogenous of degree 1, that is
{% f(\lambda \vec{w}) = \lambda f(\vec{w}) %}
can be expressed as
{% f(\vec{w}) = \sum_i ^n w_i \frac{\partial{f}}{{\partial{w_i}}} %}
(see
braga pg 45) and
(see
wikipedia)
In the context of allocation, Eulers Theorem provides a way to decompose a function value as a sum
of contributions from the underlying variables.
Example 1 - Linear Function
{% f(x_{1}, x_{2}) = x_1 + x_2 %}
In such an easy example attribution is easy
{% \Delta f_{x1} = \Delta x_1 %}
{% \Delta f_{x2} = \Delta x_2 %}
A common example of linear attribution is the net income of a company. The profit is the sum of the various revenues
minus the various expenses. If one wanted to know how much salary expense contributed to (or detracted from) the profit of the
company, one need only read the number off the financial statements. No magic needs to occur here.
Example 2
{% f(x_{1}, x_{2}) = x_1 \times x_2^2 %}
Consider two points
{% (x_{1}, x_{2}) = (1,1) %}
{% (x_{1}, x_{2}) = (2,2) %}
Then the value of f changes from 1 to 8. How much of the change was due to the change in x1 versus x2?
A common example of non linear attribution is to ask how much a particular asset contributes to the overall
risk of a portfolio. Because there correlations between assets that are less than 1, there is a diversification
effect. In such a case, it may be meaningless to ask how much a particular asset contributes to the risk
(except in the marginal case)
Methods of Solution
It is generally agreed that if only one variable changes, then the entire change in the value of the function is due to the single variable.
For example, if only the value of {% x_1 %} changes, then the change in f is
{% \Delta f = f(x_1', x_2) - f(x_1,x_2) %}
and the entire change is attributable to {% x_1 %}
This observation leads to a method of solution to the attribution problem. To calculate the change attributable to each
variable, you change each variable one at a time and measure the difference in f, then attribute that difference to the changed
variable.
As an example, consider attributing the change in f between the points (1,1) and (2,2)
{% value1 = f(1,1) %}
{% value2 = f(2,1) %}
{% value3 = f(2,2) %}
then
{% \Delta x_1 = value2 - value1 %}
{% \Delta x_2 = value3 - value2 %}
The challenge with this approach is that the answer will depend on the order which one chooses to scale
the inputted variables.
Attribution API
let att = await import('/lib/attribution/v1.0.0/attribution.mjs');
let method = function(x, y){
return x*y*y;
}
let results = att.path(method, [[1,1], [2,2]])
Try it!
let att = await import('/lib/attribution/v1.0.0/attribution.mjs');
let method = function(x, y){
return x*y*y;
}
let xs = $from(1,2,10);
let ys = $from(1,2,10);
let args = [];
for(let i=0;i<xs.length;i++){
args.push([xs[i], ys[i]]);
}
let results = att.path(method, args)
Try it!