Statalist The Stata Listserver


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

st: Re: xtgee - identifying omitted groups


From   Paul Seed <[email protected]>
To   [email protected]
Subject   st: Re: xtgee - identifying omitted groups
Date   Thu, 21 Dec 2006 12:39:34 +0000

Thanks very much Scott.
That goes a long way to solving my problem.
As it happens, the data has a complex pattern
of missing values:

-> . xtdes , patterns(20)

patid: 1, 2, ..., 2476 n = 192
visit: 1, 2, ..., 4 T = 4
Delta(visit) = 1; (4-1)+1 = 4
(patid*visit does not uniquely identify observations)

Distribution of T_i: min 5% 25% 50% 75% 95% max
2 2 2 3 3 4 4

Freq. Percent Cum. | Pattern
---------------------------+---------
56 29.17 29.17 | 1.11
29 15.10 44.27 | 1.1.
21 10.94 55.21 | 111.
21 10.94 66.15 | 1111
18 9.38 75.52 | 1..1
17 8.85 84.38 | 11..
8 4.17 88.54 | 11.1
7 3.65 92.19 | ..11
4 2.08 94.27 | .1.1
4 2.08 96.35 | .111
2 1.04 97.40 | .11.
2 1.04 98.44 | 1.12
1 0.52 98.96 | ..12
1 0.52 99.48 | 1.21
1 0.52 100.00 | 112.
---------------------------+---------
192 100.00 | XXXX

Going back to my original data set, I can use:

use blood_meas5, clear

gen on_rx = visit > 1 & vitamin == 1

drop if uric_acid == 0 | uric_acid == .

qui xi: xtgee uric_acid i.visit on_rx , robust corr(ar1)

gen sample = e(sample)
keep if sample

keepmode2 patid visit dropped_groups
drop if dropped_groups == 1

xi: xtgee uric_acid i.visit on_rx , robust corr(ar1)

xi: xtreg uric_acid i.visit on_rx , re sa
pause





Date: Wed, 20 Dec 2006 08:25:59 -0600

From: [email protected]

Subject: Re: st: xtgee - identifying omitted groups



There might be a more direct way, but it looks like -xtgee- calls the

subroutine -KeepMode- to identify the groups with unequal spacing.

One can copy this subroutine (with a few modifications) as a separate

program to identify the groups:



program keepmode2

version 9.2

args ivar tvar omitted

tempvar bb

qui {

by `ivar': gen float `bb' = `tvar'-`tvar'[_n-1]

by `ivar': replace `bb' = `bb'[2] if _n==1

qui summ `bb'

cap assert `bb' == r(min) | `bb'>=.

if _rc==0 {

exit

}

tempname mesh

tempvar freq bad

sort `bb'

by `bb': gen `freq'=_N if _n==_N

summ `freq'

summ `bb' if `freq'==r(max)

scalar `mesh' = r(min)

sort `ivar' `tvar'

drop `freq'

by `ivar': gen `bad' = cond(_n==1,0,`bb'!=`mesh')

by `ivar': replace `bad' = cond(_n==_N,sum(`bad')!=0,0)

summ `bad', mean

}

di in gr _n /*

*/ "note: observations not equally spaced" _n /*

*/ _col(8) "modal spacing is delta `tvar' = " `mesh' _n /*

*/ _col(8) r(sum) " groups omitted from estimation"

qui by `ivar': gen `omitted' = `bad'[_N]

if _N==0 {

di in red "no observations"

exit 2000

}

end



. webuse grunfeld,clear



. set seed 111



. drop if uniform()<.05

(8 observations deleted)



. qui xi: xtgee invest i.year, robust corr(ar1)



. keepmode2 com time dropped_groups



note: observations not equally spaced

modal spacing is delta time = 1

5 groups omitted from estimation



. tab com dropped



| dropped_groups

company | 0 1 | Total

- -----------+----------------------+----------

1 | 0 18 | 18

2 | 0 19 | 19

3 | 0 18 | 18

4 | 20 0 | 20

5 | 20 0 | 20

6 | 19 0 | 19

7 | 0 19 | 19

8 | 20 0 | 20

9 | 0 19 | 19

10 | 20 0 | 20

- -----------+----------------------+----------

Total | 99 93 | 192



Scott



- ----- Original Message -----

From: Paul Seed <[email protected]>

Date: Wednesday, December 20, 2006 6:56 am

Subject: st: xtgee - identifying omitted groups

To: [email protected]



> This may be an old question, but I can't see anything in the FAQ

> or

> statalist archives.

>

> If I fit a model such as

> xi: xtgee uric_acid i.visit on_rx if n_uric_acid > 1 &

> uric_acid

> ~= 0, robust corr(ar1)

> I get in the output:

>

> note: observations not equally spaced

> modal spacing is delta visit = 1

> 120 groups omitted from estimation



<snip>



> How do I identify the 120 omitted groups., so that I can compare

> the

> performance of the
> two models on the same data?
*
* 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