# How to check if specific MAE and MSE are feasible given only the real data?

I have as data some real measures, let's say: 1000, 800, 900, 1100, 900 and I have the Mean Absolute Error (MAE) and Mean Squared Error (MSE) 80 and 20000, but I don't know which are the estimated data. \begin{align} MAE_s(h) &= \frac{1}{n}\sum_{x \in s} |f(x)-h(x)| \\[5pt] MSE_s(h) &= \frac{1}{n}\sum_{x \in s} (f(x)-h(x))^2 \end{align} In the above equations, $f(x)$ is the real measure(1000,800, 900, 1100 and 900) and $h(x)$ is the estimated measure (which is unknown to me), while $n$ is the measure amount (which is 5 in our case).

I have to prove if this situation is possible or not, so I took the MAE formula and I replace the values I knew, getting the equations which you can see below. I used $x,y,z,w,t$ to denote the values that I don't know, which are the the values for the estimated data. \begin{align} 80 &= \frac{1}{5} ((1000-x)+(800-y)+(900-z)+(1100-w)+(900-t)) \\[5pt] 20000 &= \frac{1}{5} ((1000-x)^2+(800-y)^2+(900-z)^2+(1100-w)^2+(900-t)^2) \end{align} I tried different values for $x,y,z,w,t$ until I found one estimated values combination that has the requested MAE and MSE. These values are: 900,800, 900, 800 and 900. So I got something like this: \begin{align} 80 &= \frac{1}{5} ((1000-900)+(800-800)+(900-900)+(1100-800)+(900-900)) \\[5pt] 80 &= 80 \\[5pt] 20000 &= \frac{1}{5} ((1000\!-\!900)^2+(800\!-\!800)^2+(900\!-\!900)^2+(1100\!-\!800)^2+(900\!-\!900)^2) \\[5pt] 20000 &= 20000 \end{align}

So I could prove that the situation was possible, but this doesn't seem a very handy way of doing that because there are a lot of possible combinations.

Is there any other way to check if a situation is possible or not given the MAE, MSE and the real data?

• You should be able to formulate this as a system of equations, and then the task is to solve it in terms of the parameters you are allowed to vary. Which of the two steps do you find problematic? – Richard Hardy Nov 27 '16 at 18:23
• Please explain what you mean by "MAE" and "MSE". Ordinarily the former refers to "mean absolute error" (around the mean), but for your data that value is $88$, not $80$. Ordinarily the latter refers to "mean squared error" (also about the mean), but for your data that value is $10400$, not $20000$. And to what "model" do you refer? What do you mean by "estimated values"? – whuber Nov 27 '16 at 18:41
• @RichardHardy I thought about that but I have 2 equations for 5 unknowns. PD I edited the question to clarify – Iván Rodríguez Torres Nov 27 '16 at 19:32
• @whuber I updated the question. Thank you for the advices. If you think I must clarify anything more, please, let me know. – Iván Rodríguez Torres Nov 27 '16 at 19:33
• If you spelled these equations out in your post, it would already be a step forward, IMHO. – Richard Hardy Nov 27 '16 at 19:36

I interpret your question as being about the feasibility of a solution rather than its computation.

Let your "real data" be $$\{y_i\}_{i=1,\ldots, n}$$ and the "estimated data" be $$\{\hat{y}_i\}_{i=1,\ldots, n}$$. Define $$z_i = |y_i - \hat{y}_i|$$.

Using the fact that $$Var(z_i) \geq 0$$, we can show that $$MSE(y, \hat{y}) = mean[z_i^2] \geq mean[z_i]^2 = MAE(y, \hat{y})^2$$.

We also have $$n MAE^2 \geq MSE$$ because the $$L_1$$ norm of a vector is larger than its $$L_2$$ norm.

Your MSE and MAE values satisfy both these properties, therefore satisfying the necessary conditions for feasibility.

These two properties are also sufficient for feasibility as long as $$n \geq 2$$.

Proof: We need to find non-negative $$z_i$$ ($$i = 2, \ldots, n$$) such that $$\sum_i z_i = n MAE$$ and $$\sum_i z_i^2 = n MSE$$.

Set $$z_1 = MAE + a$$ and $$z_i = MAE - \frac{a}{n-1}$$ for $$i = 2, \ldots, n$$, where $$a = \sqrt{(n-1) (MSE - MAE^2)}$$.

It's easy to check that the the MSE and MAE values work out to what we want, and we can use the fact that $$n MAE^2 \geq MSE$$ to show that all the $$z_i$$s are non-negative.

Bottomline The two inequalities $$MAE^2 \leq MSE \leq n MAE^2$$ are both necessary and sufficient to be able to find an "estimated" vector that results in the particular MSE and MAE values.

• This seems to make sense. Would you mind provide some source (link to a article or a book or similar) where I can find the two conditions for feasibility? I haven't heard about them before – Iván Rodríguez Torres Dec 8 '16 at 10:04
• I checked the method and it works like a charm. Using this, you get one value for each z and they are right. But there are several combinations for z values that work, for example z={100,0,0,300,0}. Is there a way to get all this values for z? – Iván Rodríguez Torres Dec 8 '16 at 10:30
• I don't have a reference for this. It's a simple result that depends on norms of vectors. Also, as @whuber mentioned in his comment, there are infinite solutions for $z$, unless you restrict it by imposing other conditions. – Innuo Dec 8 '16 at 13:55

The condition MAE≤MSE≤nMAE may be sufficient but is not necessary. It does not hold in the the case of the original example where MSE=20000 and is not <= 5x80=400. It seems that a better condition is (n MAE) squared >= n MSE . In the original example, (n MAE) squared = 160,000 and n MSE = 100,000 and therefore a solution can be found. This condition is based on the inequality: [sum abs(Z_i)] squared >= sum (Z_i squared). Z_i is the difference between f(i) and h(i).

• You forgot the squares for the MAE in your inequality. In the OP's data it is definitely true that MSE = 20000 < 5 * 80^2 = n MAE^2. – Innuo Dec 7 '16 at 22:16
• I noticed after posting the above comment that I had a typo in my answer where I omitted the square on MAE myself. Since fixed. – Innuo Dec 8 '16 at 13:57