Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: capture number of -xtmixed- iterations?


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: capture number of -xtmixed- iterations?
Date   Wed, 26 Dec 2007 15:11:08 -0500

Thanks. I figured this out eventually - actually, I copied
and modified -xtmixed.ado- to return e(ic), and then captured
that.

thanks,
Jeph

Yulia Marchenko, StataCorp wrote:
Jeph Herrin <[email protected]> wants to keep track of how many times
-xtmixed- failed to converge in the simulations:

I'm running a simulation using -simulate- to call a wrapper program for -xtmixed-. Sometimes -xtmixed- doesn't converge, so I call -xtmixed- with
the option -iterate(1000)-, which forces it to stop after 1000 iterations.
What I would like to do is keep track of how often -xtmixed- is not
converging before 1000 iterations. However, there seems to be no way that I
can find to capture the number of iterations, other than parse the output of
-xtmixed- itself. Is there anywhere that the number of iterations is stored
for use post-estimation?
The number of iterations is not saved after -xtmixed- (or other -ml-
commands).  However, Jeph can use -e(converged)-, saved after -xtmixed- and
other -ml- commands, to count how many times the model failed to converge
during simulations.  To do this, return the values of -e(converged)- as a
returned result from the wrapper command.  See an example below.

/******************************************************/
cap program drop mywrapper
program mywrapper, rclass
	version 10
	clear
	set obs 10
	gen double id = _n
	gen double y = 2*invnormal(uniform())
	expand 5
	replace y = 5 + y + invnormal(uniform())
	xtmixed y || id: , iter(3)
	return scalar Nconverged = e(converged)
end

simulate (r:conv = r(Nconverged)) _b, reps(3): mywrapper
qui summ  r_conv
di as txt "# converged: " as res r(N)
/******************************************************/

--Yulia
[email protected]
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index