(LDA lecture 4/15/08: Transition model for binary data. -- TL)

Similar documents
Transcription:

(LDA lecture 4/5/08: Transition model for binary data -- TL) (updated 4/24/2008) log: G:\public_html\courses\LDA2008\Data\CTQ2log log type: text opened on: 5 Apr 2008, 2:27:54 *** read in data ****************************************************** infile obs id trtgrp quit week using ctq2dat (3372 observations read) replace trtgrp = trtgrp- (3372 real changes made) *** declare LD ******************************************************** xtset id week panel variable: id (strongly balanced) time variable: week, to 2 delta: unit xtdes id: 305, 309,, 358 n = 28 week:, 2,, 2 T = 2 Delta(week) = unit Span(week) = 2 periods (id*week uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 2 2 2 2 2 2 2 Freq Percent Cum Pattern ---------------------------+-------------- 28 0000 0000 ---------------------------+-------------- 28 0000 XXXXXXXXXXXX *** individual profiles plot ****************************************** xtline quit if id<352

0 5 0 5 quit 0 5 0 5 305 309 3 33 34 37 32 324 325 326 328 33 336 338 339 342 343 347 350 35 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 Graphs by id week sort trtgrp id week list in /5 +----------------------------------+ obs id trtgrp quit week ---------------------------------- 305 0 0 2 2 305 0 0 2 3 3 305 0 0 3 4 4 305 0 0 4 5 5 305 0 5 ---------------------------------- 6 6 305 0 6 7 7 305 0 7 8 8 305 0 8 9 9 305 0 9 0 0 305 0 0 ---------------------------------- 305 0 2 2 305 0 2 3 25 3 0 0 4 26 3 0 0 2 5 27 3 0 0 3 +----------------------------------+ *** group profiles plot ************************************************ by trtgrp: tabulate quit week, col --------------------------------- - -> trtgrp = 0 +-------------------+ Key ------------------- frequency column percentage +-------------------+ 2

week quit 2 3 4 5 6 7 8 Total -----------+----------+---------- 0 36 30 6 02 74 74 72 68,042 0000 0000 983 989 698 7048 6923 6800 7997 -----------+----------+---------- 0 0 2 9 32 3 32 32 26 000 000 69 8 309 2952 3077 3200 2003 -----------+----------+---------- Total 36 30 8 06 05 04 00,303 0000 0000 0000 0000 0000 0000 0000 0000 0000 week quit 9 0 2 Total 0 67 69 68 66,042 6768 6970 6869 6875 7997 32 30 3 30 26 3232 3030 33 325 2003 Total 99 99 99 96,303 0000 0000 0000 0000 0000 --------------------------------- - -> trtgrp = +-------------------+ Key ------------------- frequency column percentage +-------------------+ week quit 2 3 4 5 6 7 8 Total -----------+----------+---------- 0 28 25 22 2 74 70 65 53 960 9846 9766 9606 906 649 6250 5963 5354 7267 -----------+----------+---------- 2 3 5 40 42 44 46 36 54 234 394 894 3509 3750 4037 4646 2733 -----------+----------+---------- Total 30 28 27 23 4 2 09 99,32 0000 0000 0000 0000 0000 0000 0000 0000 0000 week quit 9 0 2 Total 0 56 53 49 53 960 5773 5579 523 5699 7267 4 42 45 40 36 4227 442 4787 430 2733 Total 97 95 94 93,32 0000 0000 0000 0000 0000 xtgraph quit, group (trtgrp) level(0) 3

quit 0 478723 0 2 week *** create Y_i,j- and Y_i,j-2 using lag (L, L2) operation ************ sort id week gen quitl=lquit (937 missing values generated) gen quitl2=l2quit (30 missing values generated) *** tabulate the transitions from Y_i,j- to Y_i,j ********************* tabulate quitl quit if (trtgrp== & week>=5), row +----------------+ Key ---------------- frequency row percentage +----------------+ quit quitl 0 Total 0 450 54 504 8929 07 0000 23 286 309 744 9256 0000 Total 473 340 83 588 482 0000 tabulate quitl quit if (trtgrp==0 & week>=5), row 4

+----------------+ Key ---------------- frequency row percentage +----------------+ quit quitl 0 Total 0 526 55 58 9053 947 0000 32 95 227 40 8590 0000 Total 558 250 808 6906 3094 0000 *** basic model (): model transition patterns ************************ logit quit quitl if (trtgrp== & week>=5), cluster(id) r Logistic regression Number of obs = 83 Wald chi2() = 24496 Prob > chi2 = 00000 Log pseudolikelihood = -25348432 Pseudo R2 = 0543 (Std Err adjusted for 4 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl 464076 296538 565 0000 4059605 52298 _cons -220264 668042-27 0000-244794 -793333 logit quit quitl if (trtgrp==0 & week>=5), cluster(id) r Logistic regression Number of obs = 808 Wald chi2() = 6947 Prob > chi2 = 00000 Log pseudolikelihood = -27429362 Pseudo R2 = 0452 (Std Err adjusted for 06 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl 4065232 322764 302 0000 34538 4677282 _cons -2257968 777068-27 0000-2606267 -909669 *** i) allow underlying prob to vary with time ************************* xi: logit quit iweek quitl if (trtgrp== & week>=5), cluster(id) r iweek _Iweek_-2 (naturally coded; _Iweek_ omitted) Logistic regression Number of obs = 83 Wald chi2(8) = 24395 Prob > chi2 = 00000 Log pseudolikelihood = -2305906 Pseudo R2 = 05827 (Std Err adjusted for 4 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_5 276865 5788847 469 0000 582272 385458 _Iweek_6 978567 6577998 40 063-374073 22072 _Iweek_7 287 530887 2 0035 084843 262255 5

_Iweek_8 28645 692909 208 0038 072627 2500203 _Iweek_9 0092234 5944774 002 0988-5593 74378 _Iweek_0 9476749 5970878 59 02-2225958 27946 _Iweek_ 33808 6034 223 0026 595268 256635 quitl 5478573 3892052 408 0000 475745 62440 _cons -364805 520924-700 0000-4669075 -262736 xi: logit quit iweek quitl if (trtgrp==0 & week>=5), cluster(id) r iweek _Iweek_-2 (naturally coded; _Iweek_ omitted) Logistic regression Number of obs = 808 Wald chi2(8) = 9902 Prob > chi2 = 00000 Log pseudolikelihood = -2668842 Pseudo R2 = 04765 (Std Err adjusted for 06 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_5 6529 406288 398 0000 8956 24464 _Iweek_6-0383336 50452-008 0939-02775 9505075 _Iweek_7 279864 4075554 069 0492-5893 078658 _Iweek_8 296999 4369788 050 065-6367627 07663 _Iweek_9 29929 486379 027 0789-8228837 082742 _Iweek_0-2847 3954763-03 0759-896304 6539346 _Iweek_ 203552 503706 040 0686-783685 90789 quitl 4450985 348808 276 0000 3767346 534624 _cons -276572 3346489-826 0000-34262 -20982 *** ii) allow underlying prob and transition prob to vary with time **** xi: logit quit iweek iweek*quitl if (trtgrp== & week>=5), cluster(id) r iweek _Iweek_-2 (naturally coded; _Iweek_ omitted) iweek*quitl _IweeXquit_# (coded as above) Logistic regression Number of obs = 77 Wald chi2(4) = 2002 Prob > chi2 = 00000 Log pseudolikelihood = -22508352 Pseudo R2 = 05624 (Std Err adjusted for 4 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_5 903946 68877 308 0002 690856 36806 _Iweek_6 395327 7353333 054 059-04594 836539 _Iweek_7 020693 7988394 003 0979-545077 58636 _Iweek_8 2282587 79403 029 0774-3285 784669 _Iweek_9-405465 945409-043 0668-225849 447489 _Iweek_0-0400053 8369924-005 0962-68048 60047 _Iweek_2-3422862 9398005-036 076-28426 499689 quitl 39847 075724 297 0003 083466 5300228 _IweeXquit_6 403273 255829 2 0264-05807 3864652 _IweeXquit_7 326962 537798 23 0033 255593 6283649 _IweeXquit_8 30772 55894 200 0046 0553574 66686 _IweeXquit_9 724477 385524 24 023-99099 4440054 _IweeXqui~0 2678 435234 82 0069-202269 5424788 _IweeXqui~2 635323 36585 20 023-04694 43234 _cons -2793208 5973876-468 0000-3964066 -62235 xi: logit quit iweek iweek*quitl if (trtgrp==0 & week>=5), cluster(id) r iweek _Iweek_-2 (naturally coded; _Iweek_ omitted) iweek*quitl _IweeXquit_# (coded as above) Logistic regression Number of obs = 808 Wald chi2(5) = 2259 Prob > chi2 = 00000 Log pseudolikelihood = -2546075 Pseudo R2 = 04906 6

(Std Err adjusted for 06 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_5 2023939 6487699 32 0002 7523732 3295504 _Iweek_6 655889 734847 084 0402-824685 2055863 _Iweek_7 66322 799665 02 0835-40006 732659 _Iweek_8 2404292 7999945 030 0764-32753 80839 _Iweek_9 27687 7949349 034 0733-286362 829725 _Iweek_0 27687 8000392 034 0734-296366 83973 _Iweek_ 2404292 788800 030 076-30559 786449 quitl 69773 7468657 227 0023 2339006 3656 _IweeXquit_6 98868 92642 25 0032 729648 3803372 _IweeXquit_7 3803528 2705 337 000 594443 60263 _IweeXquit_8 3323955 090686 305 0002 86249 54666 _IweeXquit_9 300502 03589 296 0003 08422 49968 _IweeXqui~0 2525447 027245 246 004 520837 45388 _IweeXqui~ 3287587 770 294 0003 096934 547824 _IweeXqui~2 3240334 86626 273 0006 945897 5566079 _cons -3028522 593966-50 0000-492666 -864379 *** iii) allow 2nd order dependence ************************************ logit quit quitl quitl2 if (trtgrp== & week>=6), cluster(id) r Logistic regression Number of obs = 699 Wald chi2(2) = 25387 Prob > chi2 = 00000 Log pseudolikelihood = -626489 Pseudo R2 = 06594 (Std Err adjusted for 2 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl 4327268 3895552 0000 3563753 5090782 quitl2 48768 4289076 347 000 6469743 232826 _cons -2864039 220358-300 0000-3295933 -243245 logit quit quitl quitl2 if (trtgrp==0 & week>=6), cluster(id) r Logistic regression Number of obs = 702 Wald chi2(2) = 2048 Prob > chi2 = 00000 Log pseudolikelihood = -795565 Pseudo R2 = 05872 (Std Err adjusted for 05 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl 3669273 342898 072 0000 2998593 4339953 quitl2 873073 2934628 638 0000 297897 244825 _cons -2979939 25527-383 0000-3402364 -255754 *** basic model (2): add covariates ************************************ gen OneMinusQuitL = -quitl (937 missing values generated) gen TrtOneMinusQuitL = trtgrp*oneminusquitl (937 missing values generated) gen TrtQuitL = trtgrp*quitl (937 missing values generated) 7

logit quit OneMinusQuitL TrtOneMinusQuitL quitl TrtQuitL if (week>=5), nocon cluster(id) r Logistic regression Number of obs = 62 Wald chi2(4) = 46936 Log pseudolikelihood = -52777794 Prob > chi2 = 00000 (Std Err adjusted for 220 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] OneMinusQu~ -2257968 77270-274 0000-26054 -90525 TrtOneMinu~ 377045 243672 057 057-3388946 643035 quitl 807264 2426476 745 0000 33683 2282844 TrtQuitL 732339 34305 209 0037 0442952 38273 log close log: G:\public_html\courses\LDA2008\Data\CTQ2log log type: text closed on: 24 Apr 2008, 2:4:28 --------------------------------- 8