*! 1.0.0 NJC 24 January 2000 after CFB program define _gfilter version 6.0 qui tsset /* error if not set as time series */ gettoken type 0 : 0 gettoken g 0 : 0 gettoken eqs 0 : 0 syntax varname [if] [in] , Lags(numlist int min=1) /* */ Coef(numlist min=1) [ * ] local nopts : word count `options' if `nopts' > 1 { error 198 } local normali 0 if `nopts' == 1 { local options = substr("`options'",1,7) local lopt = length("`options'") if "`options'" != substr("normali",1,`lopt') { error 198 } local normali = 1 } local ncoef : word count `coef' local nlags : word count `lags' if `nlags' != `ncoef' { di in r "lags( ) and coef( ) not consistent" exit 198 } marksample touse tokenize `coef' if `normali' { local i = 1 local total = 0 while `i' <= `ncoef' { local total = `total' + (``i'') local i = `i' + 1 } local i = 1 while `i' <= `ncoef' { local `i' = ``i'' / `total' local i = `i' + 1 } } local rhs "0" local i = 1 while `i' <= `nlags' { local l : word `i' of `lags' local L = -`l' local op = cond(`l' < 0, "F`L'.", "L`l'.") local rhs "`rhs' + (``i'') * `op'.`varlist'" local i = `i' + 1 } qui gen `type' `g' = `rhs' if `touse' end