Dynare creating too many temporary variables

Hi,

I’m currently attempting to do a second order approximation of a relatively large system (around 60 variables, 2500 parameters, and fairly complicated model expressions) and I get the following error message:

"Error using feval
The current workspace already has too many variables; there is no room for “T854468”.

Error in stochastic_solvers (line 107)
[junk,jacobia_,hessian1] = feval([M_.fname ‘_dynamic’],z(iyr0),…

Error in resol (line 141)
[dr,info] = stochastic_solvers(dr,check_flag,M,options,oo);

Error in stoch_simul (line 82)
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);

Error in aggregateDynamics (line 8010)
info = stoch_simul(var_list_);

Error in dynare (line 223)
evalin(‘base’,fname) ;

Error in mainFile (line 119)
dynare aggregateDynamics minimal_workspace"

The error comes after the preprocessing is completed and the steady state is computed (using an external _steadystate.m file) without error. So my guess is that the preprocessor creates a lot of temporary terms as part of the differentiation routine (see slide 59 of “preprocessor.pdf” in the doc folder), and when Matlab evaluates the _dynamic.m file it runs out of room in the workspace. I can compute the first order approximation no problem, so the extra terms must be coming from the second order derivatives.

If anyone has any advice for me, I would really appreciate it! Some ideas I had: are there ways to reduce the amount of temporary terms created in the preprocessor? (I think that these temporary terms are created because they are common components in the derivatives) Or, is there a way to write my system to minimize the number of temporary terms created? Or, is there a way to clear the unnecessary terms from Matlab’s memory, without messing up the final evaluation of the derivatives? Or, a way to increase the size of Matlab’s workspace? I’m already using the minimal_workspace option in the unstable snapshot by invoking “dynare filename.mod minimal_workspace” in Matlab.

As a last resort, I am thinking of feeding in my own derivative matrices, and calling Dynare’s functions to do the rest of the model computation and analysis.

Thanks,

Tom

Pass the notmpterms argument to the dynare command line. I.e.: dynare model.mod notmpterms You can read more about it and other command line options in the manual.

Thanks Houtan! This is exactly the option I was looking for. Sorry to waste your time, I thought I had looked everywhere for a solution, but apparently missed this entry in the manual.