# Re: st: passing variables names to sub-programs

 From Antoine Terracol To statalist@hsphsun2.harvard.edu Subject Re: st: passing variables names to sub-programs Date Thu, 26 Feb 2009 19:37:52 +0100

```Carlo,

local eq "y = x1 x2"
gettoken dep indep0 : eq , parse("=")
gettoken indep0 indep : indep0 , parse("=")

di "`dep'"
di "`indep'"

local eq "y  x1 x2"
gettoken dep indep : eq

di "`dep'"
di "`indep'"

Antoine

Carlo Fezzi wrote:
```
```Dear all,

I am writing a program to maximize the likelihood function of a simultaneous
equation model (in specific, it is a simultaneous equation heteroskedastic
Tobit model via Quasi Maximum Likelihood, but it is not important for the
current question.. I just mention it because I would be very happy to make
it a standard .ado file once fine-tuned). In such a model it is very useful
to specify as starting values the parameters estimated for the single
equations estimated separately, which are much faster to be estimated.
However, I cannot figure out which are the right commands and syntax to use
to pass the structure of the equations defined by the user from the
multiequation program to the single equation ones.

To explain better, let’s consider a model composed by 3 equations:

---------------------
program multiequation
args mu1 mu2 mu3 lnsigma1 lnsigma2 lnsigma3 ar12 ar13 ar23

*** mu_i = mean parameters, lnsigma_i = variances, ar_ij = correlations ***

mat b0 = 0

** b0 = matrix of starting values **

forvalues i = 1/3 {
tempname b`i'
ml model lf singlequation_ll (mu`i': “y in mu_i” = “x in mu_i”) ///
(lnsigma`i': “x in lnsigma_i”)
ml maximize
mat	b`i' = e(b)
mat b0 = b0,b`i'
}
mat b0 = b0[1...,2...]
ml init b0
ml model multiequation_ll etc...
-------------

The problem is that I cannot figure out the right syntax to indicate the
dependent and the explanatory variables that are included in mu_i (indicated
in the program by “y in mu_i” and “x in mu_i”) and in lnsigma_i (“x in
lnsigma _i”). These are decided by the user in the usual way (e.g. mu1: y1 =
x1 x2) when the “multiequation” program runs, but I don’t know how to pass
that information to the “singlequation_ll” program.

I would greatly appreciate any advice on this,

All the best,

Carlo

**************************************************
Carlo Fezzi
Senior Research Associate
Centre for Social Research on the Global Environment (CSERGE)
Department of Environmental Sciences
University of East Anglia
```
Norwich (UK) NR2 7TJ Telephone: +44(0)1603 591385
```Fax: +44(0)1603 593739
*************************************************

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

```
```

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```