Commit 5417b27a authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Fixed indentation of matlab files.

parent 3d91cf97
......@@ -26,107 +26,107 @@ function [AHess, DLIK, LIK] = AHessian(T,R,Q,H,P,Y,DT,DYss,DOm,DH,DP,start,mf,ka
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
k = size(DT,3); % number of structural parameters
smpl = size(Y,2); % Sample size.
pp = size(Y,1); % Maximum number of observed variables.
mm = size(T,2); % Number of state variables.
a = zeros(mm,1); % State vector.
Om = R*Q*transpose(R); % Variance of R times the vector of structural innovations.
t = 0; % Initialization of the time index.
oldK = 0;
notsteady = 1; % Steady state flag.
F_singular = 1;
k = size(DT,3); % number of structural parameters
smpl = size(Y,2); % Sample size.
pp = size(Y,1); % Maximum number of observed variables.
mm = size(T,2); % Number of state variables.
a = zeros(mm,1); % State vector.
Om = R*Q*transpose(R); % Variance of R times the vector of structural innovations.
t = 0; % Initialization of the time index.
oldK = 0;
notsteady = 1; % Steady state flag.
F_singular = 1;
lik = zeros(smpl,1); % Initialization of the vector gathering the densities.
LIK = Inf; % Default value of the log likelihood.
if nargout > 1
DLIK = zeros(k,1); % Initialization of the score.
end
AHess = zeros(k,k); % Initialization of the Hessian
Da = zeros(mm,k); % State vector.
Dv = zeros(length(mf),k);
AHess = zeros(k,k); % Initialization of the Hessian
Da = zeros(mm,k); % State vector.
Dv = zeros(length(mf),k);
% for ii = 1:k
% DOm = DR(:,:,ii)*Q*transpose(R) + R*DQ(:,:,ii)*transpose(R) + R*Q*transpose(DR(:,:,ii));
% DOm = DR(:,:,ii)*Q*transpose(R) + R*DQ(:,:,ii)*transpose(R) + R*Q*transpose(DR(:,:,ii));
% end
while notsteady && t<smpl
t = t+1;
v = Y(:,t)-a(mf);
F = P(mf,mf) + H;
if rcond(F) < kalman_tol
if ~all(abs(F(:))<kalman_tol)
return
else
a = T*a;
P = T*P*transpose(T)+Om;
end
while notsteady && t<smpl
t = t+1;
v = Y(:,t)-a(mf);
F = P(mf,mf) + H;
if rcond(F) < kalman_tol
if ~all(abs(F(:))<kalman_tol)
return
else
F_singular = 0;
iF = inv(F);
K = P(:,mf)*iF;
lik(t) = log(det(F))+transpose(v)*iF*v;
[DK,DF,DP1] = computeDKalman(T,DT,DOm,P,DP,DH,mf,iF,K);
for ii = 1:k
Dv(:,ii) = -Da(mf,ii) - DYss(mf,ii);
Da(:,ii) = DT(:,:,ii)*(a+K*v) + T*(Da(:,ii)+DK(:,:,ii)*v + K*Dv(:,ii));
if t>=start && nargout > 1
DLIK(ii,1) = DLIK(ii,1) + trace( iF*DF(:,:,ii) ) + 2*Dv(:,ii)'*iF*v - v'*(iF*DF(:,:,ii)*iF)*v;
end
end
vecDPmf = reshape(DP(mf,mf,:),[],k);
% iPmf = inv(P(mf,mf));
if t>=start
AHess = AHess + Dv'*iF*Dv + .5*(vecDPmf' * kron(iF,iF) * vecDPmf);
end
a = T*(a+K*v);
P = T*(P-K*P(mf,:))*transpose(T)+Om;
DP = DP1;
a = T*a;
P = T*P*transpose(T)+Om;
end
notsteady = max(max(abs(K-oldK))) > riccati_tol;
oldK = K;
end
else
F_singular = 0;
iF = inv(F);
K = P(:,mf)*iF;
lik(t) = log(det(F))+transpose(v)*iF*v;
if F_singular
error('The variance of the forecast error remains singular until the end of the sample')
end
[DK,DF,DP1] = computeDKalman(T,DT,DOm,P,DP,DH,mf,iF,K);
if t < smpl
t0 = t+1;
while t < smpl
t = t+1;
v = Y(:,t)-a(mf);
for ii = 1:k
Dv(:,ii) = -Da(mf,ii)-DYss(mf,ii);
Da(:,ii) = DT(:,:,ii)*(a+K*v) + T*(Da(:,ii)+DK(:,:,ii)*v + K*Dv(:,ii));
if t>=start && nargout >1
DLIK(ii,1) = DLIK(ii,1) + trace( iF*DF(:,:,ii) ) + 2*Dv(:,ii)'*iF*v - v'*(iF*DF(:,:,ii)*iF)*v;
end
end
if t>=start
AHess = AHess + Dv'*iF*Dv;
end
a = T*(a+K*v);
lik(t) = transpose(v)*iF*v;
for ii = 1:k
Dv(:,ii) = -Da(mf,ii) - DYss(mf,ii);
Da(:,ii) = DT(:,:,ii)*(a+K*v) + T*(Da(:,ii)+DK(:,:,ii)*v + K*Dv(:,ii));
if t>=start && nargout > 1
DLIK(ii,1) = DLIK(ii,1) + trace( iF*DF(:,:,ii) ) + 2*Dv(:,ii)'*iF*v - v'*(iF*DF(:,:,ii)*iF)*v;
end
end
vecDPmf = reshape(DP(mf,mf,:),[],k);
% iPmf = inv(P(mf,mf));
if t>=start
AHess = AHess + Dv'*iF*Dv + .5*(vecDPmf' * kron(iF,iF) * vecDPmf);
end
AHess = AHess + .5*(smpl-t0+1)*(vecDPmf' * kron(iF,iF) * vecDPmf);
if nargout > 1
a = T*(a+K*v);
P = T*(P-K*P(mf,:))*transpose(T)+Om;
DP = DP1;
end
notsteady = max(max(abs(K-oldK))) > riccati_tol;
oldK = K;
end
if F_singular
error('The variance of the forecast error remains singular until the end of the sample')
end
if t < smpl
t0 = t+1;
while t < smpl
t = t+1;
v = Y(:,t)-a(mf);
for ii = 1:k
% DLIK(ii,1) = DLIK(ii,1) + (smpl-t0+1)*trace( iF*DF(:,:,ii) );
Dv(:,ii) = -Da(mf,ii)-DYss(mf,ii);
Da(:,ii) = DT(:,:,ii)*(a+K*v) + T*(Da(:,ii)+DK(:,:,ii)*v + K*Dv(:,ii));
if t>=start && nargout >1
DLIK(ii,1) = DLIK(ii,1) + trace( iF*DF(:,:,ii) ) + 2*Dv(:,ii)'*iF*v - v'*(iF*DF(:,:,ii)*iF)*v;
end
end
if t>=start
AHess = AHess + Dv'*iF*Dv;
end
a = T*(a+K*v);
lik(t) = transpose(v)*iF*v;
end
AHess = AHess + .5*(smpl-t0+1)*(vecDPmf' * kron(iF,iF) * vecDPmf);
if nargout > 1
for ii = 1:k
% DLIK(ii,1) = DLIK(ii,1) + (smpl-t0+1)*trace( iF*DF(:,:,ii) );
end
lik(t0:smpl) = lik(t0:smpl) + log(det(F));
% for ii = 1:k;
% for jj = 1:ii
% H(ii,jj) = trace(iPmf*(.5*DP(mf,mf,ii)*iPmf*DP(mf,mf,jj) + Dv(:,ii)*Dv(:,jj)'));
% end
% end
end
AHess = -AHess;
end
lik(t0:smpl) = lik(t0:smpl) + log(det(F));
% for ii = 1:k;
% for jj = 1:ii
% H(ii,jj) = trace(iPmf*(.5*DP(mf,mf,ii)*iPmf*DP(mf,mf,jj) + Dv(:,ii)*Dv(:,jj)'));
% end
% end
end
AHess = -AHess;
if nargout > 1
DLIK = DLIK/2;
end
......@@ -134,15 +134,15 @@ end
lik = (lik + pp*log(2*pi))/2;
LIK = sum(lik(start:end)); % Minus the log-likelihood.
% end of main function
% end of main function
function [DK,DF,DP1] = computeDKalman(T,DT,DOm,P,DP,DH,mf,iF,K)
k = size(DT,3);
tmp = P-K*P(mf,:);
k = size(DT,3);
tmp = P-K*P(mf,:);
for ii = 1:k
DF(:,:,ii) = DP(mf,mf,ii) + DH(:,:,ii);
DF(:,:,ii) = DP(mf,mf,ii) + DH(:,:,ii);
DiF(:,:,ii) = -iF*DF(:,:,ii)*iF;
DK(:,:,ii) = DP(:,mf,ii)*iF + P(:,mf)*DiF(:,:,ii);
Dtmp = DP(:,:,ii) - DK(:,:,ii)*P(mf,:) - K*DP(mf,:,ii);
......@@ -150,6 +150,3 @@ for ii = 1:k
end
% end of computeDKalman
\ No newline at end of file
......@@ -29,7 +29,7 @@ function e = SPAimerr(c)
% Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
% pages 472-489
if(c==1) e='Aim: unique solution.';
if(c==1) e='Aim: unique solution.';
elseif(c==2) e='Aim: roots not correctly computed by real_schur.';
elseif(c==3) e='Aim: too many big roots.';
elseif(c==35) e='Aim: too many big roots, and q(:,right) is singular.';
......
function [b,rts,ia,nexact,nnumeric,lgroots,aimcode] = ...
SPAmalg(h,neq,nlag,nlead,condn,uprbnd)
SPAmalg(h,neq,nlag,nlead,condn,uprbnd)
% [b,rts,ia,nexact,nnumeric,lgroots,aimcode] = ...
% SPAmalg(h,neq,nlag,nlead,condn,uprbnd)
%
......@@ -8,9 +8,9 @@ function [b,rts,ia,nexact,nnumeric,lgroots,aimcode] = ...
% roots. This procedure will fail if the companion matrix is
% defective and does not have a linearly independent set of
% eigenvectors associated with the big roots.
%
%
% Input arguments:
%
%
% h Structural coefficient matrix (neq,neq*(nlag+1+nlead)).
% neq Number of equations.
% nlag Number of lags.
......@@ -19,9 +19,9 @@ function [b,rts,ia,nexact,nnumeric,lgroots,aimcode] = ...
% by numeric_shift and reduced_form.
% uprbnd Inclusive upper bound for the modulus of roots
% allowed in the reduced form.
%
%
% Output arguments:
%
%
% b Reduced form coefficient matrix (neq,neq*nlag).
% rts Roots returned by eig.
% ia Dimension of companion matrix (number of non-trivial
......@@ -57,7 +57,7 @@ function [b,rts,ia,nexact,nnumeric,lgroots,aimcode] = ...
% pages 472-489
b=[];rts=[];ia=[];nexact=[];nnumeric=[];lgroots=[];aimcode=[];
if(nlag<1 || nlead<1)
if(nlag<1 || nlead<1)
error('Aim_eig: model must have at least one lag and one lead');
end
% Initialization.
......@@ -75,17 +75,17 @@ if (iq>qrows)
end
[a,ia,js] = SPBuild_a(h,qcols,neq);
if (ia ~= 0)
if any(any(isnan(a))) || any(any(isinf(a)))
if any(any(isnan(a))) || any(any(isinf(a)))
disp('A is NAN or INF')
aimcode=63;
return
end
aimcode=63;
return
end
[w,rts,lgroots,flag_trouble]=SPEigensystem(a,uprbnd,min(length(js),qrows-iq+1));
if flag_trouble==1
disp('Problem in SPEIG');
disp('Problem in SPEIG');
aimcode=64;
return
end
end
q = SPCopy_w(q,w,js,iq,qrows);
end
test=nexact+nnumeric+lgroots;
......
......@@ -41,9 +41,9 @@ hs(:,left) = -hs(:,right)\hs(:,left);
a = zeros(qcols,qcols);
if(qcols > neq)
eyerows = 1:qcols-neq;
eyecols = neq+1:qcols;
a(eyerows,eyecols) = eye(qcols-neq);
eyerows = 1:qcols-neq;
eyecols = neq+1:qcols;
a(eyerows,eyecols) = eye(qcols-neq);
end
hrows = qcols-neq+1:qcols;
a(hrows,:) = hs(:,left);
......@@ -51,14 +51,14 @@ a(hrows,:) = hs(:,left);
% Delete inessential lags and build index array js. js indexes the
% columns in the big transition matrix that correspond to the
% essential lags in the model. They are the columns of q that will
% get the unstable left eigenvectors.
% get the unstable left eigenvectors.
js = 1:qcols;
zerocols = sum(abs(a)) == 0;
while( any(zerocols) )
a(:,zerocols) = [];
a(zerocols,:) = [];
js(zerocols) = [];
zerocols = sum(abs(a)) == 0;
a(:,zerocols) = [];
a(zerocols,:) = [];
js(zerocols) = [];
zerocols = sum(abs(a)) == 0;
end
ia = length(js);
......@@ -2,7 +2,7 @@ function q = SPCopy_w(q,w,js,iq,qrows)
% q = SPCopy_w(q,w,js,iq,qrows)
%
% Copy the eigenvectors corresponding to the largest roots into the
% remaining empty rows and columns js of q
% remaining empty rows and columns js of q
% Author: Gary Anderson
% Original file downloaded from:
......@@ -30,7 +30,7 @@ function q = SPCopy_w(q,w,js,iq,qrows)
if(iq < qrows)
lastrows = iq+1:qrows;
wrows = 1:length(lastrows);
q(lastrows,js) = w(:,wrows)';
lastrows = iq+1:qrows;
wrows = 1:length(lastrows);
q(lastrows,js) = w(:,wrows)';
end
......@@ -30,7 +30,7 @@ function [w,rts,lgroots,flag_trouble] = SPEigensystem(a,uprbnd,rowsLeft)
% Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
% pages 472-489
opts.disp=0;
opts.disp=0;
% next block is commented out because eigs() intermitently returns different rts
%try
% [w,d] = eigs(a',rowsLeft,'LM',opts);
......@@ -39,24 +39,24 @@ opts.disp=0;
% [mag,k] = sort(-mag);
% rts = rts(k);
%catch
%disp('Catch in SPE');
%pause(0.5);
%aStr=datestr(clock);
%eval(['save ' regexprep(aStr,' ','') ' a']);
try
[w,d]=eig(a');
catch
lasterr
w=[];rts=[];lgroots=[];
flag_trouble=1;
return
end
rts = diag(d);
mag = abs(rts);
[mag,k] = sort(-mag);
rts = rts(k);
%disp('Catch in SPE');
%pause(0.5);
%aStr=datestr(clock);
%eval(['save ' regexprep(aStr,' ','') ' a']);
try
[w,d]=eig(a');
catch
lasterr
w=[];rts=[];lgroots=[];
flag_trouble=1;
return
end
rts = diag(d);
mag = abs(rts);
[mag,k] = sort(-mag);
rts = rts(k);
%end
flag_trouble=0;
flag_trouble=0;
%ws=SPSparse(w);
ws=sparse(w);
......@@ -65,7 +65,7 @@ ws = ws(:,k);
% Given a complex conjugate pair of vectors W = [w1,w2], there is a
% nonsingular matrix D such that W*D = real(W) + imag(W). That is to
% say, W and real(W)+imag(W) span the same subspace, which is all
% that aim cares about.
% that aim cares about.
ws = real(ws) + imag(ws);
......
......@@ -36,12 +36,11 @@ right = qcols+1:qcols+neq;
zerorows = find( sum(abs( hs(:,right)' ))==0 );
while( any(zerorows) && iq <= qrows )
nz = length(zerorows);
q(iq+1:iq+nz,:) = hs(zerorows,left);
hs(zerorows,:) = SPShiftright(hs(zerorows,:),neq);
iq = iq + nz;
nexact = nexact + nz;
zerorows = find( sum(abs( hs(:,right)' ))==0 );
nz = length(zerorows);
q(iq+1:iq+nz,:) = hs(zerorows,left);
hs(zerorows,:) = SPShiftright(hs(zerorows,:),neq);
iq = iq + nz;
nexact = nexact + nz;
zerorows = find( sum(abs( hs(:,right)' ))==0 );
end
h=full(hs);
......@@ -37,14 +37,14 @@ right = qcols+1:qcols+neq;
zerorows = find( abs(diag(R)) <= condn );
while( any(zerorows) && iq <= qrows )
h=sparse(h);
Q=sparse(Q);
h = Q'*h;
nz = length(zerorows);
q(iq+1:iq+nz,:) = h(zerorows,left);
h(zerorows,:) = SPShiftright( h(zerorows,:), neq );
iq = iq + nz;
nnumeric = nnumeric + nz;
[Q,R,E] = qr( full(h(:,right)) );
zerorows = find( abs(diag(R)) <= condn );
h=sparse(h);
Q=sparse(Q);
h = Q'*h;
nz = length(zerorows);
q(iq+1:iq+nz,:) = h(zerorows,left);
h(zerorows,:) = SPShiftright( h(zerorows,:), neq );
iq = iq + nz;
nnumeric = nnumeric + nz;
[Q,R,E] = qr( full(h(:,right)) );
zerorows = find( abs(diag(R)) <= condn );
end
......@@ -2,7 +2,7 @@ function scof = SPObstruct(cof,cofb,neq,nlag,nlead)
% scof = SPObstruct(cof,cofb,neq,nlag,nlead)
%
% Construct the coefficients in the observable structure.
%
%
% Input arguments:
%
% cof structural coefficients
......@@ -51,17 +51,17 @@ qs=sparse(q);
qs(1:rc,1:cc) = sparse(cofb);
qcols = neq*(nlag+nlead);
if( nlead > 1 )
for i = 1:nlead-1
rows = i*neq + (1:neq);
qs(rows,:) = SPShiftright( qs((rows-neq),:), neq );
end
if( nlead > 1 )
for i = 1:nlead-1
rows = i*neq + (1:neq);
qs(rows,:) = SPShiftright( qs((rows-neq),:), neq );
end
end
l = (1: neq*nlag);
r = (neq*nlag+1: neq*(nlag+nlead));
qs(:,l) = - qs(:,r) \ qs(:,l);
qs(:,l) = - qs(:,r) \ qs(:,l);
minus = 1: neq*(nlag+1);
plus = neq*(nlag+1)+1: neq*(nlag+1+nlead);
......
......@@ -38,7 +38,7 @@ if(nonsing)
b = qs(1:neq,1:bcols);
b = full(b);
else %rescale by dividing row by maximal qr element
%'inverse condition number small, rescaling '
%'inverse condition number small, rescaling '
themax=max(abs(qs(:,right)),[],2);
oneover = diag(1 ./ themax);
nonsing = rcond(full(oneover *qs(:,right))) > condn;
......@@ -48,4 +48,3 @@ else %rescale by dividing row by maximal qr element
b = full(b);
end
end
......@@ -3,7 +3,7 @@ function [y] = SPShiftright(x,n)
% [y] = shiftright(x,n)
%
% Shift the rows of x to the right by n columns, leaving zeros in the
% first n columns.
% first n columns.
% Original author: Gary Anderson
% Original file downloaded from:
......
function [dr,aimcode,rts]=dynAIMsolver1(jacobia_,M_,dr)
% function [dr,aimcode]=dynAIMsolver1(jacobia_,M_,dr)
% Maps Dynare jacobia to AIM 1st order model solver designed and developed by Gary ANderson
% Maps Dynare jacobia to AIM 1st order model solver designed and developed by Gary ANderson
% and derives the solution for gy=dr.hgx and gu=dr.hgu from the AIM outputs
% AIM System is given as a sum:
% i.e. for i=-$...+& SUM(Hi*xt+i)= *zt, t = 0, . . . ,?
% AIM System is given as a sum:
% i.e. for i=-$...+& SUM(Hi*xt+i)= £*zt, t = 0, . . . ,?
% and its input as single array of matrices: [H-$... Hi ... H+&]
% and its solution as xt=SUM( Bi*xt+i) + @**zt for i=-$...-1
% with the output in form bb=[B-$... Bi ... B-1] and @=inv(Ho+H1*B-1)
% Dynare jacobian = [fy'-$... fy'i ... fy'+& fu']
% where [fy'-$... fy'i ... fy'+&]=[H-$... Hi ... H+&] and fu'=
% and its solution as xt=SUM( Bi*xt+i) + @*£*zt for i=-$...-1
% with the output in form bb=[B-$... Bi ... B-1] and @=inv(Ho+H1*B-1)
% Dynare jacobian = [fy'-$... fy'i ... fy'+& fu']
% where [fy'-$... fy'i ... fy'+&]=[H-$... Hi ... H+&] and fu'= £
%
% INPUTS
% jacobia_ [matrix] 1st order derivative of the model
% jacobia_ [matrix] 1st order derivative of the model
% dr [matlab structure] Decision rules for stochastic simulations.
% M_ [matlab structure] Definition of the model.
%
% M_ [matlab structure] Definition of the model.
%
% OUTPUTS
% dr [matlab structure] Decision rules for stochastic simulations.
% aimcode [integer] 1: the model defines variables uniquely
......@@ -31,20 +31,20 @@ function [dr,aimcode,rts]=dynAIMsolver1(jacobia_,M_,dr)
% (c==63) e='Aim: A is NAN or INF.';
% (c==64) e='Aim: Problem in SPEIG.';
% else e='Aimerr: return code not properly specified';
%
%
% SPECIAL REQUIREMENTS
% Dynare use:
% Dynare use:
% 1) the lognormal block in DR1 is being invoked for some models and changing
% values of ghx and ghy. We need to return the AIM output
% values before that block and run the block with the current returned values
% of gy (i.e. dr.ghx) and gu (dr.ghu) if it is needed even when the AIM is used
% of gy (i.e. dr.ghx) and gu (dr.ghu) if it is needed even when the AIM is used
% (it does not depend on mjdgges output).
%
% 2) passing in aa={Q'|1}*jacobia_ can produce ~ one order closer
% results to the Dynare solutiion then when if plain jacobia_ is passed,
% i.e. diff < e-14 for aa and diff < *e-13 for jacobia_ if Q' is used.
%
% GP July 2008
% 2) passing in aa={Q'|1}*jacobia_ can produce ~ one order closer
% results to the Dynare solutiion then when if plain jacobia_ is passed,
% i.e. diff < e-14 for aa and diff < *e-13 for jacobia_ if Q' is used.
%
% GP July 2008
% Copyright (C) 2008-2012 Dynare Team
%
......@@ -69,8 +69,8 @@ lags=M_.maximum_endo_lag; % no of lags and leads
leads=M_.maximum_endo_lead;
klen=(leads+lags+1); % total lenght
theAIM_H=zeros(neq, neq*klen); % alloc space
lli=M_.lead_lag_incidence';
% "sparse" the compact jacobia into AIM H aray of matrices
lli=M_.lead_lag_incidence';
% "sparse" the compact jacobia into AIM H aray of matrices
% without exogenous shoc
theAIM_H(:,find(lli(:)))=jacobia_(:,nonzeros(lli(:)));
condn = 1.e-10;%SPAmalg uses this in zero tests
......@@ -102,7 +102,7 @@ if aimcode==1 %if OK
col_order=[((i-1)*neq)+dr.order_var' col_order];
end
bb_ord= bb(dr.order_var,col_order); % derive ordered gy
% variables are present in the state space at the lag at which they
% appear and at all smaller lags. The are ordered from smaller to
% higher lag (reversed order of M_.lead_lag_incidence rows for lagged
......@@ -117,7 +117,7 @@ if aimcode==1 %if OK
%theH0= theAIM_H (:,lags*neq+1: (lags+1)*neq);
% theHP= theAIM_H (:,(M_.maximum_endo_lag+1)*neq+1: (M_.maximum_endo_lag+2)*neq);
%theHP= theAIM_H (:,(lags+1)*neq+1: (lags+2)*neq);
theAIM_Psi= - jacobia_(:, size(nonzeros(lli(:)))+1:end);%
theAIM_Psi= - jacobia_(:, size(nonzeros(lli(:)))+1:end);%
%? = inv(H0 + H1B1)
%phi= (theH0+theHP*sparse(bb(:,(lags-1)*neq+1:end)))\eye( neq);
%AIM_ghu=phi*theAIM_Psi;
......@@ -137,8 +137,8 @@ else
if aimcode < 1 || aimcode > 5 % too big exception, use mjdgges
error('Error in AIM: aimcode=%d ; %s', aimcode, err);
end
% if aimcode > 5
% if aimcode > 5
% disp(['Error in AIM: aimcode=' sprintf('%d : %s',aimcode, err)]);
% aimcode=5;
% end