# How to fit the coefficients of a first order linear auto-regressive function without noise in the model, and the coefficient are equal?

I have a simple auto-regressive function:

$x_{i+1} = c - cx_{i}$

It is `linear` and `first order`. There is no noise in the model although there is in the data. I am using `Matlab` and have a vector (time series) of numbers that has arisen from a process governed by the above equation. I would like to obtain the value of the coefficient $c$ for the least squares fit to this data.

How can this be done in Matlab by using a library function or toolbox? I have looked at the ar command, but fail to see how this can be used in my case. I consider writing instead a function to take the data and calculate the root-mean-squared error over a set of possible values for $c$ choosing the one that is smallest.

-

1
For any $1 \leq i < n$, we have $c = x_{i+1} / (1-x_i)$. – cardinal Mar 9 '12 at 0:53
@cardinal, I think that I made a mistake in the question which I edited, there is no noise modeled although the data contains noise. – Vass Mar 9 '12 at 0:57

2
What do you mean "There is no noise in the model but there is in the data"? That doesn't seem to make a whole lot of sense on the surface. – cardinal Mar 9 '12 at 0:59
@cardinal, I want to say is that the data I am fitting to has noise, and I want to find the best value of `c` without including any extra parameters to account for the noise – Vass Mar 9 '12 at 1:03

4
Even in the regression setting, the gist of my statement still stands. If $\mathbb E( X_{i+1} \mid X_i ) = c - c X_i$, then the least-squares estimate of $c$ is $$\hat c = \frac{\sum_i x_{i+1}(1-x_i)}{\sum_i (1-x_i)^2} \> .$$ – cardinal Mar 9 '12 at 1:05

## 1 Answer

It makes no sense to say there is no noise in the model but there is in the data. I think your model should be a standard AR(1) with a parameter constraint: $$x_{i+1} = c(1-x_i) + e_i$$ where $e_i$ is white noise.

Then the least squares estimate of $c$ is $$\hat{c} = \frac{\sum x_{i+1}(1-x_i)}{\sum (1-x_i)^2}.$$

-
(+1) Is this a subtle hint I should be posting my comments as an answer? :) – cardinal Mar 9 '12 at 1:37
Sorry. I think your comment must have gone up at about the same time as my answer. In any case, I didn't see it before I posted. If we both derived the same result, it is probably correct! – Rob Hyndman Mar 9 '12 at 2:41
No reason to be sorry at all! :) It was interesting how similar it was. I'm glad you posted it! Cheers. – cardinal Mar 9 '12 at 2:42
@RobHyndman and @cardinal, is this available in Matlab to be computed as a function (just out of curiosity). Also, in the case where the equation has 2 parameters and a squared `x_i` term is there an analogous method of evaluation? – Vass Mar 9 '12 at 7:52

1
@Vass. You will need to write your own Matlab function. It should be about 3 lines at most. For the version with squared x_i, you will need to derive the estimators and then write the corresponding function. – Rob Hyndman Mar 9 '12 at 10:17
show 1 more comment
default
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 9, "mathjax_display_tex": 3, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9370516538619995, "perplexity_flag": "head"}