Extract Lagged Variables from Equations
extract_lagged_vars.RdThis function extracts lagged variables from a given system of equations using a provided pattern that defines how lagged variables are structured.
It iterates over each equation, finds matching lag expressions, and
standardizes them in the form var.L(lag). It also rewrites each equation
to expand lag expressions and returns both the modified equations and the
set of unique lagged variables found.