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

Size: px
Start display at page:

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

Transcription

1 (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 Freq Percent Cum Pattern XXXXXXXXXXXX *** individual profiles plot ****************************************** xtline quit if id<352

2 quit Graphs by id week sort trtgrp id week list in / obs id trtgrp quit week *** group profiles plot ************************************************ by trtgrp: tabulate quit week, col > trtgrp = Key frequency column percentage

3 week quit Total , Total , week quit Total , Total , > trtgrp = Key frequency column percentage week quit Total Total , week quit Total Total , xtgraph quit, group (trtgrp) level(0) 3

4 quit 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 Total tabulate quitl quit if (trtgrp==0 & week>=5), row 4

5 Key frequency row percentage quit quitl 0 Total Total *** basic model (): model transition patterns ************************ logit quit quitl if (trtgrp== & week>=5), cluster(id) r Logistic regression Number of obs = 83 Wald chi2() = Prob > chi2 = Log pseudolikelihood = Pseudo R2 = 0543 (Std Err adjusted for 4 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl _cons logit quit quitl if (trtgrp==0 & week>=5), cluster(id) r Logistic regression Number of obs = 808 Wald chi2() = 6947 Prob > chi2 = Log pseudolikelihood = Pseudo R2 = 0452 (Std Err adjusted for 06 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl _cons *** 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) = Prob > chi2 = Log pseudolikelihood = Pseudo R2 = (Std Err adjusted for 4 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_ _Iweek_ _Iweek_

6 _Iweek_ _Iweek_ _Iweek_ _Iweek_ quitl _cons 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 = Log pseudolikelihood = Pseudo R2 = (Std Err adjusted for 06 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ quitl _cons *** 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 = Log pseudolikelihood = Pseudo R2 = (Std Err adjusted for 4 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ quitl _IweeXquit_ _IweeXquit_ _IweeXquit_ _IweeXquit_ _IweeXqui~ _IweeXqui~ _cons 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 = Log pseudolikelihood = Pseudo R2 =

7 (Std Err adjusted for 06 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ _Iweek_ quitl _IweeXquit_ _IweeXquit_ _IweeXquit_ _IweeXquit_ _IweeXqui~ _IweeXqui~ _IweeXqui~ _cons *** 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) = Prob > chi2 = Log pseudolikelihood = Pseudo R2 = (Std Err adjusted for 2 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl quitl _cons logit quit quitl quitl2 if (trtgrp==0 & week>=6), cluster(id) r Logistic regression Number of obs = 702 Wald chi2(2) = 2048 Prob > chi2 = Log pseudolikelihood = Pseudo R2 = (Std Err adjusted for 05 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] quitl quitl _cons *** 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

8 logit quit OneMinusQuitL TrtOneMinusQuitL quitl TrtQuitL if (week>=5), nocon cluster(id) r Logistic regression Number of obs = 62 Wald chi2(4) = Log pseudolikelihood = Prob > chi2 = (Std Err adjusted for 220 clusters in id) quit Coef Std Err z P> z [95% Conf Interval] OneMinusQu~ TrtOneMinu~ quitl TrtQuitL log close log: G:\public_html\courses\LDA2008\Data\CTQ2log log type: text closed on: 24 Apr 2008, 2:4: