cons=1; lag=3; 
q=1; dataset=1;            % dataset=1   if joines, mtrk1 
grate=1.0056;              %        =2   if joines, mtrl1 
                           %        =3   if seater, mcitseater 
                           %        =4   if seater, amtrhi 





if q; 
  load /home/erm/data/tax1
  [T,n]=size(zxvarn);
  z=[zxvarn(:,1)./(grate.^[1:T]'), ..
     zxvarn(:,2)./(grate.^[1:T]'), ..
     zxvarn(:,3)./(grate.^[1:T]'), ..
     zxvarn(:,4), ..
     zxvarn(:,5)./(grate.^[1:T]')];
  if dataset==1;                          
    z=[z,zxvarn(:,7)];
  end;
  if dataset==2;
    z=[z,zxvarn(:,8)];
  end; 
  if dataset==3;
    z=[z,zxvarn(:,9)];
  end; 
  if dataset==4;
    z=[z,zxvarn(:,10)];
  end; 
else;

end;

global z thet;
[T,n]=size(z);
z=z-ones(T,1)*mean(z);
%[A,SE,RES]=autor(z,lag,1);
%if cons;
%  tem=[ ]; tem1=[1:n*(n-1),n*n]';
%  A(1:n-1,[n:n:n*lag])=zeros(n-1,lag);
%  for i=1:lag;
%    tem=[tem;(i-1)*n*n+tem1];
%  end;
%  AA=A(:); AA=AA(tem);
%else;
%  AA=A(:);
%end;


load theta
%AA=theta(:);
theta0=theta;

%Q=cov(RES);
%tem=zeros(n);
%tem1=tril(ones(n));
%tem(tem1>0)=[1:n*(n+1)/2]';
%theta0=[AA;Q(tem>0)];
tem=[ ];
for i=1:lag;
  tem=[tem,z(lag-i+1:T-i+1,:)];
end;
z=tem;

[theta,like,grad,code,status]=uncmin(theta0,'junk');

save junk
