# Fitting time series when errors are correlated

**URL:** <https://root-forum.cern.ch/t/fitting-time-series-when-errors-are-correlated/2977>\
**Category:** ROOT\
**Created:** [February 13, 2006, 10:08pm UTC](https://root-forum.cern.ch/t/fitting-time-series-when-errors-are-correlated/2977 "2006-02-13T22:08:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Per\_Thomas\_Hille](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/d78d45/32.png) [@Per\_Thomas\_Hille](https://root-forum.cern.ch/u/Per_Thomas_Hille)\
**Post date:** [February 13, 2006, 10:08pm UTC](https://root-forum.cern.ch/t/fitting-time-series-when-errors-are-correlated/2977/1 "2006-02-13T22:08:17Z")

</div>

I am working with software fro online analysis of PHOS/ALICE detector data  
for the high level trigger (HLT).

Our detector response is shaped with a second order semi Gaussian  
shaper with a rise time of ~4us. The signal is over sampled (That is errors are correlated). Im trying to find the ROOT packages to anylse my data, but the TMinuit  
package, and the other packages in ROOT doesnt seems to taker into account correlated errors.

Is there any ROOT packages to handle the general case of the optimum fit  
problem. That is, when errors might be correlated and the model for the  
detetor response is nonlinear.

Fortunatly, one can most likely assume that the measurement correlation matrix  
is Hermitan symetric.

I know one is doing something similar for track reconstruction where the scattering angle is is correalted with the spatial dispacement.

Regards  
Per Thomas

---

<div class="post-metadata">

**Author:** ![Eddy\_Offermann](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eddy_offermann/32/25079_2.png) [@Eddy\_Offermann](https://root-forum.cern.ch/u/Eddy_Offermann)\
**Post date:** [February 14, 2006, 1:56am UTC](https://root-forum.cern.ch/t/fitting-time-series-when-errors-are-correlated/2977/2 "2006-02-14T01:56:24Z")

</div>

Hi Per Thomas,

> [@](#):
>
> but the TMinuit  
> package, and the other packages in ROOT doesnt seems to taker into account correlated errors.

This statement is not correct ! Minuit is a general function minimizer . It  
is up to the user to specify the correct objective function which can  
among others contain terms for correlation between data points .

Eddy

---

<div class="post-metadata">

**Author:** ![Per\_Thomas\_Hille](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/d78d45/32.png) [@Per\_Thomas\_Hille](https://root-forum.cern.ch/u/Per_Thomas_Hille)\
**Post date:** [February 14, 2006, 8:25pm UTC](https://root-forum.cern.ch/t/fitting-time-series-when-errors-are-correlated/2977/3 "2006-02-14T20:25:28Z")

</div>

Ok, I realize that have to be alittle bit more specific abouth my question.  
May quastion is.

Is there any rootpackages available to handle the genral  
Leas Mean Square (LMS) problem. Where the word "Mean"  
implies that one is working with the least square fit based on the  
knowledge of the statistical properties of the process.  
(Same as Leas square fit in the special case when error are uncorrelated).

Per Thomas

---

<div class="post-metadata">

**Author:** ![Eddy\_Offermann](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eddy_offermann/32/25079_2.png) [@Eddy\_Offermann](https://root-forum.cern.ch/u/Eddy_Offermann)\
**Post date:** [February 14, 2006, 10:13pm UTC](https://root-forum.cern.ch/t/fitting-time-series-when-errors-are-correlated/2977/4 "2006-02-14T22:13:55Z")

</div>

Hi,

Let me try to write down what I think you are talking about :

You have a data set (x\_ij, y\_i, e\_i) for i=1,N points  
where there are j=1,M control variables and a covariance  
structure so that

```
      E(e_l e_k) = Cov_lk where E() means expectation value

```

You want to determine a function yFit(par,x) , assuming Gaussian  
statistics … , this will lead to the following objective function:

```
     (y-yFit)^T Cov (y-yFit)

```

Plug this expression in a function for Minuit and minimize wrt the  
parameters par . The matrix /vector manipulations can be done  
through TVectorD/TMatrixD …

Eddy

ps Googling “fitting auto-correlated time series”, you will find the  
following interesting write-up:

```
 cran.r-project.org/doc/contrib/ Fox-Companion/appendix-timeseries-regression.pdf
```
