I come from a math/statistics background and as learned some stuff as a data analyst I learned a certain technique to calculate period to period variances between some metrics.

I was wondering if anyone is able to identify the general concept of the following problem (I have never learned anything like this academically so I cannot

Variance Calculation and Definition

The idea is that from period 1 to period 2, x varies 1.6% where it's multiplicative components a, b and c have a certain amount of weight that adds up to 1.6%.

So in the example, component a was the driver that brought down the value of x out of the three.

Any help or suggestion is welcome.


2 Answers 2


IMHO, this part of my explanation is more well-thought out. For sake of transparency, I will leave the first version of my answer below - it still has some merit of its own, but does lack the "rigor" (alas, I am no mathematician).

A bit of background

As I understand it, we are looking for a way to integrate the total derivative of some function $f$ in multiple variables.

$$ \int \mathrm{d}f=\sum_i \int\frac{\partial f}{\partial x_i}\mathrm{d}x_i $$

In our example,

$$ \int \mathrm{d}f=\int\frac{\partial f}{\partial x} \mathrm{d}x+\int\frac{\partial f}{\partial x} \mathrm{d}y+\int\frac{\partial f}{\partial z} \mathrm{d}z $$

Solving this integral involves a path integral from the initial point $(x_0,y_0,z_0)$ to the point $(x_1,y_1,z_1)$. As this happens in three dimensions, there exist multiple paths that could get us there. We could first move along the $x$-axis, then along the $y$-axis, then the $z$-axis, or any other combination of paths, or we could even go "straight" through this 3d-object along a parameterised path.

Let's assume that we restrict ourselves to choosing only paths that traverse the edges, i.e. we only move along any given line segment, consecutively, then we would have the following possible combinations:

$$ \begin{align} (000)\to(100)\to(110)\to(111)\\ (000)\to(100)\to(101)\to(111)\\ (000)\to(010)\to(110)\to(111)\\ (000)\to(010)\to(011)\to(111)\\ (000)\to(001)\to(101)\to(111)\\ (000)\to(001)\to(011)\to(111) \end{align} $$

i.e., again, there are six possible paths between the two points - all equally likely. Let's make the calculation explicit along the first path:

$$ \int \mathrm{d}f=\int\frac{\partial f}{\partial x} \mathrm{d}x+\int\frac{\partial f}{\partial x} \mathrm{d}y+\int\frac{\partial f}{\partial z} \mathrm{d}z $$

As we move along $x$ first, we have

$$ \int\left.\frac{\partial f}{\partial x}\right|_{y=y_0,z=z_0} \mathrm{d}x=f(x_1,y_0,z_0)-f(x_0,y_0,z_0) $$

As we only moved along $x$, $y$ and $z$ stay constant, i.e. $dy=dz=0$. Having moved from $x_0\x_1$, we now add the movement in $y$ direction:

$$ \int\left.\frac{\partial f}{\partial y}\right|_{x=x_1,z=z_0} \mathrm{d}y=f(x_1,y_1,z_0)-f(x_1,y_0,z_0) $$

Ultimately, we move along the $z$ dimension: $$ \int\left.\frac{\partial f}{\partial z}\right|_{x=x_1,y=y_1} \mathrm{d}z=f(x_1,y_1,z_1)-f(x_1,y_1,z_0) $$

Adding these terms we obtain:

$$ \begin{align} \int\mathrm{d}f & =\left(f(x_1,y_0,z_0)-f(x_0,y_0,z_0)\right) \\ & + \left(f(x_1,y_1,z_0)-f(x_1,y_0,z_0)\right)\\ & + \left(f(x_1,y_1,z_1)-f(x_1,y_1,z_0)\right) \end{align} $$

Do note that this is exactly the formula you have provided above. But as there are $k!$ possible paths, along the edges in $k$ dimensions, we may weigh them equally.

Original answer

The general concept here is to attribute the change in a given function $\Delta f \equiv f(\mathbf{x}_1)-f(\mathbf{x}_0) $ between two points onto per-variable changes. This ansatz uses a combination of forward and backward difference approximations to derivatives at various points.

Let me explain this in the threevariate case. Let $x,y,z$ and $\Delta x\equiv x_1-x_0, \Delta y \equiv y_1-y_0, \Delta z \equiv z_1-z_0$ denote the variables of interest and their corresponding differneces. To ease notation, we write $f(111)$ to mean $f(x_1,y_1,z_1)$, $f(000)$ to mean $f(x_0,y_0,z_0)$ and so on.

We begin by restating the identity $\Delta f$ thru adding zeros:

$$ \begin{align} \Delta f &\equiv f(x_1,y_1,z_1)-f(x_0,y_0,z_0)\\ &\equiv f(111)-f(000)\\ &= f(111)-f(000)\\ &\pm f(110)\\ &\pm f(101)\\ &\pm f(011)\\ &\pm f(100)\\ &\pm f(010)\\ &\pm f(001)\\ &=\frac{1}{3}\left(f(111)-f(110)+f(111)-f(101)+f(111)-f(011)\right)\\ &+\frac{1}{6}\left(f(110)-f(010)+f(110)-f(100)\right)\\ &+\frac{1}{6}\left(f(101)-f(100)+f(101)-f(001)\right)\\ &+\frac{1}{6}\left(f(011)-f(010)+f(011)-f(001)\right)\\ &+\frac{1}{3}\left(f(100)-f(000)+f(010)-f(000)+f(001)-f(000)\right)\\ \end{align} $$

Next, multiplying the terms by $\frac{\Delta x}{\Delta x}, \frac{\Delta y}{\Delta y},\frac{\Delta z}{\Delta z}$, we introduce various forward and backwards difference approximations to the partial derivatves, evaluated at all combinations of the start/end parameters:

$$ \begin{align} \Delta f &= \frac{\Delta x}{3}\left(\frac{f(111)-f(011)}{\Delta x}+\frac{1}{2}\left(\frac{f(110)-f(010)}{\Delta x}+\frac{f(101)-f(001)}{\Delta x}\right)+\frac{f(100)-f(000)}{\Delta x}\right)\\ &+\frac{\Delta y}{3}\left(\frac{f(111)-f(101)}{\Delta y}+\frac{1}{2}\left(\frac{f(110)-f(100)}{\Delta y}+\frac{f(011)-f(001)}{\Delta y}\right)+\frac{f(010)-f(000)}{\Delta y}\right)\\ &+\frac{\Delta z}{3}\left(\frac{f(111)-f(110)}{\Delta z}+\frac{1}{2}\left(\frac{f(101)-f(100)}{\Delta z}+\frac{f(011)-f(010)}{\Delta z}\right)+\frac{f(001)-f(000)}{\Delta z}\right) \end{align} $$

Generally, a $k$-variate function will require a total of $2^k$ (here: $k=3$) function calls for this method to work.

Note that your ansatz does not incorporate all possible difference approximations. If I apply the "full" approach outlined above, I get

$$ \begin{align} \Delta_a=&-6.41\%\\ \Delta_b=&1.51\%\\ \Delta_c=&3.31\% \end{align} $$

  • $\begingroup$ Thank you for the detailed answer. It seems quite intuitive and I am more than excited to know that there is much to learn about this. Would you happen to know any textbook or link that goes through the basics and details of this concept by any chance? $\endgroup$
    – hyg17
    Dec 8, 2023 at 20:26
  • $\begingroup$ Please read my revised answer, HTH? $\endgroup$ Dec 8, 2023 at 22:36
  • $\begingroup$ Yes, thank you for the additional detail and it is exactly my understanding. The reason why I was asking for the source of this information is not because I didn't understand it, it's that there are many more things I would like to understand about it. Such as, is this supposed to be path dependent? What if I have additional breakouts? If the inputs are not mutually exclusive to another what kind of issues will I face? The fact that you were able to provide me such detailed explanation hints that somewhere out there someone did a full on research on this topic and I am interested. $\endgroup$
    – hyg17
    Dec 9, 2023 at 17:36
  • $\begingroup$ I see. I do not have any specific source I can point to; I googled lecture material on the “path integral of the total derivative”and so on. As there is a path dependency, the order does matter. But to my knowledge, only the formulations we have discussed above allow for accounting for “independent” x,y,z-contributions. Sorry I could not help more, though $\endgroup$ Dec 9, 2023 at 20:21
  • 1
    $\begingroup$ I left my further analysis based on what I have learned and applied it to my case. Indeed we get the same answer and I have a better understanding - thank you very much! $\endgroup$
    – hyg17
    Dec 17, 2023 at 3:35

Geometric Description of Kermittfrog's Answer

As described in your answer, the partial differentials are path dependent as illustrated.

In this case there are k = 3 variables for x showing 3! = 6 possible paths (a,b,c) , (a,c,b), ... , (c,a,b), (c,b,a).

The average of each path coincides with the "full approach".


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.