Hello Statalist
I am trying to write a program that contains multiple equations where the weights used for each equation can be different. Let's call it eqspec for now. I would like the syntax to be something like
To parse the equations I am using the _eqlist class. This works fine when there are no weights specified, but fails when I include weights, as the following example shows.
Should _eqlist allow equation specific weights (it is largely undocumented)?
Is there is a better / alternative way to parse the equations given to eqspec?
Any advice gratefully received. Tim
I am trying to write a program that contains multiple equations where the weights used for each equation can be different. Let's call it eqspec for now. I would like the syntax to be something like
Code:
eqspec (reg y1 x1 [weight], options) (reg y2 x2 [weight], options) , global_options
Code:
program define eqspec syntax anything(equalok) [pweight] gettoken lhs rhs: anything, parse("=") tempname o .`o' = ._eqlist.new, numdepvars(1) wtypes(pw) .`o'.parse `lhs' return list local k_eq = `.`o'.eq count' // Number of univariate models forvalues k = 1/`k_eq' { local eqname`k' `.`o'.eq name `k'' // Univariate model for equation k di as res `"`eqname`k''"' } end * Test on auto data sysuse auto, clear * Generate weight variables gen pw1 = rnormal(1,.1) gen pw3 = rnormal(1,.05) * No weights defined eqspec (logit: foreign) (reg: length) * Global weight variable eqspec (logit: foreign) (reg: length) [pw=pw1] * Equation-specific weight variables - returns error. eqspec (logit: foreign [pw=pw1]) (reg: length [pw=pw3])
Is there is a better / alternative way to parse the equations given to eqspec?
Any advice gratefully received. Tim
Comment