# # Analysis of longitudinal dropout data with OSWALD (in Splus). # # # The window version 3.2 or 3.4 can be downloaded at # http://www.maths.lancs.ac.uk/Software/Oswald/. Unzip the file to the "library" folder # of Splus 2000, for example, C:\Program Files\sp2000\library\oswald. ############################################################# ############################ # Invoke the library “Oswald” in Splus: >library(Oswald, lib.loc="C:\\Program Files\\sp2000\\library\\oswald") The milk data - comprise 19 weekly measurements of the protein content of milk samples from each of 79 cows. - three treatment (diet) groups: barley (cows 1-25), mix of barley and lupins (cows 26-52) and lupin (cows 53-79). - missing data: drop out at weeks 15, 16, 17 and 19. No dropout at week 18. >milk<-read.balanced("C:\\Program Files\\sp2000\\library\\oswald\\DATA\\milk.dat",19,nacode =9.99) >summary(milk) Balanced LDA matrix: Number of time series: 79 Number of observations per series: 19 Total number of observations: 1501 (164 missing) >groups(milk)<-rep(c("Barley","Mixed","Lupins"),c(25,27,27)) >milk[1:4] GROUP [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] TIME 1 2 3 4 5 6 7 8 9 10 11 TS1 Barley 3.63 3.82 3.83 TS2 Barley 3.24 3.32 3.31 TS3 Barley 3.98 3.22 2.93 TS4 Barley 3.66 3.18 3.14 [,12] [,13] TIME 12 13 TS1 3.71 4.10 TS2 3.27 3.41 TS3 2.92 2.82 TS4 3.18 3.24 3.57 3.47 3.65 3.89 3.73 3.77 3.90 3.78 3.25 3.29 3.09 3.38 3.33 3.00 3.16 3.34 3.60 3.43 3.30 3.29 3.25 2.93 3.20 3.27 3.50 3.05 2.90 2.72 3.11 3.05 2.80 3.20 [,14] [,15] [,16] [,17] [,18] [,19] 14 15 16 17 18 19 4.02 4.13 4.08 4.22 4.44 4.30 3.45 3.12 3.42 3.40 3.17 3.00 2.64 NA NA NA NA NA 3.37 3.30 3.40 3.35 3.28 NA > milk[c(1, 26, 53)] GROUP [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,10] [,11] TIME 1 2 3 4 5 6 7 10 11 TS1 Barley 3.63 3.57 3.47 3.65 3.89 3.73 3.77 3.82 3.83 TS26 Mixed 3.38 3.38 3.10 3.09 3.15 2.77 3.40 3.57 3.80 TS53 Lupins 3.69 3.38 3.00 3.50 3.09 3.30 3.07 3.60 3.42 [,12] [,13] [,14] [,15] [,16] [,17] [,18] TIME 12 13 14 15 16 17 18 TS1 3.71 4.10 4.02 4.13 4.08 4.22 4.44 TS26 3.70 3.44 3.51 3.78 3.52 3.26 3.52 TS53 3.59 3.77 3.74 3.70 3.78 3.78 3.77 [,8] [,9] 8 9 3.90 3.78 3.25 3.35 3.22 2.97 [,19] 19 4.30 3.25 3.53 # Plot a sample of 20% of the trajectories from each treatment group >plot(milk,p=0.2) >ldamat.legend(milk,10,4.5) 4.5 3.5 2.5 3.0 milk 4.0 Barley Lupins Mixed 5 10 15 Time # Plot the group means over time. >milk.means <- olsfit(milk) > milk.means[c(1, 26, 53)] GROUP [,1] [,2] [,3] [,4] [,5] [,6] TIME 1 2 3 4 5 6 TS1 Barley 3.886800 3.642500 3.498000 3.376400 3.484400 3.386400 TS26 Mixed 3.861111 3.540000 3.345556 3.277778 3.337778 3.392593 TS53 Lupins 3.758148 3.427778 3.372963 3.294074 3.238077 3.280370 [,7] [,8] [,9] [,10] [,11] [,12] [,13] TIME 7 8 9 10 11 12 13 TS1 3.468800 3.503200 3.511739 3.518800 3.455000 3.429200 3.512400 3.8 TS26 3.333333 3.397692 3.435185 3.437037 3.354815 3.374074 3.410769 TS53 3.187200 3.310000 3.347037 3.268846 3.232593 3.213704 3.333704 [,14] [,15] [,16] [,17] [,18] [,19] TIME 14 15 16 17 18 19 TS1 3.506800 3.541579 3.601765 3.682000 3.640667 3.640000 TS26 3.372222 3.446000 3.570588 3.511250 3.450625 3.395714 TS53 3.254074 3.263500 3.265000 3.252000 3.302000 3.205714 > plot(milk.means[c(1, 26, 53)], ylab="Average Milk Protein") > ldamat.legend(milk.means, 10, 3.8) 3.6 3.4 3.2 Average Milk Protein Barley Lupins Mixed 5 10 15 Time A flexible model for fitting longitudinal data Yij ij U i Wi (tij ) ij , Where ij X ij models the mean structure; N (0, 2 ) is the random effect (random intercept), Ui Wi (t ) N (0, 2 ) is the realization from a stationary Gaussian process and it models the serial correlation: corr (Wi (t ),Wi ( s )) (t s ) exp( | t s |2 ). ij N (0, 2 ) is the measurement error. The set of model parameters is =( , 2 , 2 , 2 , ). Model the dropout process log it{ pr ( yk missing|y1 , y2 ,..., yk ; yk 1 is observed)} q = 0 1 yk j yk 1 j , j 2 Data are - completely random dropout (CRD) if j 0, j 1, 2,...., q. - random dropout (RD) if 1 0. - informative dropout (ID) if 1 Note that the intercept 0. 0 is often modelled as depending on the occasion k , i.e., 0k . Fitting the model Given the form of the data, a sensible model for the mean may be to fit a straight line for the first three week’s data (for the settling-in period), and a polynomial of degree at most 2 for the remainder of the experiment, i.e., fit for each group g 1, 2,3 : t 3 0 g 1t , g (t ) 2 3 ( t 3) ( t 3) , t>3. 1 2 3 0g # Creating the three variable for such a polynomial trajectory: > x1 <- c(1, 2, rep(3, 17)) > x1 [1] 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 > x2 <- c(0, 0, 0, 1:16) > x2 [1] 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 > x3 <- x2^2 (1) Assume Completely Random Dropout > milk.crd <- pcmid(milk ~ group + tex(x1) + tex(x2) + tex(x3), vparms = c(0.1, 0.03, 0.4), correxp = 1) > milk.crd Longitudinal Data Analysis Model assuming completely random dropout Call: pcmid(formula = milk ~ group + tex(x1) + tex(x2) + tex(x3), vparms = c( 0.1, 0.03, 0.4), correxp = 1) Analysis Method: Maximum Likelihood (ML) Correlation structure: exp(- phi * |u| ^ 1 ) Maximised log-likelihood: [1] -2866.67 Mean Parameters: (Intercept) group1 group2 tex(x1) tex(x2) PARAMETER 4.04367915 -0.10606293 0.001496421 -0.22861430 0.007950934 STD.ERROR 0.04418288 0.02592537 0.014771240 0.01564402 0.008077304 tex(x3) PARAMETER -0.0005958148 STD.ERROR 0.0005070062 Variance Parameters: nu.sq sigma.sq tau.sq phi 1.527421e-008 0.07214213 0.02376663 0.1518235 Maximisation converged after 185 iterations. (2) Assume Random Dropout > > > > dt <- rep(1:19, 79) dt[dt < 15 | dt == 18] <- 0 dt <- as.factor(dt) dt[1:100] [1] 0 0 0 0 0 0 0 0 19 0 0 0 [23] 0 0 0 0 0 0 0 0 0 0 0 0 [45] 0 0 0 0 0 0 0 0 0 0 0 0 [67] 0 0 0 0 0 15 16 17 0 0 0 0 0 0 0 0 0 0 15 16 17 0 0 0 0 15 16 17 0 19 0 0 15 16 17 0 19 0 0 0 0 0 0 0 0 0 0 0 19 0 0 0 [89] 0 0 15 16 17 0 19 0 0 0 0 0 > milk.rd <- pcmid(milk ~ group + tex(x1) + tex(x2) + tex(x3), vparms = c(0, 0.025, 0.15), correxp = 1, drop.parms = c(0, -6), drop.cov.parms = c(0, 19, 18, 17, 18), dropmodel = ~ -1 + dt) > milk.rd Longitudinal Data Analysis Model assuming random dropout based on 1 previous observations Call: pcmid(formula = milk ~ group + tex(x1) + tex(x2) + tex(x3), vparms = c( 0, 0.025, 0.15), drop.parms = c(0, -6), drop.cov.parms = c(0, 19, 18, 17, 18), dropmodel = ~ -1 + dt, correxp = 1) Analysis Method: Maximum Likelihood (ML) Correlation structure: exp(- phi * |u| ^ 1 ) Maximised log-likelihood: [1] -2933.502 Mean Parameters: (Intercept) group1 group2 tex(x1) tex(x2) PARAMETER 4.04376266 -0.1056935 0.00149445 -0.22844484 0.007678527 STD.ERROR 0.05821873 0.0401953 0.02290393 0.01823982 0.011424190 tex(x3) PARAMETER -0.0005799806 STD.ERROR 0.0007106747 Variance Parameters: nu.sq sigma.sq tau.sq phi 0 0.07208938 0.02377462 0.1519165 Dropout parameters: dt0 dt15 dt16 dt17 dt19 y.d y.d-1 0 19.22091 18.51024 17.77181 18.49529 0 -6.254871 Maximisation converged after 1058 iterations. (3) Assume Informative Dropout > milk.id <- pcmid(milk ~ group + tex(x1) + tex(x2) + tex(x3), Vparms=c(0, 0.025,0.15), correxp = 1, drop.parms = c(6, 12), drop.cov.parms = c(0, 19, 18, 17, 18), dropmodel = ~ -1 + dt) > milk.id Longitudinal Data Analysis Model assuming informative dropout based on 1 previous observations Call: pcmid(formula = milk ~ group + tex(x1) + tex(x2) + tex(x3), vparms = c( 0, 0.025, 0.15), drop.parms = c(6, -12), drop.cov.parms = c(0, 19, 18, 17, 18), dropmodel = ~ -1 + dt, correxp = 1) Analysis Method: Maximum Likelihood (ML) Correlation structure: exp(- phi * |u| ^ 1 ) Maximised log-likelihood: [1] -2928.264 Mean Parameters: (Intercept) group1 group2 tex(x1) tex(x2) PARAMETER 4.041186 -0.1069147 0.002143501 -0.2286773 0.007786218 STD.ERROR NA NA NA NA NA tex(x3) PARAMETER -0.0004352736 STD.ERROR NA Variance Parameters: nu.sq sigma.sq tau.sq phi 0 0.06914706 0.0246771 0.1536183 Dropout parameters: dt0 dt15 dt16 dt17 dt19 y.d y.d-1 0 18.62526 17.53009 16.77428 18.0475 4.680672 -10.90307 Maximisation converged after 1797 iterations.