/* Code for "Youth unemployment in the OECD: the role of institutions" by Andreas Sachs and Werner Smolny*/ /* The code originally stems from Sala-i-Martin et al. (2004) and has been adjusted to an unbalanced panel data set*/ new; NT=408; // Only required for data loading col=24; //has to fit to the text-file ILO = 1; //specify here which data source is used. Essential for the construction of the unbalanced panel! pmsize=6; // prior model size dummy = 1; //If dummy = 1 dummies are constructed, else estimation without fixed effects dep = 1; //Selection of dependent variable: if 1 then total unemployment, if 2 then youth unemployment, if 3 then adult unemployment, if 4 alternative youth unemployment load datacompl[NT,col] = Data_publicable.txt; missings=(datacompl[.,dep].<-900); //Delete missings data = delif(datacompl,datacompl[.,dep].<-900); y=data[.,dep]; y_scaling = y; if y[1,1]>3; y = y/100; //Scaling depends on size of dependent variable. Necessary to ensure convergence elseif y[1,1]<3; y = y/10; endif; x=data[.,5:7 13 10 12 15 16 11 14 8 9 22 23]; //Selection of explanatory variables. See the excel data file for variable names shock = data[.,17:21]; nobs = rows(x); nvar = cols(x); country = 17; periods =24; /* Construction of dummy variables for unbalanced case, see Baltagi (2003)*/ if dummy == 1; D = eye(country)|eye(country)|eye(country); D = D|D|D|D|D|D|D|D; delta1 = delif(D,missings); vec_temp = ones(country,1); start = 1; ii = 1; pp = 17; delta2 = zeros(rows(delta1),periods); qq = 1; do while start<=periods; delta2_part = D[ii:pp,1:country]; delta2_mis = missings[ii:pp,1]; delta2_part = delif(delta2_part,delta2_mis); delta2_part_final = delta2_part*vec_temp; delta2[qq:(qq+rows(delta2_part_final)-1),start] = delta2_part_final; ii = ii+17; pp = pp+17; qq = qq+rows(delta2_part_final); start = start+1; endo; delta = delta1~delta2; invdelta = pinv(delta'*delta); P_delta = delta*invdelta*delta'; Q_delta = eye(rows(P_delta))-P_delta; endif; y=Q_delta*y; x2=Q_delta*x; shock=Q_delta*shock; iprob = zeros(nvar,1); pprob = zeros(nvar,1); sprob=0; ess=0; sess=0; sumess=zeros(nvar,1); inclprob=pmsize/nvar; modelprob=zeros(nvar+1,1); summprob=0; k=0; number=zeros(nvar,1); scp=zeros(nvar,1); coeff=zeros(nvar,1); coeffu = coeff; varw=zeros(nvar,1); tolerance=ones(nvar,1)*10e-100; v4 = seqa(1,1,nvar); vin = zeros(1,nvar); lwb = 1; upb = 1; counter = 1; nreg = 0; j=0; do until j+1>nvar; pprob[j+1]= inclprob^j*(1-inclprob)^(nvar-j); j=j+1; endo; iprob = ones(nvar,1)*inclprob; maxreg = 2^nvar; h=RECSERRC(SEQA(0,1,maxreg),RESHAPE(2,nvar,maxreg)); for counter (2,maxreg,1); coinflip = h[.,counter]; number = number + coinflip; vout = coinflip.==0; select = delif(v4,vout); deselect = delif(v4,coinflip); x1=(delif(x2',vout))'; k=cols(x1); x=x1; x=x1~shock; { ess,beta,varb } = REGRES(x,y,k,pmsize); //Regression with the selected explanatory factors ess=ess*pprob[k]; sess=sess+ess; sumess = sumess+ess*coinflip; coeff[select]=coeff[select]+beta[1:k]*ess; //Calculation of model specific coefficients and standard errors varw[select]=varw[select]+(varb[1:k]+beta[1:k].*beta[1:k])*ess; print counter; endfor; coeffu=coeff./maxc(sess|tolerance); sdu=sqrt(varw./sess - coeffu^2); postprob=sumess/sess; //Gives the posterior inclusion probability coeffu = coeffu*100; sdu = sdu*100; if y_scaling[1,1] <3; coeffu = coeffu/10; sdu = sdu/10; endif; proc(3) = REGRES(x,y,k,pmsize); local b,invxx,resid,es,varb; invxx=inv(x'*x); b=invxx*x'y; resid=y-x*b; es=((resid'resid)^(-nobs/2)) / (nobs^((k-pmsize)/2)); varb =(resid'*resid)*diag(invxx)/(nobs-k-1); retp(es,b,varb); endp; output file = c: reset; //Enter the preferred path here print "postprob~coeffu~sdu"; print postprob~coeffu~sdu; output off; screen on;