After a -contract-. add a few pseudo-observations
with zero frequency and then use -fillin-?
Nick
[email protected]
Paul Seed
> I have a data set that consists of the dates of certain
> arbitrary events
> (hospital appointments), together with various predictors; mainly
> date, numeric code for referring doctor (GP) & intervention
> (pre/post ).
> I am interested in whether the intervention is associated
> with a fall in
> the monthly rate of appointments, after adjusting for secular trend
> and clustering by GP.
>
> One approach is to collapse the data & perform a Poisson or negative
> binomial regression. However, the code needed for this is
> surprisingly
> complex (see below), as I need to ensure that the practices with zero
> frequencies in
> one time period are properly included, and the only way I
> could see to do this
> was to tabulate, save the table as a matrix and then convert
> it to a data set.
>
> Two questions:
> 1) Is there a simpler way of collapsing the data without the
> zero problem
> 2) Is there a way of analysing the data using it's present
> structure (or
> something like it)?
>
> Any thought gratefully received.
>
>
>
> . use "westminster2", clear
>
> . li uniqid aptdate apttype pre_ post_ in 1/5
>
> +----------------------------------------------+
> | uniqid aptdate apttype pre_ post_ |
> |----------------------------------------------|
> 1. | 6220 11 Apr 02 first vi 0 1 |
> 2. | 6159 12 Mar 02 first vi 0 1 |
> 3. | 6175 21 Mar 02 first vi 0 1 |
> 4. | 6210 09 Apr 02 first vi 0 1 |
> 5. | 6165 14 Mar 02 first vi 0 1 |
> +----------------------------------------------+
>
> tempname temp
>
>
> tab refcode prepost if hosp == 1, matcell(temp)
> matrow(gp_ref_cd)
>
> svmat temp, names(col)
> svmat gp_ref_cd ,names(gp_ref_cd)
>
> keep c1 c2 gp_ref_cd
> rename gp_ref_cd1 gp_ref_cd
> drop if gp_ref_cd >=.
>
> reshape long c, i(gp_ref_cd) j(prepost)
> rename c n_appt
> gen post = prepost == 2
>
> svyset , psu(gp_ref_cd)
> svynbreg n_appt post , irr
>
*
* 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/