Data Preperation on April, 2nd 2014 - these are preliminary results with on 22 people in the intervention group reporting.
setwd("/Users/levibrackman/Desktop/Adult_study")
data_pre <- read.csv("pre.csv")
data_post <- read.csv("post.csv")
table(data_pre$GROUP, dnn = "group")
## group
## 0 1
## 35 32
data <- merge(data_pre, data_post, by = "ID", all = TRUE)
library(psych)
library(lattice)
# Time 1 LET
items <- grep("LET[0-6]*.x", names(data), value = TRUE)
scaleKey <- c(-1, 1, -1, 1, -1, 1)
data$meanT1LET <- scoreItems(scaleKey, items = data[, items], delete = FALSE)$score
# T2 LET
items <- grep("LET[0-6]*.y", names(data), value = TRUE)
scaleKey <- c(-1, 1, -1, 1, -1, 1)
data$meanT2LET <- scoreItems(scaleKey, items = data[, items], delete = FALSE)$score
# All LET questions
data$T1LET <- apply(data[, c("LET1.x", "LET2.x", "LET3.x", "LET4.x", "LET5.x",
"LET6.x", "meanT1LET")], 1, mean, na.rm = TRUE)
data$T2LET <- apply(data[, c("LET1.y", "LET2.y", "LET3.y", "LET4.y", "LET5.y",
"LET6.y", "meanT2LET")], 1, mean, na.rm = TRUE)
plot(data$T1LET, data$T2LET, ylab = "Pre", xlab = "Post", main = "Life Staisfaction")
# pre test plots
bwplot(GROUP.x ~ T1LET, ylab = "GROUP", xlab = "LET", main = "Pre test", data = data)
# post test plots
bwplot(GROUP.x ~ T2LET, ylab = "Group", xlab = "LET", main = "Post test", data = data)
# Pre test
t.test(T1LET ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T1LET by GROUP.x
## t = 0.9578, df = 64.98, p-value = 0.3417
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.07754 0.22044
## sample estimates:
## mean in group 0 mean in group 1
## 3.301 3.230
t.test(T2LET ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T2LET by GROUP.x
## t = -1.078, df = 64.25, p-value = 0.2851
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.4610 0.1378
## sample estimates:
## mean in group 0 mean in group 1
## 3.525 3.687
# Ancova, Model for LET
LET_ANCOVA <- lm(T2LET ~ as.factor(GROUP.x) + T1LET, data = data)
# check assumptions visually
plot(LET_ANCOVA)
# see results
summary(LET_ANCOVA)
##
## Call:
## lm(formula = T2LET ~ as.factor(GROUP.x) + T1LET, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.766 -0.435 -0.233 0.705 1.121
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.143 0.814 2.63 0.011 *
## as.factor(GROUP.x)1 0.191 0.149 1.29 0.202
## T1LET 0.419 0.245 1.71 0.092 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.604 on 64 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.0606, Adjusted R-squared: 0.0312
## F-statistic: 2.06 on 2 and 64 DF, p-value: 0.135
# Time 1 LET
items <- grep("LET[0-6]*.x", names(data), value = TRUE)
scaleKey <- c(-1, 1, -1, 1, -1, 1)
data$meanT1LET <- scoreItems(scaleKey, items = data[, items], delete = FALSE)$score
# T2 LET
items <- grep("LET[0-6]*.y", names(data), value = TRUE)
scaleKey <- c(-1, 1, -1, 1, -1, 1)
data$meanT2LET <- scoreItems(scaleKey, items = data[, items], delete = FALSE)$score
# Only questions 2, 4, 6 of LET
data$T1LET_Factor2 <- apply(data[, c("LET2.x", "LET4.x", "LET6.x", "meanT1LET")],
1, mean, na.rm = TRUE)
data$T2LET_Factor2 <- apply(data[, c("LET2.y", "LET4.y", "LET6.y", "meanT2LET")],
1, mean, na.rm = TRUE)
plot(data$T1LET_Factor2, data$T2LET_Factor2, ylab = "Pre", xlab = "Post", main = "LET")
# pre test plots
bwplot(GROUP.x ~ T1LET_Factor2, ylab = "GROUP", xlab = "LET", main = "Pre test",
data = data)
# post test plots
bwplot(GROUP.x ~ T2LET_Factor2, ylab = "Group", xlab = "LET", main = "Post test",
data = data)
# Pre test
t.test(T1LET_Factor2 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T1LET_Factor2 by GROUP.x
## t = 1.712, df = 62.45, p-value = 0.09183
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.04487 0.58110
## sample estimates:
## mean in group 0 mean in group 1
## 4.085 3.816
t.test(T2LET_Factor2 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T2LET_Factor2 by GROUP.x
## t = -0.7959, df = 64.82, p-value = 0.429
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.3457 0.1487
## sample estimates:
## mean in group 0 mean in group 1
## 4.287 4.385
# Ancova, Model for LET
LET_Factor2_ANCOVA <- lm(T2LET_Factor2 ~ as.factor(GROUP.x) + T1LET_Factor2,
data = data)
# check assumptions visually
plot(LET_Factor2_ANCOVA)
# see results
summary(LET_Factor2_ANCOVA)
##
## Call:
## lm(formula = T2LET_Factor2 ~ as.factor(GROUP.x) + T1LET_Factor2,
## data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.0432 -0.2417 0.0315 0.2488 0.8962
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.3995 0.3406 7.04 1.6e-09 ***
## as.factor(GROUP.x)1 0.2224 0.1048 2.12 0.038 *
## T1LET_Factor2 0.4621 0.0816 5.66 3.8e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.419 on 64 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.34, Adjusted R-squared: 0.32
## F-statistic: 16.5 on 2 and 64 DF, p-value: 1.65e-06
# Only questions 1, 3, 5 of LET
data$T1LET_Factor1 <- apply(data[, c("LET1.x", "LET3.x", "LET5.x", "meanT1LET")],
1, mean, na.rm = TRUE)
data$T2LET_Factor1 <- apply(data[, c("LET1.y", "LET3.y", "LET5.y", "meanT2LET")],
1, mean, na.rm = TRUE)
plot(data$T1LET_Factor1, data$T2LET_Factor1, ylab = "Pre", xlab = "Post", main = "LET")
# pre test plots
bwplot(GROUP.x ~ T1LET_Factor1, ylab = "GROUP", xlab = "LET", main = "Pre test",
data = data)
# post test plots
bwplot(GROUP.x ~ T2LET_Factor1, ylab = "Group", xlab = "LET", main = "Post test",
data = data)
# Pre test
t.test(T1LET_Factor1 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T1LET_Factor1 by GROUP.x
## t = -0.6192, df = 63.83, p-value = 0.538
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.3565 0.1878
## sample estimates:
## mean in group 0 mean in group 1
## 2.677 2.762
t.test(T2LET_Factor1 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T2LET_Factor1 by GROUP.x
## t = -0.7742, df = 63.23, p-value = 0.4417
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7156 0.3159
## sample estimates:
## mean in group 0 mean in group 1
## 2.951 3.151
# Ancova, Model for LET
LET_Factor1_ANCOVA <- lm(T2LET_Factor1 ~ as.factor(GROUP.x) + T1LET_Factor1,
data = data)
# check assumptions visually
plot(LET_Factor1_ANCOVA)
# see results
summary(LET_Factor1_ANCOVA)
##
## Call:
## lm(formula = T2LET_Factor1 ~ as.factor(GROUP.x) + T1LET_Factor1,
## data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.354 -0.641 -0.337 0.728 2.233
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.543 0.579 0.94 0.35
## as.factor(GROUP.x)1 0.124 0.229 0.54 0.59
## T1LET_Factor1 0.900 0.208 4.32 5.5e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.932 on 64 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.233, Adjusted R-squared: 0.209
## F-statistic: 9.73 on 2 and 64 DF, p-value: 0.000205
# Only questions 1 of LET
data$T1LETQ1 <- apply(data[("LET1.x")], 1, mean, na.rm = TRUE)
data$T2LETQ1 <- apply(data[("LET1.y")], 1, mean, na.rm = TRUE)
plot(data$T1LETQ1, data$T2LETQ1, ylab = "Pre", xlab = "Post", main = "LET")
# pre test plots
bwplot(GROUP.x ~ T1LETQ1, ylab = "GROUP", xlab = "LET", main = "Pre test", data = data)
# post test plots
bwplot(GROUP.x ~ T2LETQ1, ylab = "Group", xlab = "LET", main = "Post test",
data = data)
# Pre test
t.test(T1LETQ1 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T1LETQ1 by GROUP.x
## t = -0.7225, df = 64.31, p-value = 0.4726
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.9008 0.4223
## sample estimates:
## mean in group 0 mean in group 1
## 2.886 3.125
t.test(T2LETQ1 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T2LETQ1 by GROUP.x
## t = 0.616, df = 43.94, p-value = 0.5411
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.5285 0.9937
## sample estimates:
## mean in group 0 mean in group 1
## 2.423 2.190
# Ancova, Model for LET
LETQ1ANCOVA <- lm(T2LETQ1 ~ as.factor(GROUP.x) + T1LETQ1, data = data)
# check assumptions visually
plot(LETQ1ANCOVA)
# see results
summary(LETQ1ANCOVA)
##
## Call:
## lm(formula = T2LETQ1 ~ as.factor(GROUP.x) + T1LETQ1, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.2529 -0.4167 0.0937 0.5833 2.0955
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.556 0.331 1.68 0.10 .
## as.factor(GROUP.x)1 -0.324 0.270 -1.20 0.24
## T1LETQ1 0.674 0.100 6.74 2.8e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.92 on 44 degrees of freedom
## (22 observations deleted due to missingness)
## Multiple R-squared: 0.512, Adjusted R-squared: 0.49
## F-statistic: 23.1 on 2 and 44 DF, p-value: 1.41e-07