‘Ramsey policy’ compute the first order approximation of the optimal policy rule. I would like to compute the second order approximation of welfare given by this rule.
My first idea was to write the model with the rule given by ramsey policy but it also depends on (state) lagrange multiplier and I don’t know how to get the equations for the lagrange multipliers.
It is not possible to use the ramsey_policy command of dynare to compute the welfare because, as you say, this command performs only a first order approximation. If you want to compute a second order approximation, you have to write yourself the (non linear) equations of the Ramsey allocation in the model block (non linear foc + equations for the Lagrange multiplier). This can be done using the symbolic math toolbox of matlab or, if you don’t want to pay for this, the symbolic math library of python (sympy).