LET- Life Engagement Test (Scheier et al., 2006)

Repeated Measures for Life Engagement, w/ all negative questions: There is not enough purpose in my life. (1), Most of what I do seems trivial and unimportant to me. (3), I don’t care very much about the things I do. (5)

#Loading the dataset that has been reset into a long version
data.test4 <- read.csv("/Volumes/TOSHIBA EXT/Dropbox/ADULT STUDY/adult_study011615.csv")
# Load the psych package
library(psych)

Creating a new variable that is the mean of all positive purpose meanLET questions

items <- c("LET1", "LET3", "LET5")
scaleKey <- c(-1, -1, -1)
data.test4$meanLET  <- scoreItems(scaleKey, items=data.test4[,items], delete=FALSE)$score
library(reshape2); library(car)
## Warning: package 'car' was built under R version 3.1.2
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:psych':
## 
##     logit
data <- data.test4[,c("ID", "GROUP", "wave", "meanLET")]
data <- dcast(data, ID + GROUP ~ wave, mean, value.var = "meanLET")
data[,3:5] <- apply(data[,3:5],2,function(x) recode(x, "NaN = NA") )

Create new data set with ID Group baseline meanLET and wave so that we have Baseline, time 1 and 2 to compare to

data2 <- as.data.frame(mapply(c,data[,1:4], data[,c(1:3,5)]))
data2$wave <- rep(1:2, each=89)
names(data2) <- c("ID", "GROUP", "BASELINE", "meanLET", "WAVE")

Drop the cases where participants did not complete the intervention completely

#data2 <- data2[-c(which(data2$GROUP ==2)),]

Intention to treat model (ITT) where we keep the cases who dropped out and did not complete the study (http://en.wikipedia.org/wiki/Intention-to-treat_analysis).

data2[which(data2$GROUP ==2), "GROUP"] <- 1

For lme to work GROUP and ID need to be seen as factors

data2$GROUP <-as.factor(data2$GROUP)
data2$ID <-as.factor(data2$ID)

Describe the meanLET variable by the GROUP variable

describeBy(data2[,3:4], group = data2$GROUP)
## group: 0
##          vars  n mean   sd median trimmed  mad  min max range  skew
## BASELINE    1 86 3.61 0.91   3.67    3.63 0.99 1.67   5  3.33 -0.14
## meanLET     2 59 3.98 0.96   4.33    4.09 0.99 1.67   5  3.33 -0.72
##          kurtosis   se
## BASELINE    -0.97 0.10
## meanLET     -0.43 0.12
## -------------------------------------------------------- 
## group: 1
##          vars  n mean   sd median trimmed  mad  min max range  skew
## BASELINE    1 88 3.39 1.09   3.33    3.42 1.24 1.33   5  3.67 -0.03
## meanLET     2 54 4.13 0.90   4.33    4.25 0.99 1.33   5  3.67 -1.11
##          kurtosis   se
## BASELINE    -1.02 0.12
## meanLET      0.87 0.12

Create a plot that visualizes meanLET variable by the GROUP variable

library(ggplot2)
## 
## Attaching package: 'ggplot2'
## 
## The following object is masked from 'package:psych':
## 
##     %+%

Take a look at the residuals

residual <- lm(meanLET ~ BASELINE, data=data2)$residual

Plot the residuals to see that they are random

plot(density(residual))# A density plot

plot of chunk unnamed-chunk-10

qqnorm(residual) # A quantile normal plot to checking normality
qqline(residual)

plot of chunk unnamed-chunk-10 Checking the different between intervention and control groups residuals. This allows us to control for individual unsystematic differences.

data2$residual <- NA
sel1 <- which(!is.na(data2$meanLET)) 
sel2 <- which(!is.na(data2$BASELINE))
data2$residual[intersect(sel1,sel2)] <- residual
qplot(GROUP, meanLET, data=data2, geom="boxplot")
## Warning: Removed 65 rows containing non-finite values (stat_boxplot).

plot of chunk unnamed-chunk-11 Plot of the difference between intervention and control groups.

qplot(GROUP, residual, data=data2, geom="boxplot")
## Warning: Removed 69 rows containing non-finite values (stat_boxplot).

plot of chunk unnamed-chunk-12 Two way repeated measures ======================================================== Graphing the Two-Way Interaction. Both meanLET and the Residuals

# Load the nlme package
library(nlme)
with(data2, boxplot(meanLET ~ WAVE + GROUP))

plot of chunk unnamed-chunk-13

with(data2, boxplot(residual ~ WAVE + GROUP))

plot of chunk unnamed-chunk-13

Linear Mixed-Effects Model

Comparing Basline to Wave 2 and 3 by Group.

fullModel <- lme(meanLET ~ GROUP * WAVE + BASELINE, random = ~1 | ID, data = data2, method = "ML", na.action = "na.omit")
Results

Explanation of significance:

We asses the significance of our models by comparing them from the baseline model using the anova() function.
(Intercept): Where everything is 0
GROUP1: Is there a difference between group. If it is significant than there is a difference and the treatment had an effect.
WAVE: Asseses whether the effects gets bigger beteen time 2 and 3 (does not have to be significant)
BASELINE: Should not be significant. If it is then it shows that there is a difference between groups before the treatment.
GROUP1:WAVE: If this is significant then it means that the effect was either fleeting or it happened after the treatment i.e. between time 2 and 3.

summary(fullModel)
## Linear mixed-effects model fit by maximum likelihood
##  Data: data2 
##     AIC   BIC logLik
##   226.2 245.1 -106.1
## 
## Random effects:
##  Formula: ~1 | ID
##         (Intercept) Residual
## StdDev:      0.4531   0.4922
## 
## Fixed effects: meanLET ~ GROUP * WAVE + BASELINE 
##               Value Std.Error DF t-value p-value
## (Intercept)  1.6696    0.3619 66   4.614  0.0000
## GROUP1      -0.3300    0.3273 66  -1.008  0.3171
## WAVE        -0.1952    0.1429 38  -1.366  0.1799
## BASELINE     0.6737    0.0779 66   8.652  0.0000
## GROUP1:WAVE  0.4686    0.2090 38   2.242  0.0309
##  Correlation: 
##             (Intr) GROUP1 WAVE   BASELI
## GROUP1      -0.463                     
## WAVE        -0.520  0.600              
## BASELINE    -0.791  0.062 -0.031       
## GROUP1:WAVE  0.369 -0.886 -0.683  0.004
## 
## Standardized Within-Group Residuals:
##      Min       Q1      Med       Q3      Max 
## -2.49922 -0.40715  0.04361  0.54724  1.65473 
## 
## Number of Observations: 109
## Number of Groups: 69

Table with P-values

Value Std.Error DF t-value p-value
(Intercept) 1.6696 0.3619 66.0000 4.6137 0.0000
GROUP1 -0.3300 0.3273 66.0000 -1.0080 0.3171
WAVE -0.1952 0.1429 38.0000 -1.3661 0.1799
BASELINE 0.6737 0.0779 66.0000 8.6522 0.0000
GROUP1:WAVE 0.4686 0.2090 38.0000 2.2416 0.0309

``` Table with confidence intervals

est. lower upper
(Intercept) 1.6696 0.9638 2.3753
GROUP1 -0.3300 -0.9684 0.3084
WAVE -0.1952 -0.4778 0.0874
BASELINE 0.6737 0.5218 0.8255
GROUP1:WAVE 0.4686 0.0552 0.8820