Statalist


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

st: -simulate- stops after one iteration


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   st: -simulate- stops after one iteration
Date   Thu, 20 Dec 2007 13:53:56 -0500

I am using -simulate- to run a program I wrote in
order to estimate statistical power. I have several
outcomes, and for most of those outcome variables
there is no problem.

However, for three of the variables, I find that after
one iteration, -simulate- hangs. (I let it hang for two
days on three occasions, so I think it's not just
my impatience.)

The program is fairly simple, it runs -xtmixed- and for
a while I thought it was -xtmixed- that was hanging; however,
a few well placed -display- commands disabused me of that
notion. In the below I get two dots (".") displayed before
it hangs:

=======================================================
program define xtpow, rclass
	version 10
	syntax, out(string) eff(real) [, indvars(string) ]
	u power, clear
	bys id_practice id_doctor: egen mean=mean(`out')
	expand 2
	bys obs: gen cohort=_n-1
	replace mean=mean+`eff'
	replace mean=min(mean,1)
	replace mean=max(mean,0)
	rndbinx mean denom
	replace `out'=bnlx if cohort==1&!missing(`out')	
	di in r ". " _con
	xtmixed `out' cohort `indvars' || id_practice: || id_doctor:
	matrix b=e(b)
	matrix V=e(V)
	scalar zrat=b[1,1]/sqrt(V[1,1])
	scalar pval=2*(1-normprob(abs(zrat)))
	di in r ". " _con
	return scalar p=pval
end
=======================================================

My command:
. local O "chol_ldl_good"
. local E=0.005
. simulate pval=r(p) , reps(1000) : xtpow, out("`O'")  eff(`E')

produces

chol_ldl_good
. .


Like I said, this works when the local macro O is 12 out of
15 variables, but not for the other three. There is nothing
strange about those three - and the simulation always completes
ONE iteration with no trouble, it just never starts the second.

Thoughts?

Jeph




*
*   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