Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Fw: ADO file for ML estimation and temporary variables
From
Daniele Pacifico <[email protected]>
To
[email protected]
Subject
st: Fw: ADO file for ML estimation and temporary variables
Date
Fri, 17 Sep 2010 00:20:30 +0000 (GMT)
Dear Stata users,
I am trying to write an ado file for a maximum likelihood estimator and I hope
you can help me with a problem I found..
Let's assume I have an ado file called "newcmd1.ado" that should perform
some manipulations of the variables in "varlist"..
Here is the syntax:
**********************************
program newcmd1
newcmd1 varlist [if] [in], etc...
**********************************
Note that "newcmd1.ado" is not an estimation command.. It just performs
manipulations of existing variables..
At some point, this ado file calls another ado file - "newcmd2.ado" - that
should perform the maximisation of a likelihood function.
The results of this maximisation will be used WITHIN "newcmd.ado" (the first
one) once the
likelihood has been estimated (by using newcmd2.ado).
Hence, in the middle of "newcmd1" it appears the syntax for the other ado file
"newcom2":
**********************************
newcmd2 varlist2 [if] [in], etc..
**********************************
Since this is an estimation file, we also need "newcmd2_ll", which contains
the ml evaluator..
Okay, the first problem is how to pass the temporary variables that
"newcmd1" creates before calling "newcmd2" into the ml evaluator contained
in "newcmd2".. Importantly, these variables are EXTRA variables with respect to
those in "varlist2", i.e. the equation that I want to compute the
parameters of (see the syntax of newcmd2 above for "varlist2"..).
More crucially, these "extra" temporary variables should also be read WITHIN
newcmd2_ll.. but this seems really impossible!
Here is an example of my problem:
In "newcmd1.ado" I create a local variable `age' and a local scalar `ls'.. both
these elements will be needed within "newcmd2.ado"..
In "newcmd2.ado" I specified the syntax line as:
**********
program newcmd2
syntax varlist [if] [in], ncl(real) othervar(varlist)
**********
Hence - in "newcmd1" - I can write this:
**********
local varlist2 `sex educ'
newcom2 `varlist2', ncl(`ls') othervar(`age')
**********
In this way, I manage to pass the elements I need - the scalar `ls' and
the variable `age' - from "newcmd1.ado" to "newcmd2.ado"..
Clearly, in "newcmd2" the scalar `ls' is now called `ncl' and the local variable
`age' is now `othervar'.. (Isn't this a waste of memory by the way?).
Well, these two elements are then used within "newcmd2.ado" to create some NEW
elements: new temporary variables and new local scalars..
So, I would like to copy/exchange these new elements from "newcmd2" to
"newcmd2_ll" since
they enter the likelihood function I want to maximize.. However, neither `ncl'
nor `othervar' can be read within newcmd2_ll... How is it possible? How can I
push a temporary variable created within newcmd2.ado into the ml evaluator
"newcmd2_ll"?
Hope you can help me, I do not know what else I can try!
Thanks in advance,
Daniele Pacifico
*
* 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/