| function model=differentiate_dsge(f,yp,y,xp,x,symparams,approx,Phi)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| disp('Preparing perturbation...')
|
|
|
| currentFolder = pwd;
|
| mkdir('files');
|
| cd('files')
|
|
|
| syms sigma_perturbation sigmap_perturbation real
|
| Phi=sym(Phi);
|
| f=sym(f);
|
|
|
| x=[x(:);sigma_perturbation];
|
| xp=[xp(:);sigmap_perturbation];
|
|
|
| v=[yp(:); y(:); xp(:); x(:)];
|
|
|
| n_f=length(f);
|
| n_x=length(x);
|
| n_y=length(y);
|
| n_x2=size(Phi,1);
|
| n_x1=n_f-n_y;
|
| n_v=length(v);
|
|
|
| model.f=f;
|
| model.yp=yp;
|
| model.y=y;
|
| model.xp=xp;
|
| model.x=x;
|
| model.v=v;
|
| model.n_f=n_f;
|
| model.n_x=n_x;
|
| model.n_y=n_y;
|
| model.n_x2=n_x2;
|
| model.n_x1=n_x1;
|
| model.n_v=n_v;
|
|
|
| create_compression_matrices_nonzero;
|
|
|
| if approx>=1
|
| model.f_ind=getderivs_vector(f,v,approx,symparams,'f');
|
| end
|
|
|
|
|
|
|
| gen_fun(Phi,symparams,x,'Phi');
|
| if approx>=1
|
| model.Phi_ind=getderivs(Phi,x,approx,symparams,'Phi');
|
| end
|
|
|
| create_OMEGA_x;
|
|
|
| model.UW=UW;
|
|
|
| if approx<3
|
| OMEGA_x=[];
|
| end
|
| model.OMEGA_x=OMEGA_x;
|
|
|
| rehash;
|
|
|
| disp('Perturbation prepared successfully.')
|
|
|
| cd(currentFolder)
|
|
|
|
|