Statalist


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

st: RE: RE: QIC Program question to assess fit in xtgee


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: QIC Program question to assess fit in xtgee
Date   Fri, 29 Feb 2008 15:19:46 -0000

If this program were tweaked so that mu were instead a temporary
variable, then all the subsequent -drop mu- could (and should) be
omitted. 

Other improvements look possible -- for example, why wire in the
particular -xtgee- call -- 
but that's one for now. 

capture program drop qicm
program define qicm
	args corr
	quietly {

		capture quietly xtgee yvar x1 x2 x3 x4 x5 x6 xm
[pweight=wt], robust corr(`corr')
		if (_rc !=0) {
			exit
		}

		matrix V = e(V)
		matrix T = Ai*V
		matrix t = trace(T)
		scalar off = t[1,1]

		tempvar ql mu 
		quietly predict double `mu', mu
		quietly generate double `ql' = (yvar*log(`mu'/(1-`mu'))
+ log(1-`mu'))
		quietly summarize `ql', meanonly

	}
	display in green "QIC = " in yellow 2*(off-r(sum))
end

Mustillo, Sarah A

I just tried the QIC program and got the same error.  I always use the
code provided by Hardin and Hilbe in their GEE book.  Put in your own Y
variable and X variables and run it like a do file:

*From Hardin&Hilbe 2002 - Using QIC to determine the best correlation
structure for the data.

xtgee yvar x1 x2 x3 x4 x5 x6 xm [pweight=wt], robust corr(ind)
matrix A= e(V)
matrix Ai= syminv(A)

capture program drop qicm
program define qicm
	args corr
	quietly {

		capture quietly xtgee yvar x1 x2 x3 x4 x5 x6 xm
[pweight=wt], robust corr(`corr')
		if (_rc !=0) {
			exit
		}

		matrix V = e(V)
		matrix T = Ai*V
		matrix t = trace(T)
		scalar off = t[1,1]

		tempvar ql
		quietly predict double mu, mu
		quietly generate double `ql' = (yvar*log(mu/(1-mu)) +
log(1-mu))
		quietly summarize `ql', meanonly

	}
	display in green "QIC = " in yellow 2*(off-r(sum))
end

qicm ind
drop mu
qicm exch
drop mu
qicm "ar 1"
drop mu
qicm "ar 2"
drop mu
qicm unst
drop mu
qicm "sta 2"


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