11.07.2015 Views

Preface to First Edition - lib

Preface to First Edition - lib

Preface to First Edition - lib

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ANALYSIS USING R 219which is no longer constant for different values of t j . Similarly the covariancebetween two <strong>to</strong>tal residuals of the same individualCov(u i + v i t j + ε ij , u i + v i t k + ε ik ) = σ 2 u + σ uv (t j − t k ) + σ 2 vt j t kis not constrained <strong>to</strong> be the same for all pairs t j and t k .(It should also be noted that re-estimating the model after adding or subtractinga constant from t j , e.g., its mean, will lead <strong>to</strong> different variance andcovariance estimates, but will not affect fixed effects.)Linear mixed-effects models can be estimated by maximum likelihood. However,this method tends <strong>to</strong> underestimate the variance components. A modifiedversion of maximum likelihood, known as restricted maximum likelihoodis therefore often recommended; this provides consistent estimates of the variancecomponents. Details are given in Diggle et al. (2003) and Longford (1993).Competing linear mixed-effects models can be compared using a likelihood ratiotest. If however the models have been estimated by restricted maximumlikelihood this test can be used only if both models have the same set of fixedeffects, see Longford (1993). (It should be noted that there are some technicalproblems with the likelihood ratio test which are discussed in detail inRabe-Hesketh and Skrondal, 2008).12.4 Analysis Using RAlmost all statistical analyses should begin with some graphical representationof the data and here we shall construct the boxplots of each of the five repeatedmeasures separately for each treatment group. The data are available as thedata frame BtheB and the necessary R code is given along with Figure 12.1.The boxplots show that there is decline in BDI values in both groups withperhaps the values in the group of patients treated in the Beat the Blues armbeing lower at each post-randomisation visit.We shall fit both random intercept and random intercept and slope models<strong>to</strong> the data including the baseline BDI values (pre.bdi), treatment group,drug and length as fixed effect covariates. Linear mixed effects models arefitted in R by using the lmer function contained in the lme4 package (Batesand Sarkar, 2008, Pinheiro and Bates, 2000, Bates, 2005), but an essentialfirst step is <strong>to</strong> rearrange the data from the ‘wide form’ in which they appearin the BtheB data frame in<strong>to</strong> the ‘long form’ in which each separate repeatedmeasurement and associated covariate values appear as a separate row in adata.frame. This rearrangement can be made using the following code:R> data("BtheB", package = "HSAUR2")R> BtheB$subject nobs BtheB_long BtheB_long$time

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!