# Re: st: Defining variables for the ml procedure

 From Ed Blackburne To statalist@hsphsun2.harvard.edu Subject Re: st: Defining variables for the ml procedure Date Sun, 09 Oct 2005 22:36:09 -0500

```Bjorn,

My understanding is that you want to estimate an equation of the form
(it doesn't much matter whether it is Z or Z[_N-1] for this post):

y=a+b(cZ+x)

Is this correct?
If so, I see two options.

Option 1: Estimate y=a+dZ+bx and use nlcom to recover c:
nlcom _b[Z]/_b[x]

Option 2: You can estimate via conditional likelihood (aka profile
likelihoods) using the undocumented hold option of ml.

If you would like a pointer at Option 2 let me know.

-Ed

On Sun, 2005-10-09 at 12:59 -0400, bpersson@bu.edu wrote:
> Dear Statalist,
>
> I am trying to estimate a nonlinear regression equation using the ml
> routine, and I am having problems defining one of my input variables.
>  Specifically, I would like to use the recursively defined variable
> Z(it):
>
> Z(it) = c*Z(it-1) + X(it)
>
> as an independent variable in my regression equation.  If the
> coefficient "c" is known, this variable can be generated as follows:
>
> gen Z = X
> bysort group (time): replace Z = c * Z[_n-1] + X if _n >= 2
>
> My problem is that I would like to estimate the coefficient "c" (along
> with the other regression coefficients) and therefore I need to define
> the variable Z(it) "within" the program itself.
>
> It seems, however, as if the "by" command and the "if" command are not
> allowed when specifying variables in the ml programs.  I would be most
> grateful if anyone would have any ideas on how to do this.
>
> Thank you for your help.
>
> Best
> Bjorn
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```