I am writing an .ado file to calculate tests of coefficients similar to -test-. I cannot use the code of -test- or -lrtest- directly because the test is not a Wald test nor a likelihood ratio test.

I need to evaluate whether the expressions involving the coefficients are well formed and linear (in the coefficients). Does anyone know of code in Stata or Mata which will help me do that?

I looked at -test.ado- hoping to lift some of its code, but the part which evaluates expressions is in the built-in command -_test-. Similarly -constraint-, which also evaluates linear expressions, is a built-in command. -egen- commands allowing expressions generally pass them to built-in commands like -summarize-.

I am realizing this is a tricky task because I need to allow expressions like "1/3*_b[length]" but reject expressions like "1/_b[length]".

Thanks,

John Gallup

I need to evaluate whether the expressions involving the coefficients are well formed and linear (in the coefficients). Does anyone know of code in Stata or Mata which will help me do that?

I looked at -test.ado- hoping to lift some of its code, but the part which evaluates expressions is in the built-in command -_test-. Similarly -constraint-, which also evaluates linear expressions, is a built-in command. -egen- commands allowing expressions generally pass them to built-in commands like -summarize-.

I am realizing this is a tricky task because I need to allow expressions like "1/3*_b[length]" but reject expressions like "1/_b[length]".

Thanks,

John Gallup

## Comment