%EXAMPLE 2    computes GMM/MLE estimates for example in `Cattle cycles' by 
%             Rosen, et.al.   For this example, quantities (y,x,c) and
%             prices (p) are assumed to be observed.       

%             Ellen R. McGrattan, 7-20-93

%Files: mlgmmgx_1.m,mlgmmhx_1.m 

%Data:  drosen.mat

%Fixed params:

  rho2   = 0.0;
  sigma2 = 1;
  x0     = [0;17.56*ones(3,1);1;0;0;0];
  grate  = 1;
  Gam    = zeros(4);


%Parameters fixed during estimation:

  beta   = 0.96;
  delta  = 0;
  varm(4)= 1e-7;
  sig    = 0;
  f1     = 1.0247e-03; 
  f3     = 1.9193e-03; 
  f5     = 3.8389e-05; 
  f7     = 5.7707e-03; 


%Current estimates:

  alpha0 = 1.7128e+02;  
  alpha1 = 2.3010e+00;  
  gamma0 = 2.2095e-01;  
  gamma1 = 2.1112e+00;
  g      = 8.2469e-01; 
  rho1   = 7.2214e-01; 
  rho3   = 6.7386e-01; 
  sigma1 = 1.1362e+00; 
  sigma3 = 8.2850e+00; 
  muh    = 2.8008e+01; 
  mum    = 2.4024e+01;  
  varm(1)= 8.0892e-03;
  varm(2)= 1.4760e-01; 
  varm(3)= 7.5470e+00;  
 

%Current likelihood value:

  L      = 7.3047e+02; 



%Optimization of likelihood:

  Theta  = [alpha0;alpha1;beta;delta;gamma0;gamma1;f1;f3;f5;f7;g;rho1;rho2;
            rho3;sigma1;sigma2;sigma3;muh;mum;grate;sig;varm(:)];
  ind    = [1,1,0,0,1,1, 0,0,0,0, 1, 1,0,1, 1,0,1, 1,1, 0, 0, 1,1,1,0];
  Theta  = Theta(ind);
  load drosen
  xgmm   = ZVAR;
  global xgmm zgmm nobs qgmm Wgmm mgmm lgmm pshocks
  format short e
  zgmm     = ones(length(xgmm),1);
  pshocks  = randn(20*length(xgmm),2);
  n        = 1;
  wgt      = 0;
  nlag     = 0;
  restrict = 0;
  induc    = 0;
  [x,jstat,df1,thetac,rstat,df2,se]=mlgmmx(Theta,n,wgt,nlag,restrict,induc);
