Extrapolate Optimal Rule Function from Ramsey Problem

Dear All

I have an important doubt to resolve. In my DSGE model I have households, firms, government and central bank with the presence of public capital , public expenditure and public investments and distortionary taxation.
In setting the welfare maximization problem I used a Ramsey Decision problem and Dynare returns me the welfare losses. But on an analytical level I would need to derive / extrapolate the optimal functional form of one of the variables from which Dynare then calculates the welfare loss.
For example, if I wanted to right in my paper the relative one the variable of public spending, by hand, I would have to derive the lagrangian of the single equations eliminating any lagrange multiplier by substitution to obtain the optimal rule of public spending. is it a feasible procedure with a large number of lagrange multiplier? or there is another procedure to do this?

Thank You all for your help
My Best

Sorry, but I don’t really understand the problem from the quite generic description. Could you maybe provide precise details what you are trying to do and where the problem is?

Thank you for your answer Professor @jpfeifer .
For sure.
I have my model with government and I want to find the optimal decision rule for the public spending. So I impose the Ramsey Problem.
By hand i need to construct my Lagrangian with all the constraint of the economy maximising the (households) utility function (the model is quite large with its conditions - 25 lagrange multiplier - )
Deriving and by substitution i need to extrapolate by the maximization problem the optimal rule for the public spending (in the same way for the household maximization problem in deriving e.g. Euler equation or Lucas Equation for Capital). I suppose thath when i Impose the Ramsey problem in Dynare, the software for sure find the optimal function for every control variable and then theoretically calculate the welfare losses from that optimal decision.
My question is: Is dynare able to give me directly that functional form imposing the Ramsey Problem for a given variable ? or i need another procedure? Or I need to use another method to get this result?
Thank You