AR Model programming

Dear user of le forum!

Im am trying to implement an Autoregression model and estimating the parameters.
The code I have so far, reading the data and calculating the error term does work perfect! But the whole problem is when I want to minimize my error term by changing the parameters.....

Im more used to programming in oxmetrics and Matlab so I really could use some help with knowing how to optimize my parameters!!!

Im not looking for the answers but a few clues or hints would really be great!


¿is your problem the implementation in c++, or you don't even have an algorithm?
http://en.wikipedia.org/wiki/Levinson_recursion
My problem is the implementation, i just cant seem to understand what to do with residuals so that i can optimize my parameters in C++
1
2
3
4
5
6
7
8
9
10
11
12
r = autocorrelation(output);
err = r(1)
a(1,1) = -r(2)/err;

	for K=[2:max_order]
		alpha = -1/err * ( r(K+1)+ dot(a([1:K-1],K-1),r([K:-1:2])) );
		a(K,K) = alpha;
		for L=[1:K-1]
			a(L,K) = a(L,K-1) + alpha*a(K-L,K-1);
		end
		err = err*(1-alpha**2);
	end
the columns of `a' stored the coefficients to the K order.
The residual is used to compute \alpha
Im so glad you took the time to help me out. I will program this now, again thank you
Topic archived. No new replies allowed.