function [y,dy]=marcetf2(beta,dummy);

beta=[beta(1:4),beta(5:8)];
delta=.89;
gam1=.7;
gam2= 1;
rho0=.1;
rho1=1.3;
rho2=-.4;
sige=sqrt(.016);
ks=.935;

phi1=exp(beta(1,1)+beta(2,1)*zxv(:,3)+beta(3,1)*zxv(:,4)+beta(4,1)*zxv(:,5));
phi2=exp(beta(1,2)+beta(2,2)*zxv(:,3)+beta(3,2)*zxv(:,4)+beta(4,2)*zxv(:,5));
v1=zxv(:,1)-phi1;
v2=zxv(:,2)-phi2;
y=(sum(v1.^2)+sum(v2.^2))/2500;
dy(1,1)=-sum(v1.*phi1)/1250;
dy(2,1)=-sum(v1.*phi1.*zxv(:,3))/1250;
dy(3,1)=-sum(v1.*phi1.*zxv(:,4))/1250;
dy(4,1)=-sum(v1.*phi1.*zxv(:,5))/1250;
dy(5,1)=-sum(v2.*phi2)/1250;
dy(6,1)=-sum(v2.*phi2.*zxv(:,3))/1250;
dy(7,1)=-sum(v2.*phi2.*zxv(:,4))/1250;
dy(8,1)=-sum(v2.*phi2.*zxv(:,5))/1250;

