Hi,

I am wanting to do a segmented regression (as an interrupted time series) using binary outcome data. Reform is the intervention, time1 is the slope until the intervention and time2 is the change in slope after the intervention. That's all fine and I can run the analysis with individual level data but I then thought I should be able to test for autocorrelation which requires tsset'ing the data. So I aggregated the data at the monthly level but then running a logistic regression with frequency weights still requires two lines of data for each time point (number without the outcome on one line and number with the outcome on another line).

Is there a sensible way to do this?

A model I would look at is (incorporating Newey-West S.E.'s if necessary):

Code:
glm y time1 time2 i.reform [fw = sex], family(binomial) link(logit) vce(hac nwest 1) eform
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id byte y float Stata_Month long sex byte(time1 time2) float reform
 1 0 636 19  0  0 0
 1 1 636 18  0  0 0
 2 0 637 25  1  0 0
 2 1 637 20  1  0 0
 3 0 638 18  2  0 0
 3 1 638 25  2  0 0
 4 0 639 20  3  0 0
 4 1 639 14  3  0 0
 5 0 640 17  4  0 0
 5 1 640 18  4  0 0
 6 0 641 19  5  0 0
 6 1 641 29  5  0 0
 7 0 642 17  6  0 0
 7 1 642 19  6  0 0
 8 0 643 29  7  0 0
 8 1 643 19  7  0 0
 9 0 644 22  8  0 0
 9 1 644 25  8  0 0
10 0 645 29  9  0 0
10 1 645 22  9  0 0
11 0 646 22 10  0 0
11 1 646 24 10  0 0
12 0 647 17 11  0 0
12 1 647 27 11  0 0
13 0 648 26 12  0 0
13 1 648 25 12  0 0
14 0 649 26 13  0 0
14 1 649 15 13  0 0
15 0 650 19 14  0 0
15 1 650 38 14  0 0
16 0 651 27 15  0 1
16 1 651 28 15  0 1
17 0 652 20 16  1 1
17 1 652 30 16  1 1
18 0 653 14 17  2 1
18 1 653 20 17  2 1
19 0 654 17 18  3 1
19 1 654 24 18  3 1
20 0 655 12 19  4 1
20 1 655 20 19  4 1
21 0 656 11 20  5 1
21 1 656 17 20  5 1
22 0 660 15 24  9 1
22 1 660 34 24  9 1
23 0 661 16 25 10 1
23 1 661 19 25 10 1
24 0 662 17 26 11 1
24 1 662 20 26 11 1
25 0 663 20 27 12 1
25 1 663 30 27 12 1
26 0 664 20 28 13 1
26 1 664 26 28 13 1
27 0 665 18 29 14 1
27 1 665 16 29 14 1
28 0 666 11 30 15 1
28 1 666 28 30 15 1
29 0 667 21 31 16 1
29 1 667 19 31 16 1
30 0 668 17 32 17 1
30 1 668 23 32 17 1
31 0 669 18 33 18 1
31 1 669 27 33 18 1
32 0 670 22 34 19 1
32 1 670 17 34 19 1
33 0 671 19 35 20 1
33 1 671 28 35 20 1
34 0 672 13 36 21 1
34 1 672 35 36 21 1
35 0 673 16 37 22 1
35 1 673 28 37 22 1
36 0 674 17 38 23 1
36 1 674 19 38 23 1
37 0 675 23 39 24 1
37 1 675 19 39 24 1
38 0 676  4 40 25 1
38 1 676 32 40 25 1
39 0 677 18 41 26 1
39 1 677 20 41 26 1
40 0 678 16 42 27 1
40 1 678 28 42 27 1
41 0 679 13 43 28 1
41 1 679 22 43 28 1
42 0 680 20 44 29 1
42 1 680 24 44 29 1
43 0 681 15 45 30 1
43 1 681 23 45 30 1
44 0 682 25 46 31 1
44 1 682 16 46 31 1
45 0 683 20 47 32 1
45 1 683 21 47 32 1
46 0 684 21 48 33 1
46 1 684 24 48 33 1
47 0 685 16 49 34 1
47 1 685 21 49 34 1
48 0 686 13 50 35 1
48 1 686 33 50 35 1
49 0 687 15 51 36 1
49 1 687 23 51 36 1
50 0 688 15 52 37 1
50 1 688 18 52 37 1
end
format %tm Stata_Month