# Least squares fitting of an iterative function

I have a set of data which need to be modelled by a function which is defined iteratively. IE $$N(t) = 2*N(t-1)+a*N(t-1)$$

Where a is the parameter to be fitted. This isn't the function, it's just as an example. How do I go about least squares when I have an iterative function? Particularly looking for an answer which I can program in MATLAB. All the toolboxes I've seen just fit a normal function like a polynomial or something.

Anyone done this before??

• these sort of things have been done since sooo.. long time ago. – Seyhmus Güngören Oct 16 '15 at 14:35

Say you observe $N_t$ for $t=1,2,...,T$. Then you may consider the following model:$$N_t=\beta N_{t-1}+e_t$$
where $e_t$ is some error term. Under some assumptions (OLS assumptions) you may estimate $\beta$ by $$\hat{\beta}=\frac{\sum_{t=2}^TN_tN_{t-1}}{\sum_{t=2}^TN_{t-1}^2}$$