#include #include //#include /*POT-POURRI DE FONCTIONS POUR PANEL ESTIMATION (WITH SIMULATIONS) 1) DISTINCVAL 2) HALTONSEQ 3) HALTDRAWSUNIF 4) HALTDRAWS 5) HALTPANEL 6) SMOOTH RECURSIVE SIMULATOR (GHK) 7) SEQX */ // DISTINCVAL *************************** static distincval(const vX,const OPTIONS) { decl N,i,y,vNumwave,rowsvX,x; y = sortc(vX); N = y[0]; rowsvX = sizer(vX); i=1; while(i; d = new matrix[N*R][1]; draws = new matrix[N][R*D]; if(options==1) for(i=0;i1 .? d-1 .: d; draws[][i*R:(i+1)*R-1] = shape(d,N,R); } return draws; } // END FUNCTION (FROM BELLEMARE) // HALTON DRAWS FROM DIFFERENT DIST. **** /*Procedure to draw quantiles from various continuous distributions based on inverting Halton draws derived from the proc 'haltdraws'. It creates a N by R*D matrix of draws where N is the number of observations, R the number of draws per dimension and D is the dimension of the space we draw from. w: Specifies the number of points in the Halton sequence that is thrown away options: Choses the type of Randomization applied to the Halton sequence 1) Long N*R sequence for each dimension, cut into bits on R elements 2) 1-Modulus with uniform draw for each dimension distrib: Specifies the distribution from which quantiles should be drawn 1) Univariate normal distribution with support [-infinity, +infinity]. 2) Univariate extreme value type 1 Gumbel distribution 3) Univariate log-normal distribution */ static haltdraws(const R, const N, const D, const w, const options, const distrib) { decl x,draws; draws = new matrix[N][R*D]; x = new matrix[N][R*D]; x = haltdrawsunif(R,N,D,w,options); if(distrib==1) { draws = quann(x); draws = setbounds(draws,-5,5); } else if (distrib==2) {draws = -log(-log(x));} else if (distrib==3) {draws = exp(x);} return draws; } //END FUNCTION ************************ // HALTON DRAWS FOR PANEL *************** /*The following proc computes R randomized Halton draws for N observations and blows them up to be used for unbalanced individual random effects integration. Each individual participates in a 'Numwave' number of periods. The proc calls 'haltdraws' to generate R*D number of draws for this individual. This row is then vertically concatenated 'Numwave' number of times according to a N by 1 vector 'Numwave' which contains excatly the number of waves this individual will be in the panel.This corresponds to the eps[i] defined in the following equation y[i][t] = x[i][t]'beta + eps[i]; t=1,...Numwave[i]. */ static haltpanel(const R, const N, const D, const w, const options, const distrib, const numwave) { decl x,draws,i,j,count; x = haltdraws(R,N,D,w,options,distrib); draws = new matrix[sumc(numwave)][R*D]; count = 0; for (decl i = 0; i20) */ static GHK(const mV, const A, const B, const mS, const mL, const mD, const R) { decl j,mU,GB,GA,mProb; mU = new matrix [rows(mS)][R]; GB = GA = new matrix[1][R]; mU[0][] = quann(mD[][0:R-1].*probn((B[0]-mV[0]) /(mL[0][0]+1.e-100).*ones(1,R)) +(1-mD[][0:R-1]).*probn((A[0]-mV[0]) /(mL[0][0]+1.e-100).*ones(1,R))); mProb = probn((B[0]-mV[0])/(mL[0][0]+1.e-100) .*ones(1,R))-probn((A[0]-mV[0])/ (mL[0][0]+1.e-100).*ones(1,R)); for (j=1;j