TAC Method for Fitting Exponential Autoregressive Models and Others: Applications in Economy and Finance

: There are a couple of purposes in this paper: to study a problem of approximation with exponential functions and to show its relevance for the economic science. We present results that completely solve the problem of the best approximation by means of exponential functions and we will be able to determine what kind of data is suitable to be fitted. Data will be approximated using TAC (implemented in the R-package nlstac ), a numerical algorithm for fitting data by exponential patterns without initial guess designed by the authors. We check one more time the robustness of this algorithm by successfully applying it to two very distant areas of economy: demand curves and nonlinear time series. This shows TAC’s utility and highlights how far this algorithm could be used.


Introduction
This paper is planned to cover a couple of major objectives.Broadly, the first one is to solve one of the remaining issues in [1].Later, in this same introduction, this first objective will be introduced in a detailed way.The second one is to exemplify the interest, for the economic science, of the algorithm presented in [1] and implemented in the R-package nlstac, see [2].We have developed this algorithm in order to fit data coming from an exponential decay.Therefore we will illustrate the interest of this algorithm by fitting the pattern in a couple of cases related with different economic problems.
The first economic problem deals with demand curves.Economic demand curves can be used to map the relationship between the consumption of a good and its price.When plotting price (actually the logarithm of the price) and consumption, we obtain a curve with a negative slope, meaning that when price increases, demand decreases.Hursh and Silberbeg proposed in [3] an equation to model this situation; in this paper, we will fit some data using that model.
The second economic problem is about nonlinear time series models.Many financial time series display typical nonlinear characteristics, so many authors such as [4] consider to apply nonlinear models.Although our algorithm was not designed for this kind of problems, we will obtain good results using it.In this example we will focus on the model that, among all nonlinear time series models, seems to have more relevance in the literature, namely, the exponential autoregressive model.
Before we get into the first objective, let us see the structure of this paper.Section 2 deals with approximations by means of exponential functions measuring the error with the max-norm when fitting a small set of data: 3 or 4 observations.Later, Section 3 is devoted to some symmetric cases that could happen.Section 4 deals with approximation in general datasets.Section 5 gathers two examples about Newton Law of Cooling and directly apply what have been developed in this paper.Section 6 shows examples related to economy and use the R-package nlstac for the calculations.Although the economical section represents 1 out of the 6 sections of this paper, it remains a very important one, and everything we have been working on before directly apply there.
We will focus in the first objective in Sections 2 to 5. In those sections we will deal with approximations by means of exponential functions and we will measure the error with the max-norm.So, when we say that some function f is the best approximation for some data (t, T ), we will mean that we have t = (t 1 . . ., t n ), T = (T 1 . . ., T n ) ∈ R n , with t i < t i+1 for every i, and that {(t, f (t)) : t ∈ [t 1 , t n ]} ⊂ R 2 is the centre of the narrowest band that contains every point and has exponential shape, see Figure 1.
The authors already proved in [1] that for every k ∈ R, k ̸ = 0, there exists the best approximation f k (t) = a k exp(kt) + b k amongst all the functions of the form a exp(kt + b), with a, b ∈ R. We also showed that, given any dataset (t, T ), the function E ∞ (k) that assigns to every k ∈ (−∞, 0) the error max |T i − f k (t i )| is quasiconvex, so there are two options.Namely, either E ∞ attains its minimum at some k or it is monotonic.If E ∞ is monotonic, then either it is increasing and the minimum would be attained, so to say, at −∞, or it is decreasing and attains its minimum at k = 0. We will also study what happens for positive k, so we will need to pay attention not only to the behaviour of the exponentials but also to their limits when k → 0 and k → ±∞, see Proposition 2 and Subsection 3.2.

Notation 1. Our main results show that every dataset (t, T ), with at least four data, fulfils one of the following conditions:
• There exists one triple (a, b, k) ∈ R 3 with ak ̸ = 0 such that a exp(kt) + b is the best possible approximation, i.e., max i=1,...,n In this case, the best approximation by means of exponentials does not exist and the constant 1 2 (T i 1 + T i 2 ) approximates (t, T ) better than any strictly monotonic function -in particular any exponential.So, for every k ∈ R, the best approximation with the form a exp(kt) + b has a = 0 and b = 1 2 (T i 1 + T i 2 ).It happens exactly the same when the maximum is attained at i 2 and the minimum at i 1 and i 3 , with i 1 < i 2 < i 3 .In both cases, the function E ∞ is constant.
. ., T n } and T attains its second greatest value at i 3 > i 2 .The best approximation by means of exponentials does not exist and every exponential approximates (t, T ) worse than any function fulfiling f (t 1 ) = The pointwise limit of the best approximations when k → −∞ takes these values.(The symmetric cases belong to this kind of limits, maybe with In blue, the points, in black the best approximation and in green the upper and lower borders of the narrowest band that contains (t, T ).Yes, the band has constant width.
• There are some c, d ∈ R such that the line ct + d approximates (t, T ) better than any exponential.In this case, each ct i + d is the limit when k → 0 of the values in t i of the best approximations with k as exponent.This happens when there are four indices This implies that E ∞ decreases in (−∞, 0).

Remark 1.
What happens with this kind of functions is the following: consider two exponentials that agree at α < β ∈ R, say g(α) = f (α) > g(β) = f (β).Then, the following are equivalent: A visual way to look at this is the following.Consider a wooden slat supported on two points and imagine we put a load between the supports.When we increase the load, the slat lowers between the two supports but the other part of the slat raises.For these functions, the behaviour is similar -if two of them agree at α and β then one function is greater than the other in (α, β) and lower outside [α, β].
Besides, if α < β and f (β) < f (α) then for each (γ, x) that does not lie in the line defined by (α, f (α)) and (β, f (β)) and belongs to there is exactly one exponential h such that h does not belong to the set given by (1), then there is no monotonic function that fulfils the later.The existence of such an exponential is a straightforward consequence of [1,Lemma 2.10] -we will develop this later, see Proposition 4.

Remark 2.
A significant trouble when dealing with the problem of approximating datasets with exponentials has been to find conditions determining whether some dataset is worth the try or not.The only way we have found to answer this problem has been to identify the most general conditions that ensure that some dataset has one best approximation by exponentials -needless to say, this has been a very sinewy problem.The different behaviours described in Notation 1 can give a hint about the several different details that we will need to deal with, but there is still some casuistry that we need to break down.Namely, our main interest in these results comes from the fact that they can be applied to exponential decays, which appear in several real-life problems -the introduction in [1] presents quite a few examples.The typical data that we have worked with are easily recognizable, but we needed to determine when the data may be fitted with a decreasing, convex, function -like the exponentials f (t) = a exp(kt) + b with a > 0, k < 0. The easiest way we have found is: • If some data (t, T ) are to be fitted with a decreasing function and we are measuring the error with the max-norm, then the maximum value in T must be attained before the minimum.There may exist more than one index where they are attained, but every appearance of the maximum must lie before every appearance of the minimum.In short, if T i = max(T ) and T j = min(T ), then i < j.  [7, Theorem 8 page 29] or [8]) we know that the line that best approximates any dataset behaves either this way, either the opposite or the third case in 1. Please observe that this theorem would not apply so easily to approximations with general degree polynomials.
Before we go any further, let us comment something about the notation that will be used.For the remaining of the paper we will always take n as the number of coordinates of t and T , i.e., t, T ∈ R n .Besides, t ∈ R n will fulfil t 1 < t 2 < . . .< t n .
Moreover, for any k ̸ = 0 we will always denote as f k (t) = a k exp(kt) + b k the best approximation with the form f (t) = a exp(kt) + b with a, b ∈ R.
In a try to ease the notation, whenever we have some function f : R → R and t = (t 1 , . . ., t n ) ∈ R n , f(t) will denote (f (t 1 ), . . ., f (t n )) ∈ R n , and the same will apply to any fraktur character: g(t), r(t), f 1 (t), f 2 (t), f k (t) would represent the same for g, r, f 1 , f 2 , f k : R → R and so on.
Given any vector v = (v 1 , . . ., v n ), M(v) will denote its maximum and M (v) will denote its minimum.

Small datasets
In this Section we are going to show some not too complicated, general results about the behaviour of exponentials that will allow us to prove our main results in Section 4. We will focus only in the approximation of the most simple datasets, with n = 3 or n = 4.
We will begin with Proposition 1, just a slight modification of [1, Proposition 2.3] that will be useful for the subsequent results.Later, in Lemma 1, we will find the expression of the best approximation for ((t 1 , t 2 , t 3 ), (T 1 , T 2 , T 3 )) for each fixed k (please note that with n = 2, for every k there is an exponential that interpolates the data).In Lemma 2 we study the case n = 4, determining a technical condition on (t, T ) that ensures that the best approximation exists and it is unique and, moreover, we kind of determine analytically this best approximation.
Then, there exist indices Reciprocally, if a k and b k fulfil this condition, then a k exp(kt) + b k is the best approximation to T for this k.Lemma 1.Let n = 3, k ̸ = 0 and T 1 ̸ = T 3 .Then, the best approximation to (t, T ) by means of exponentials has these coefficients: ), and a simple computation shows that By Proposition 1, this is enough to ensure that a k and b k are optimal.
Remark 3. Please observe that a k does not depend on (t 2 , T 2 ).
Then, there exists a unique exponential Moreover, this exponential is the best approximation to (t, T ).
Proof.Let (t, T ) be as in the statement.For k ∈ R, k ̸ = 0, there exist unique a, b ∈ R such that a exp(kt 1 ) + b = T 1 and a exp(kt exp(kt 2 )−exp(kt 4 ) .So, the equalities (4) hold if and only if, for some k ̸ = 0, we have a Please observe that this equality holds trivially when k = 0 and that, as both T 1 − T 3 and T 2 − T 4 are positive, we are not trying to divide by 0.
If we put z = exp(k), the last equality can be written as We will denote as p(z) the left hand side of this equality.
As we are only interested in positive roots of p, we can divide by z t 1 and consider Taking into account that q(0) = T 2 − T 4 > 0, that q obviously vanishes at 1 (but this root corresponds to the void case k = 0 and so a + k and a − k are not defined) and also that the limit of q(z) is ∞ as z goes to ∞, there must exist another z ∈ (0, ∞), maybe z = 1, such that p(z) = q(z) = 0.By Descartes' rule of signs, see [9] Theorem 2.2, both q and p have at most two positive roots, so there is exactly another positive root of p.To determine whether this root is greater or smaller than 1, we can compute the derivative of p at 1.
so the other root of p lies between 0 and 1 whenever the condition in the statement is fulfiled.
So, there exists just one k = log(z) ∈ (−∞, 0) for which and f (t) = a exp(kt) + b we have the function we were looking for.
As for the moreover part, suppose that there exist a, b, k such that f (t) = a exp(kt) + b approximates (t, T ) at least as well as f .We may suppose that Remark 4. This Lemma gives a kind of analytic solution to the best approximation problem, with the only obstruction of being able to determine the other root of p.In the next section, we do the same with the symmetric cases and give actual analytic solutions to the same problem when the data are not good to be approximated by exponentials, ironically.

Symmetric cases and limits
In this section we will focus in those cases that do not match with the problem we have in mind but, nevertheless, have their own interest.First we approach the symmetric cases such as, for example, exponential growths.Second, we approach the limit cases, that is, the ones whose best approximation is not an exponential but the limit as k → 0 or k → −∞ of exponentials.They are not what one can expect to find while adjusting data that follow an exponential decay but we have been able to identify when they occur and deal successfully with them.

Symmetric cases
If (t, T ) and f are as in the statement of Lemma 2, then a moment's reflection is enough to realize that: as its best approximation.

2.
The T -symmetric data as its best approximation.
These symmetries correspond to the following: ) < 0, then there are still two changes of sign in the coefficients of p, so it has another positive root.The difference here is that both a and k are positive.Please observe that this means that (T 2 − T 4 )/(t 2 − t 4 ) > (T 1 − T 3 )/(t 1 − t 3 ) > 0, so f must be increasing and increases faster for greater t.

Limit cases
Even if the conditions are not fulfiled by any symmetric version of the dataset, the computations made in the proof of Lemma 2 give the answer to the approximation problem: ) > 0, then z = 1 is a double root -this corresponds to k = 0-and the "exponential" we are looking for is a line with negative slope.Namely, its slope is (T 3 − T 1 )/(t 3 − t 1 ) and this best approximation is the line given by Chebyshev's Alternation Theorem.

2.
If (T -this is symmetric to the previous case.

3.
If T 1 = T 3 or T 2 = T 4 , then we have, up to symmetries, three cases: then there is no global best approximation, but every exponential approximates (t, T ) worse than the limit, with k → −∞, of the best approximations.This limit is and it turns out to be also a kind of best approximation for every then the situation is as follows: As M(T ) lies before M (T ), any good approximation must be nonincreasing.T attains its second greatest value after M (T ), so every decreasing function approximates (t, T ) worse than the function f(t) defined as in (6).Actually, (t 2 , T 2 ) could be ignored whenever as we are about to see in the last item: 4.
Finally, if T 1 − T 3 and T 2 − T 4 have different signs, then there is just one change of signs in the coefficients of p, so the only positive root of p is z = 1 and k = 0, and there is no function fulfilling the statement.More precisely, this situation has two paradigmatic examples with t = (1, 2, 3, 4) and T = (3, 0, 1, 2) or with t ′ = (1, 2, 3, 4) and T ′ = (3, 1, 0, 2).In the first case, the third point (3, 1) simply does not affect the approximation in the sense that, for every k, the exponential f k : R → R that best approximates T fulfils 3, 4 and this, along with Proposition 1, implies that f k cannot be the best approximation.
The second case is similar.Though the point (t ′ 2 , T ′ 2 ) = (2, 1) is relevant for some approximations, it is skippable for every k < k 0 for some k 0 < 0.

General datasets
In this Section, we apply the previous results to datasets with arbitrary size in order to find out when a dataset has an exponential as its best approximation.Before we arrive to this first objective main result, Theorem 1, we will need several minor results.The path that we will follow is, in a nutshell, the following: Lemma 3 is a technical Lemma that allows us to show that the maps Lemma 4 is just Chebyshev's Alternation Theorem, and it suffices to determine which datasets are good to be approximated by decreasing, convex, functions -like exponential decays.We will call that datasets admissible from Definition 1 on.
Then we determine the vectors one obtains by taking limits of exponentials with exponents converging to ±∞ or 0, see Proposition 2.
With all these preparations, we are ready to translate Lemma 2 to a more general statement, keeping the n = 4 condition.We give a necessary and sufficient condition for any dataset (t, T ) to be approximable by exponential decays in terms that are easily generalizable to n > 4.This is Proposition 3.
In Proposition 3 and 2 we improve the results in Corollary 1 to get Remark 6, where we show that we can handle the best approximations at ease if the variations of k are small enough.
Finally, Proposition 5, reduces the general problem to the n = 4 case, thus getting Theorem 1. Lemma 3. Let k 0 ̸ = 0 and f k 0 (t) = a k 0 exp(kt) + b k 0 be the best approximation for k 0 and suppose that there are exactly three indices i < j < m such that the equalities hold.Then, there exists ε > 0 such that, for every k ∈ (k 0 − ε, k 0 + ε) the equalities hold with the same indices.Moreover, if k ′ > k 0 is such that the indices where the norm is attained are not i < j < m, then there exists k ′′ ∈ [k 0 , k ′ ] for which the norm is attained in at least four indices.
As ktm) for every k ̸ = 0 we have α k 0 = a k 0 .If we take, further for every k.Given any l ∈ {1, . . ., n} \ {i, j, m}, our hypotheses give As the map k → f k (t l ) = α k exp(kt l ) + β k is continuous for every l, we obtain that holds for every k in a neighbourhood of k 0 , say (k 0 − ε l , k 0 + ε l ).Since there are only finitely many indices we may take ε as the minimum of the ε l to see that f k is the best approximation for k ∈ (k 0 − ε, k 0 + ε), and finish the proof of the first part.
As for the moreover part, it is quite obvious that the expression for f k will be if and only if, for every l ̸ ∈ {i, j, m}, one has Please observe that the symmetric inequalities could hold and it would make f k have the same expression, but this would imply n = 3. Anyway, if k ′ > k is such that there is some l for which Maybe it is not k ′′ = k, but taking k ′′ as the smallest real number in (k, k ′ ] for which there exists such an l, we are done.
for some 1 ≤ i < j < m ≤ n and δ = ±1, and this line approximates T better than any other line.
Proof.It is a particular case of the Chebyshev's Alternation Theorem, applied to the polygonal defined by (t, T ).
Remark 5. Thanks to Lemma 4, we can define which vectors T will be our "good vectors": those for which a < 0 and the equalities (8) hold with δ = 1 and not with δ = −1.When our data fulfil these conditions, we have some idea of decreasing monotonicity and also some kind of convexity, and this is the kind of dataset that we wanted, though we will need to add some further conditions.Anyway, when dealing with datasets that fulfil any couple of symmetric conditions we just need to have in mind the symmetries.Namely, they will behave as in Subsection 3.1.
Definition 1.Let r(t) = at + b be the line that best approximates (t, T ).We will say that (t, T ) is admissible when a < 0 and there exist 1 ≤ i < j < m ≤ n such that 1.
Once we have stated the kind of data which we will focus on, say discretely decreasing and convex, now we have to determine when they will be approximable.Before that, we will study the behaviour of the limits of best approximations.
Then ψ(k) depends on k but not on a k or b k and, moreover: Proof.We only need to make some elementary computations to show that ) .
The computation of the limit at 0 only needs a L'Hôpital's rule application, the other ones are even easier once one substitutes z = exp(k).See [1, Lemma 2.10].

4.
For Proof.Let k 0 ̸ = 0.If the best approximation for k 0 is a constant, then it is constant for every k ̸ = 0, and the constants are obviously the same.So, we may suppose f k is not a constant for any k ̸ = 0.In this case, Lemma 3 implies that k → f k (t l ) is continuous for every l.As we have just a finite amount of indices, this means that lim we are done. 2he proof of the three last items is immediate from Lemma 5: Then, the best exponential approximation to (t, T ) has the form f (t) = a exp(kt) + b with a > 0, k < 0 if and only if (t, T ) is admissible and the following does not happen: ♠ T 1 = M(T ) and the second greatest value of T is attained after M (T ).
Proof.As the second greatest value of T will appear frequently in this proof, we will denote it as M T = max{T i : i = 2, 3, 4}.Analogously, m T = min{T i : i = 2, 3, 4}.If ♠ happens, then the following is the limit of best approximations when k → −∞ Indeed, as f −∞ (t) is the pointwise limit of functions fulfiling (2), it must fulfil (2) too.It is clear that this implies that f −∞ (t) must be as in (9).It is clear that every strictly decreasing function approximates (t, T ) worse than f −∞ (t), so we have finished the first part of the proof.
Conversely, if (t, T ) is admissible then there are exponentials with a > 0, k < 0 that approximate (t, T ) better than the line r(t) = f 0 (t).Indeed, we only have to consider the three points of the Definition 1 and take into account Lemma 3. As the function error is quasiconvex, the only option for contradicting the statement is that every exponential is worse than the −∞ limit of the approximations f k , and of course this limit is not better than f −∞ (t) as in (9) because no vector of the form (x, y, y, y) approximates T better than this.So, we may suppose f −∞ (t) is the best approximation -and please recall that we are supposing that (t, T ) is We need to break down several possibilities: )/2 without increasing the error, so one best approximation is a constant and this means that a = 0, so (t, T ) is not admissible, a contradiction.II: If T 1 < m T then (t, T ) is not admissible.III: If T 1 > M T , then we still have some options: i: If T 2 ≤ T 4 then we obtain that ♠ holds, no matter the value of T 3 .
iii: If T 2 > T 4 and the rates of decreasing are equal, then (t, T ) is not admissible because this implies iv: If T 2 > T 4 and (T 2 − T 4 )/(t 4 − t 2 ) < (T 1 − T 3 )/(t 3 − t 1 ) then Lemma 2 ensures that the best approximation is f k (t) = a exp(kt) + b, with a > 0 and k < 0.
be the line that contains (t 1 , T 1 ) and (t 3 , T 3 ).In [1], Lemma 2.10, it is seen that, if g k (t) = a k exp(kt) + b, where , and b = T 1 − a k exp(kt 1 ), Essentially, the same proof suffices to show how g k (t 2 ) behaves: This implies that the map k → g k (t 2 ) is strictly increasing, while k → g k (t 4 ) is strictly decreasing.So, k → g k (t 2 ) increases as k → g k (t 4 ) decreases and, moreover, the map ϕ : (T 3 , T 1 ) → (−∞, T 3 ) given by ϕ(g k (t 2 )) = g k (t 4 ) for k ̸ = 0, and ϕ(r(t 2 )) = r(t 4 ) is a (decreasing) homeomorphism from (T 3 , T 1 ) to (−∞, T 3 ).Applying the same reasoning to t 0 < t 1 and to t 3 < t 4 we obtain this key result: Proposition 4. Let t 0 < t 1 < t 2 < t 3 < t 4 and T 1 > T 3 and consider for every k ̸ = 0 the only exponential g k (t) = a exp(kt) + b such that g k (t 1 ) = T 1 , g k (t 3 ) = T 3 and f 0 (t) the only line such that g 0 (t 1 ) = T 1 , g 0 (t 3 ) = T 3 .Then, all the following maps are homeomorphisms, ϕ 0 and ϕ 4 are decreasing and ϕ 2 is increasing: We can rewrite Proposition 4 as follows: Then, when k increases, g k (t 0 ) and g k (t 4 ) decrease and g k (t 2 ) increases and everything is continuous.
Proposition 5.The best exponential approximation (including limits) to (t, T ) is the best approximation for some quartet (( Proof.Let f k 0 be the best approximation and suppose that the conclusion does not hold.Then, we may suppose that there are exactly three indices where the norm is attained, say i < j < m and If f k 0 (t) is the limit at −∞ of the best approximations, then it is the best approximation for every quartet that contains ((t i , t j , t m ), (T i , T j , T m )) because this means that ♠ holds.So, suppose that the best approximation is f k 0 , for some k 0 ∈ R -maybe k 0 = 0.Then, for some ε > 0 the functions f k , with k ∈ (k 0 − ε, k 0 ) approximate this triple better than f k 0 .Reducing if necessary ε, Remark 6 implies that every f k with k ∈ (−ε, 0) approximates (t, T ) better than f k 0 , thus getting a contradiction.
Theorem 1.Let (t, T ) be admissible.Then, the best approximation is a exponential if and only if ♠ does not happen.
Proof.The proof of Proposition 3 is enough to see that ♠ avoids the option of (t, T ) being approximable by a best exponential.If (t, T ) is admissible, then the best approximation cannot be the 0-limit of exponentials, so it is either an exponential or the −∞-limit of exponentials.So, suppose it is the −∞-limit and let us see that in this case ♠ holds.It is clear that T 1 > M T = max{T 2 , . . ., T n } as in the proof of Proposition 3, so just need to show that M T occurs later than M (T ).Let m T = min{T 2 , . . . ,T n }.A moment's reflection suffices to realize that f −∞ (T m ) = (M T + m T )/2 for every m ≥ 2 and so, the error for f −∞ is exactly r = (M T − m T )/2.Let T i be the last appearance of M T and T j the first appearance of m T and suppose i < j, i.e., that ♠ does not hold.Thanks to Proposition 4, for small ε > 0 there is k close enough to −∞ so that we can find The value of b in (3) can be easily generalised, so we do not need to worry about it.If we are able to determine k and a k , then finding b is just a straightforward computation.Namely: With this b, the error is Proof.First, we are going to compute the error.Since, obviously, we just need to take into account that (10) implies On the one hand, this implies that the error is as in the statement.On the other hand, let b ′ < b.Then, so a exp(kt) + b ′ approximates T worse than a exp(kt) + b.The same happens with M (T − a exp(kt) − b ′ ) if we take b ′ > b, so the best approximation is the one with b as in (10).
With this section we have covered the theoretical aspects about the first objective of this paper.Examples in Section 5 are about Newton Law of Cooling and directly apply what have been developed here, ending this way our first objective.

Examples
In this section we present two different examples.We intend to apply what have been developed in previous sections to fit data following an exponential function.
The calculations in this section were carried out by means of a GNU Octave using an AMD Ryzen 7 3700U processor with 16GB of RAM.The system used is an elementary OS 5.1.7Hera (64-bit) based on Ubuntu 18.04.4LTS with a Linux kernel 5.4.0-65-generic.

Exponential decay in a Newton's law of cooling process
In section 4 of [1], the paper that motivated this one, we presented an example that was the beginning of our work.In this new approach we consider necessary to fit that very same data but using a new tool: approximation through the max-norm.
We are going to fit data coming from a thermometer achieving thermal balance at the bottom of the ocean.The time evolution of the temperature, according to Newton's law of cooling process, follows an exponential function as where λ 1 and λ 2 ∈ R and, in the considered case, k < 0.
We implemented an algorithm to fit, by a pattern as (11), and taking the max-norm as the approximation criteria, the records obtained by the device.The results corresponding to this implementation are gathered in Table 1.Table 2 of [1] shows similar information for the same fit but while using the Euclidean norm, so interested reader can compare both approximations.
In Figure 2 we present some graphical information about this approximation.Subfigure 2a shows observations and fit and Subfigure 2b shows the relative error in this implementation.We have designed this figures to resemble figure 3   (b) Relative error for values lower or equal than 0.07.on a small scale, the signed relative error.Figure 2. Some graphical aspects about this TAC implementation.In the numerical analisys bibliography, relative error is defined with or without sign; in this paper we will consider the latter.A spike can be seen in the small window of Figure 2b.This spike should not be considered as an indicator of a poor adjustment of the curve to the data.On the contrary: the spike is due to the proximity of the data to zero and, however, the error remains bounded.This is because curve and data are close enough to control the fact that we are virtually dividing by zero differences in the fit must exist.Nevertheless they both give a more than reasonable approximation.

Exponential decay attaining the max-norm in 4 indices
We wanted to show an example where Proposition 5 was fulfilled.Data from Example 5.1 was not good enough for us to find the 4 points at witch the norm attain its maximum, so we have chosen a different set of data -also coming from a thermometer achieving thermal balance.This new set of data allow us to show a visual perspective of Proposition 5: Figure 3 presents in red where the 4 points are.

Economical models and nlstac
Now we will cover the second objective: to exemplify the interest for the economic science of the algorithm presented in [1] and implemented in the R-package nlstac.The calculations in this section were carried out by the same machine as in Section 5 using RStudio instead of GNU Octave.

The exponential model in demand curves
In this example we will use the exponential model to fit demand curves.As stated in [10], 'behavioral economic demand analyses describe the relationship between the price (including monetary cost and/or effort) of a commodity and the amount of that commodity that is consumed.Such analyses have been successful in quantifying the reinforcing efficacy of commodities including drugs of abuse, and have been shown to be related to other markers of addiction.'Different mathematical representations of demand curves have been proposed -see, for example, [3].The most widely used model for demand curves in addiction research is presented in the following equation where Q represents consumption at a given price, Q 0 is known as derived demand intensity, k is a constant that denotes the range of consumption values in log units, C is the commodity price and α is the derived essential value, a measure of demand elasticity.This model was established by Hursh and Silberberg in [3] and has been used in many other works such as [10], [11] or [12].The parameters to be estimated are Q 0 , k and α.
Renaming log 10 (Q 0 ) − k as b, k as a and −α • Q 0 as d, the pattern is now similar to the one we have been working in this paper: Therefore we simply need to adjust consumption data to the pattern presented in (13) and undo the changes, being k = a, Q 0 = 10 b+k and α = − d Q 0 the parameters we originally sought.
We ran a simulation for this kind of data and successfully fitted it using R package nlstac.For the simulation we have established 15 as the number of observations, Q 0 as 48, α as 0.006, k as 3.42 and added some noise to the pattern with mean 0 and standard deviation 0.1.Tolerance value was set as 10 −7 .
Table 2 shows the result of this TAC implementation.As can be seen, output is reasonably similar to the values we originally established.Please take into account we added some noise to the data so differences in the parameters were expected.
In Figure 4 we can see the observations (blue dots) and the approximation (red dots).This approximation makes sense: it gets in the middle of the observations, keeping the errors under control.
The calculations in this section were carried out by the same machine as in Section 5 using RStudio instead of GNU Octave.

The exponential autoregressive model
As stated in [13], 'nonlinear time series models can reveal nonlinear features of many practical processes, and they are widely used in finance, ecology and some other fields.'Out of those nonlinear time series models, the exponential autoregressive (ExpAR) model is specially relevant.Given a time series {x 1 , x 2 , x 3 , . ..}, the ExpAR model is defined as where ε t is an i.i.d random variable and independent with x i and p denotes the system degree and c i , π i (for i = 1, . . ., p) and γ are the parameters to be estimated from observations.This model can be found in, for example, [13] or [14].We followed the notation of the former.Some generalizations for this model have been made and [14] presents a wide variety of those generalizations.Teräsvirta's model is an extension of the ExpAR model presented in [15] and used in [14].We will focus in a generalization of Teräsvirta's model that can be found in equation 10 of [14]: where z i (for i = 1, . . ., p) are scalar parameters and d is an integer number.We intend to fit data following (14) in the particular case when p = d = 2. Please observe that this problem is way beyond the proven convergence of TAC algorithm.It requires more than just fitting of a curve following some exponential function since now we have no function to be fitted because every observation depends on the previous ones.This obstacle can be overcome by looking at the problem not as a one-dimensional problem but as a two-dimensional one: if (x 1 , . . ., x n ) are the observations, denoting y = (x 3 , . . ., x n ), x 1 = (x 2 , . . ., x n−1 ), x 2 = (x 1 , . . ., x n−2 ), 1 = (1, n . .., 1), z 1 = z 1 • 1 and z 2 = z 2 • 1, data y will depend on two independent variables, x 1 and x 2 , and could be written as: where operator • represents the product between two vectors coordinate to coordinate, that is, given (a 1 , . . ., a n ), (b 1 , . . ., b n ) ∈ R n , (a 1 , . . ., a n ) • (b 1 , . . ., b n ) := (a 1 • b 1 , . . ., a n • b n ), and where the exponential and power functions are applied to each coordinate.As indicated before, this new approach is far for proven in the TAC convergence, however running nlstac package will provide us a result that stands to reason.
In Tables 3 and 4 we gather the results of this implementation.As can be seen, parameters are quite similar to the ones we have previously established.(14), RSS being residual sum of squares and M SE = RSS/n where n = 98 is the number of observations.

CPU
In Figure 5 we can see the approximations (red dots) over the actual observations (blue dots, a bit bigger than the red ones), which indicate the approximation is good.This example is specially relevant because it show us the possibility to use nlstac in a problem way different than the one it was intended, so it opens the door to its use in different nonlinear time series models or even in some other models.
Author Contributions: As can be deduced by the acknowledgments, all authors have been involved during the whole creative process of this paper.However we would like to note that the contributions of Javier Cabello Sánchez have been crucial in the results involving the max-norm.This same comment can be suitable for the examples presented in this paper, where Juan Antonio Fernández Torvisco has had a predominant role.Nevertheless Mariano R. Arias has been key to obtain the final version of the paper; connecting both major goals of this paper.

Figure 1 .
Figure 1.In blue, the points, in black the best approximation and in green the upper and lower borders of the narrowest band that contains (t, T ).Yes, the band has constant width.

Corollary 1 .Lemma 4 .
The maps k → a k , k → b k and k → f k (t) are continuous.Let T , t ∈ R n .There exists exactly one line r(t) = at + b such that Data and a small detail of TAC fit.

Figure 3 .
Figure 3. Blue dots represent differences between T and f k (t).In 4 dots, M(T − f k (t)) and M (T − f k (t)) are reached, and we have colored them in red.Those are the 4 points mentioned in Proposition 5. Please observe how the maxima and the minima are alternatively reached.

Table 2 :
Result of implementation of nlstac for pattern(12).RSS denote residual sum of squares and M SE = RSS/n where n = 15 is the number of observations.

Figure 4 .
Figure 4. Observations in blue, approximation in red.

Figure 5 .
Figure 5. Observations in blue, approximation in red (smaller circle).Please observe how each approximation lays over the actual observation.

Funding:
This research was partially supported by MICINN [research project references CTM2010-09635 (subprogramme ANT) and PID2019-103961GB-C21], MINECO [research project reference • Moreover, if we are going to approximate (t, T ) with a convex function, the dataset must have some kind of convexity.The only way we have found to state this is: ♡ "Let r(t) be the line that best approximates (t, T ).Then (T 1 − r(t 1 ), . . ., T n − r(t n )) has two maxima and one minimum between them."Thanks to Chebyshev's Alternation Theorem (the polynomial p n is the best approximation of function f in [a, b] if and only if there exists n + 2 points a ≤ t 1 < t 2 < . . .< t n+2 ≤ b where |f (t) − p n (t)| attains its maximum and f

Table 1 :
[1]1]so the reader can graphically compare the results of both approximations.Taking into account each example use a different norm, Result of implementation of TAC.

Table 4 :
Result of implementation of nlstac for pattern