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)
# Only PERMA acomplishment questions
data$T1PERMA_ACOMP <- apply(data[, c("PERMA1.x", "PERMA6.x", "PERMA12.x")],
1, mean, na.rm = TRUE)
data$T2PERMA_ACOMP <- apply(data[, c("PERMA1.y", "PERMA6.y", "PERMA12.y")],
1, mean, na.rm = TRUE)
plot(data$T1PERMA_ACOMP, data$T2PERMA_ACOMP, ylab = "Pre", xlab = "Post", main = "Acomplishement")
# pre test plots
bwplot(GROUP.x ~ T1PERMA_ACOMP, ylab = "GROUP", xlab = "PERMA_ACOMP", main = "Pre test",
data = data)
# post test plots
bwplot(GROUP.x ~ T2PERMA_ACOMP, ylab = "Group", xlab = "PERMA", main = "Post test",
data = data)
# Pre test
t.test(T1PERMA_ACOMP ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T1PERMA_ACOMP by GROUP.x
## t = 1.155, df = 62.34, p-value = 0.2526
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.3313 1.2378
## sample estimates:
## mean in group 0 mean in group 1
## 7.276 6.823
t.test(T2PERMA_ACOMP ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T2PERMA_ACOMP by GROUP.x
## t = -0.5619, df = 44.99, p-value = 0.577
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.9348 0.5270
## sample estimates:
## mean in group 0 mean in group 1
## 7.590 7.794
# Ancova, Model for PERMA acmplishment questions
PERMA_ACOMP_ANCOVA <- lm(T2PERMA_ACOMP ~ as.factor(GROUP.x) + T1PERMA_ACOMP,
data = data)
# check assumptions visually
plot(PERMA_ACOMP_ANCOVA)
# Results show that number 16 is an outlier. This will be re-run withour 16
# to see if it changes the results. see results
summary(PERMA_ACOMP_ANCOVA)
##
## Call:
## lm(formula = T2PERMA_ACOMP ~ as.factor(GROUP.x) + T1PERMA_ACOMP,
## data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.928 -0.333 0.006 0.525 2.449
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.061 0.776 5.23 4.4e-06 ***
## as.factor(GROUP.x)1 0.239 0.307 0.78 0.44
## T1PERMA_ACOMP 0.475 0.101 4.72 2.4e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.05 on 44 degrees of freedom
## (22 observations deleted due to missingness)
## Multiple R-squared: 0.34, Adjusted R-squared: 0.31
## F-statistic: 11.3 on 2 and 44 DF, p-value: 0.000106
# Results show that there is no significan increase based in sense of
# acomplishemnet due to the intervention
# Now running the same tests but without 16 which was an outlier
data$T1PERMA_ACOMP1 <- apply(data[, c("PERMA1.x", "PERMA6.x", "PERMA12.x")],
1, mean, na.rm = TRUE)
data$T2PERMA_ACOMP1 <- apply(data[, c("PERMA1.y", "PERMA6.y", "PERMA12.y")],
1, mean, na.rm = TRUE)
plot(data$T1PERMA_ACOMP1, data$T2PERMA_ACOMP1, ylab = "Pre", xlab = "Post",
main = "Acomplishement")
# pre test plots
bwplot(GROUP.x ~ T1PERMA_ACOMP1, ylab = "GROUP", xlab = "PERMA_ACOMP", main = "Pre test",
data = data)
# post test plots
bwplot(GROUP.x ~ T2PERMA_ACOMP1, ylab = "Group", xlab = "PERMA", main = "Post test",
data = data)
# Pre test
t.test(T1PERMA_ACOMP1 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T1PERMA_ACOMP1 by GROUP.x
## t = 1.155, df = 62.34, p-value = 0.2526
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.3313 1.2378
## sample estimates:
## mean in group 0 mean in group 1
## 7.276 6.823
t.test(T2PERMA_ACOMP1 ~ GROUP.x, data = data)
##
## Welch Two Sample t-test
##
## data: T2PERMA_ACOMP1 by GROUP.x
## t = -0.5619, df = 44.99, p-value = 0.577
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.9348 0.5270
## sample estimates:
## mean in group 0 mean in group 1
## 7.590 7.794
# Ancova, Model for PERMA complishment without number 16
PERMA_ACOMP_ANCOVA1 <- lm(T2PERMA_ACOMP ~ as.factor(GROUP.x) + T1PERMA_ACOMP,
data = data, -16)
# check assumptions visually
plot(PERMA_ACOMP_ANCOVA1)
# see results
summary(PERMA_ACOMP_ANCOVA1)
##
## Call:
## lm(formula = T2PERMA_ACOMP ~ as.factor(GROUP.x) + T1PERMA_ACOMP,
## data = data, subset = -16)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.895 -0.323 0.082 0.515 1.677
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.215 0.781 4.11 0.00017 ***
## as.factor(GROUP.x)1 0.102 0.289 0.35 0.72585
## T1PERMA_ACOMP 0.589 0.102 5.77 7.8e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.972 on 43 degrees of freedom
## (22 observations deleted due to missingness)
## Multiple R-squared: 0.439, Adjusted R-squared: 0.413
## F-statistic: 16.9 on 2 and 43 DF, p-value: 3.94e-06
# Results show that while there is a higer multiple R-squared there is a
# much higher p-value as well.