viernes, 7 de noviembre de 2008

PIB Ecuador

//PRONOSTICO DEL AÑO 2008
vector=[21250 24899 28636 32642 37187 41763 45789 48508]';
n=length(vector)
vector1=[0;vector(1:n-1)]
vector2=[0;0;vector(1:n-2)]
x=[vector1,vector2]
b=inv(x'*x)*(x'*vector)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
x=[vector1 vector2]
a=inv(x'*x)*(x'*vector)
z=a(1)*vector1+a(2)*vector2
plot(t,[vector z])
//error1=vector-z
//sqrt(error1'*error1)
//plot(error1)
t=[1:n+1]';
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
z=a(1)*vector1+a(2)*vector2
plot(t,z)


//PRONOSTICO DEL AÑO 98
vector=[18573 20195 21268 23635 23255]';
n=length(vector)
vector1=[0;vector(1:n-1)]
vector2=[0;0;vector(1:n-2)]
x=[vector1,vector2]
b=inv(x'*x)*(x'*vector)
s=poly(0,'s')
s=s^2-b(1)*s-b(2)
raiz=roots(s)
t=[1:n]'
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
x=[vector1 vector2]
a=inv(x'*x)*(x'*vector)
z=a(1)*vector1+a(2)*vector2
plot(t,vector)
//error1=vector-z
//sqrt(error1'*error1)
//plot(error1)
t=[1:n+1]';
vector1=(raiz(1).^t)
vector2=(raiz(2).^t)
z=a(1)*vector1+a(2)*vector2
plot(t,z)

No hay comentarios: