Codes for flattening correlation matrix
# ++++++++++++++++++++++++++++
# flattenCorrMatrix
# ++++++++++++++++++++++++++++
# cormat : matrix of the correlation coefficients
# pmat : matrix of the correlation p-values
flattenCorrMatrix <- function(cormat, pmat) {
ut <- upper.tri(cormat)
data.frame(
row = rownames(cormat)[row(cormat)[ut]],
column = rownames(cormat)[col(cormat)[ut]],
cor =(cormat)[ut],
p = pmat[ut]
)
}
df <- CVLT[, c('Age', 'EduYears', 'CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free')]
res<-rcorr(as.matrix(df)) #correlation matrix
flat_corr <- flattenCorrMatrix(res$r, res$P)
corr <- flat_corr[flat_corr$row %in% c('Age', 'EduYears') ,]
corr <- corr[!(corr$column %in% c('Age', 'EduYears')) ,]
corr$adj_p <- p.adjust(corr$p, 'fdr') # FDR adjusted p-values
corr$Significance[corr$adj_p >= .05 & corr$adj_p < .10] <- "Trend"
corr$Significance[corr$adj_p < .05] <- "Significant"
corr$Significance[corr$adj_p > .10] <- "Non-Significant"
#Correlation table of correlations between age and CVLT-II performance
DT::datatable(corr)
#Male
df_m <- CVLT[CVLT$Sex ==1, c('Age', 'EduYears', 'CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free')]
res_m <-rcorr(as.matrix(df_m)) #correlation matrix
flat_corr_m <- flattenCorrMatrix(res_m$r, res_m$P)
corr_m <- flat_corr_m[flat_corr_m$row %in% c('Age', 'EduYears') ,]
corr_m <- corr_m[!(corr_m$column %in% c('Age', 'EduYears')) ,]
corr_m <- cbind(gender = 'Male', corr_m)
#Fenale
df_f <- CVLT[CVLT$Sex ==2, c('Age', 'EduYears', 'CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free')]
res_f <-rcorr(as.matrix(df_f)) #correlation matrix
flat_corr_f <- flattenCorrMatrix(res_f$r, res_f$P)
corr_f <- flat_corr_f[flat_corr_f$row %in% c('Age', 'EduYears') ,]
corr_f <- corr_f[!(corr_f$column %in% c('Age', 'EduYears')) ,]
corr_f <- cbind(gender = 'Female', corr_f)
corr_all <- rbind(corr_m, corr_f) # combining correlation tables for males and females
corr_all$adj_p <- p.adjust(corr_all$p, 'fdr') # FDR adjusted p-values
corr_all$Significance[corr_all$adj_p >= .05 & corr$adj_p < .10] <- "Trend"
corr_all$Significance[corr_all$adj_p < .05] <- "Significant"
corr_all$Significance[corr_all$adj_p > .10] <- "Non-Significant"
DT::datatable(corr_all)
CVLT$Sex <- as.factor(CVLT$Sex)
levels(CVLT$Sex) <- c("Male", "Female")
scatterplot(CVLT_Imm_Total ~ Age | Sex, data = CVLT, boxplot = "xy",
smooth=FALSE, ylab = "Immediate Free Recall")
scatterplot(CVLT_DelR_SD_Free ~ Age | Sex, data = CVLT, boxplot = "xy",
smooth=FALSE, ylab = "Short-Delayed Free Recall")
scatterplot(CVLT_DelR_LD_Free ~ Age | Sex, data = CVLT, boxplot = "xy",
smooth=FALSE, ylab = "Long-Delayed Free Recall")
print("Predicting Total Immediate Recall")
## [1] "Predicting Total Immediate Recall"
summary(lm.beta(model1 <- lm(CVLT_Imm_Total ~ Age + Sex + EduYears, data = CVLT)))
##
## Call:
## lm(formula = CVLT_Imm_Total ~ Age + Sex + EduYears, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.4349 -5.2955 -0.0098 6.3300 16.0469
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 53.30373 0.00000 5.08902 10.474 < 2e-16 ***
## Age -0.20890 -0.42114 0.03596 -5.809 4.40e-08 ***
## SexFemale 6.30457 0.34178 1.34791 4.677 7.05e-06 ***
## EduYears 0.48728 0.12842 0.27839 1.750 0.0824 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.747 on 133 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.3068, Adjusted R-squared: 0.2912
## F-statistic: 19.62 on 3 and 133 DF, p-value: 1.358e-10
print("Predicting Short-Delayed Free Recall")
## [1] "Predicting Short-Delayed Free Recall"
summary(lm.beta(model2 <- lm(CVLT_DelR_SD_Free ~ Age + Sex + EduYears, data = CVLT)))
##
## Call:
## lm(formula = CVLT_DelR_SD_Free ~ Age + Sex + EduYears, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.4245 -1.7981 0.1569 1.7174 3.9387
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 12.96399 0.00000 1.43648 9.025 1.77e-15 ***
## Age -0.06140 -0.44293 0.01015 -6.049 1.39e-08 ***
## SexFemale 1.59139 0.30872 0.38047 4.183 5.20e-05 ***
## EduYears 0.04772 0.04500 0.07858 0.607 0.545
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.187 on 133 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.2928, Adjusted R-squared: 0.2768
## F-statistic: 18.35 on 3 and 133 DF, p-value: 5.044e-10
print("Predicting Long-Delayed Free Recall")
## [1] "Predicting Long-Delayed Free Recall"
summary(lm.beta(model3 <- lm(CVLT_DelR_LD_Free ~ Age + Sex + EduYears, data = CVLT)))
##
## Call:
## lm(formula = CVLT_DelR_LD_Free ~ Age + Sex + EduYears, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6048 -1.6472 0.0856 1.8917 4.0711
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 12.31061 0.00000 1.51957 8.101 3.08e-13 ***
## Age -0.04612 -0.33084 0.01074 -4.296 3.34e-05 ***
## SexFemale 1.68742 0.32548 0.40248 4.193 5.00e-05 ***
## EduYears 0.07700 0.07220 0.08313 0.926 0.356
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.313 on 133 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.2176, Adjusted R-squared: 0.2
## F-statistic: 12.33 on 3 and 133 DF, p-value: 3.618e-07
t.test(CVLT_Imm_Total ~ Sex, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_Imm_Total by Sex
## t = -3.8691, df = 115.89, p-value = 0.000181
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8.977889 -2.898298
## sample estimates:
## mean in group Male mean in group Female
## 51.18033 57.11842
t.test(CVLT_DelR_SD_Free ~ Sex, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_SD_Free by Sex
## t = -3.6247, df = 120.36, p-value = 0.0004251
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.4047049 -0.7057351
## sample estimates:
## mean in group Male mean in group Female
## 10.78689 12.34211
t.test(CVLT_DelR_LD_Free ~ Sex, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_LD_Free by Sex
## t = -3.7542, df = 113.44, p-value = 0.0002759
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.4892677 -0.7695761
## sample estimates:
## mean in group Male mean in group Female
## 11.34426 12.97368
myColors <- ifelse(levels(CVLT$Sex)=="Male" , rgb(0.1,0.1,0.7,0.5) ,
ifelse(levels(CVLT$Sex)=="Female", rgb(0.8,0.1,0.3,0.6),
"grey90" ) )
par(mfrow=c(1,3))
boxplot(CVLT$CVLT_Imm_Total ~ CVLT$Sex, col = myColors, ylab="Total Immediate Recall", xlab = "Sex")
boxplot(CVLT$CVLT_DelR_SD_Free ~ CVLT$Sex, col = myColors, ylab="Short-Delayed Free Recall", xlab = "Sex")
boxplot(CVLT$CVLT_DelR_LD_Free ~ CVLT$Sex, col = myColors, ylab="Long-Delayed Free Recall", xlab = "Sex")
CVLT$COMT <- as.factor(CVLT$COMT)
levels(CVLT$COMT) <- c("Met/Met", "Val-allele carrier", "Val-allele carrier")
t.test(CVLT_Imm_Total ~ COMT, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_Imm_Total by COMT
## t = 1.4058, df = 46.606, p-value = 0.1664
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.174274 6.618583
## sample estimates:
## mean in group Met/Met mean in group Val-allele carrier
## 56.58065 53.85849
t.test(CVLT_DelR_SD_Free ~ COMT, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_SD_Free by COMT
## t = 0.82258, df = 45.856, p-value = 0.415
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.6553668 1.5610271
## sample estimates:
## mean in group Met/Met mean in group Val-allele carrier
## 12.00000 11.54717
t.test(CVLT_DelR_LD_Free ~ COMT, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_LD_Free by COMT
## t = 0.74892, df = 43.85, p-value = 0.4579
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7267552 1.5861587
## sample estimates:
## mean in group Met/Met mean in group Val-allele carrier
## 12.58065 12.15094
myColors <- ifelse(levels(CVLT$COMT)=="Met/Met" , rgb(0.1,0.1,0.7,0.5) ,
ifelse(levels(CVLT$COMT)=="Val-allele carrier", rgb(0.8,0.1,0.3,0.6),
"grey90" ) )
par(mfrow=c(1,3))
boxplot(CVLT$CVLT_Imm_Total ~ CVLT$COMT, col = myColors, ylab="Total Immediate Recall", xlab = "COMT")
boxplot(CVLT$CVLT_DelR_SD_Free ~ CVLT$COMT, col = myColors, ylab="Short-Delayed Free Recall", xlab = "COMT")
boxplot(CVLT$CVLT_DelR_LD_Free ~ CVLT$COMT, col = myColors, ylab="Long-Delayed Free Recall", xlab = "COMT")
CVLT$BDNF2 <- as.factor(CVLT$BDNF2)
levels(CVLT$BDNF2) <- c("Met-allele carrier", "Val/Val")
t.test(CVLT_Imm_Total ~ BDNF2, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_Imm_Total by BDNF2
## t = 0.99094, df = 85.116, p-value = 0.3245
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.686819 5.038993
## sample estimates:
## mean in group Met-allele carrier mean in group Val/Val
## 55.60000 53.92391
t.test(CVLT_DelR_SD_Free ~ BDNF2, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_SD_Free by BDNF2
## t = 0.47792, df = 87.728, p-value = 0.6339
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7072115 1.1550376
## sample estimates:
## mean in group Met-allele carrier mean in group Val/Val
## 11.80000 11.57609
t.test(CVLT_DelR_LD_Free ~ BDNF2, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_LD_Free by BDNF2
## t = 1.1336, df = 91.391, p-value = 0.2599
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.3941116 1.4419377
## sample estimates:
## mean in group Met-allele carrier mean in group Val/Val
## 12.60000 12.07609
myColors <- ifelse(levels(CVLT$BDNF2)=="Met-allele carrier" , rgb(0.1,0.1,0.7,0.5) ,
ifelse(levels(CVLT$BDNF2)=="Val/Val", rgb(0.8,0.1,0.3,0.6),
"grey90" ) )
par(mfrow=c(1,3))
boxplot(CVLT$CVLT_Imm_Total ~ CVLT$BDNF2, col = myColors, ylab="Total Immediate Recall", xlab = "BDNF")
boxplot(CVLT$CVLT_DelR_SD_Free ~ CVLT$BDNF2, col = myColors, ylab="Short-Delayed Free Recall", xlab = "BDNF")
boxplot(CVLT$CVLT_DelR_LD_Free ~ CVLT$BDNF2, col = myColors, ylab="Long-Delayed Free Recall", xlab = "BDNF")
CVLT$ApoE4 <- as.factor(CVLT$ApoE4)
levels(CVLT$ApoE4) <- c("e4 carrier", "non-carrier")
t.test(CVLT_Imm_Total ~ ApoE4, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_Imm_Total by ApoE4
## t = 0.74745, df = 32.493, p-value = 0.4602
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.752484 5.946437
## sample estimates:
## mean in group e4 carrier mean in group non-carrier
## 55.79167 54.19469
t.test(CVLT_DelR_SD_Free ~ ApoE4, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_SD_Free by ApoE4
## t = 0.26115, df = 29.925, p-value = 0.7958
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.174560 1.518955
## sample estimates:
## mean in group e4 carrier mean in group non-carrier
## 11.79167 11.61947
t.test(CVLT_DelR_LD_Free ~ ApoE4, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_LD_Free by ApoE4
## t = 0.41905, df = 32.163, p-value = 0.678
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.9834733 1.4930603
## sample estimates:
## mean in group e4 carrier mean in group non-carrier
## 12.45833 12.20354
myColors <- ifelse(levels(CVLT$ApoE4)=="e4 carrier" , rgb(0.1,0.1,0.7,0.5) ,
ifelse(levels(CVLT$ApoE4)=="non-carrier", rgb(0.8,0.1,0.3,0.6),
"grey90" ) )
par(mfrow=c(1,3))
boxplot(CVLT$CVLT_Imm_Total ~ CVLT$ApoE4, col = myColors, ylab="Total Immediate Recall", xlab = "ApoE4")
boxplot(CVLT$CVLT_DelR_SD_Free ~ CVLT$ApoE4, col = myColors, ylab="Short-Delayed Free Recall", xlab = "ApoE4")
boxplot(CVLT$CVLT_DelR_LD_Free ~ CVLT$ApoE4, col = myColors, ylab="Long-Delayed Free Recall", xlab = "ApoE4")
CVLT$Smoker <- as.factor(CVLT$Smoker)
levels(CVLT$Smoker) <- c("Non-smoker", "Smoker")
t.test(CVLT_Imm_Total ~ Smoker, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_Imm_Total by Smoker
## t = 0.015517, df = 4.2139, p-value = 0.9883
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -13.47626 13.63081
## sample estimates:
## mean in group Non-smoker mean in group Smoker
## 54.47727 54.40000
t.test(CVLT_DelR_SD_Free ~ Smoker, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_SD_Free by Smoker
## t = -1.0596, df = 4.2362, p-value = 0.346
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.99452 2.19149
## sample estimates:
## mean in group Non-smoker mean in group Smoker
## 11.59848 13.00000
t.test(CVLT_DelR_LD_Free ~ Smoker, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_LD_Free by Smoker
## t = -0.71854, df = 4.2211, p-value = 0.5102
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.727473 2.751715
## sample estimates:
## mean in group Non-smoker mean in group Smoker
## 12.21212 13.20000
myColors <- ifelse(levels(CVLT$Smoker)=="Non-smoker" , rgb(0.1,0.1,0.7,0.5) ,
ifelse(levels(CVLT$Smoker)=="Smoker", rgb(0.8,0.1,0.3,0.6),
"grey90" ) )
par(mfrow=c(1,3))
boxplot(CVLT$CVLT_Imm_Total ~ CVLT$Smoker, col = myColors, ylab="Total Immediate Recall", xlab = "Smoking Status")
boxplot(CVLT$CVLT_DelR_SD_Free ~ CVLT$Smoker, col = myColors, ylab="Short-Delayed Free Recall", xlab = "Smoking Status")
boxplot(CVLT$CVLT_DelR_LD_Free ~ CVLT$Smoker, col = myColors, ylab="Long-Delayed Free Recall", xlab = "Smoking Status")
# T-tests – High BP
CVLT$High_BP <- as.factor(CVLT$High_BP)
levels(CVLT$High_BP) <- c("No", "Yes")
t.test(CVLT_Imm_Total ~ High_BP, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_Imm_Total by High_BP
## t = 2.3836, df = 17.991, p-value = 0.02837
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.6756455 10.7210758
## sample estimates:
## mean in group No mean in group Yes
## 55.09836 49.40000
t.test(CVLT_DelR_SD_Free ~ High_BP, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_SD_Free by High_BP
## t = 1.253, df = 18.619, p-value = 0.2257
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.5410669 2.1498101
## sample estimates:
## mean in group No mean in group Yes
## 11.73770 10.93333
t.test(CVLT_DelR_LD_Free ~ High_BP, data = CVLT)
##
## Welch Two Sample t-test
##
## data: CVLT_DelR_LD_Free by High_BP
## t = 0.78538, df = 18.752, p-value = 0.442
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.8391423 1.8456996
## sample estimates:
## mean in group No mean in group Yes
## 12.30328 11.80000
myColors <- ifelse(levels(CVLT$High_BP)=="No" , rgb(0.1,0.1,0.7,0.5) ,
ifelse(levels(CVLT$High_BP)=="Yes", rgb(0.8,0.1,0.3,0.6),
"grey90" ) )
par(mfrow=c(1,3))
boxplot(CVLT$CVLT_Imm_Total ~ CVLT$High_BP, col = myColors, ylab="Total Immediate Recall", xlab = "High_BP")
boxplot(CVLT$CVLT_DelR_SD_Free ~ CVLT$High_BP, col = myColors, ylab="Short-Delayed Free Recall", xlab = "High_BP")
boxplot(CVLT$CVLT_DelR_LD_Free ~ CVLT$High_BP, col = myColors, ylab="Long-Delayed Free Recall", xlab = "High_BP")
print("Predicting Total Immediate Recall")
## [1] "Predicting Total Immediate Recall"
summary(lm.beta(model1 <- lm(CVLT_Imm_Total ~ Age + Sex + EduYears + High_BP + Smoker, data = CVLT)))
##
## Call:
## lm(formula = CVLT_Imm_Total ~ Age + Sex + EduYears + High_BP +
## Smoker, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.481 -5.231 0.016 6.474 16.090
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 53.428274 0.000000 5.148996 10.376 < 2e-16 ***
## Age -0.213637 -0.430693 0.040266 -5.306 4.65e-07 ***
## SexFemale 6.329953 0.343159 1.361797 4.648 8.06e-06 ***
## EduYears 0.488362 0.128710 0.280859 1.739 0.0844 .
## High_BPYes 0.638781 0.021757 2.384045 0.268 0.7892
## SmokerSmoker 0.060534 0.001238 3.566915 0.017 0.9865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.803 on 131 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.3072, Adjusted R-squared: 0.2808
## F-statistic: 11.62 on 5 and 131 DF, p-value: 2.664e-09
print("Predicting Short-Delayed Free Recall")
## [1] "Predicting Short-Delayed Free Recall"
summary(lm.beta(model2 <- lm(CVLT_DelR_SD_Free ~ Age + Sex + EduYears + High_BP + Smoker, data = CVLT)))
##
## Call:
## lm(formula = CVLT_DelR_SD_Free ~ Age + Sex + EduYears + High_BP +
## Smoker, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.4611 -1.7197 0.2673 1.6641 3.7921
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 13.26007 0.00000 1.42446 9.309 3.94e-16 ***
## Age -0.07050 -0.50863 0.01114 -6.329 3.61e-09 ***
## SexFemale 1.62413 0.31507 0.37674 4.311 3.17e-05 ***
## EduYears 0.04424 0.04173 0.07770 0.569 0.5700
## High_BPYes 1.15153 0.14035 0.65954 1.746 0.0832 .
## SmokerSmoker 1.44760 0.10596 0.98678 1.467 0.1448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.159 on 131 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.321, Adjusted R-squared: 0.2951
## F-statistic: 12.39 on 5 and 131 DF, p-value: 7.57e-10
print("Predicting Long-Delayed Free Recall")
## [1] "Predicting Long-Delayed Free Recall"
summary(lm.beta(model3 <- lm(CVLT_DelR_LD_Free ~ Age + Sex + EduYears + High_BP + Smoker, data = CVLT)))
##
## Call:
## lm(formula = CVLT_DelR_LD_Free ~ Age + Sex + EduYears + High_BP +
## Smoker, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6486 -1.8110 0.1346 1.8208 4.4169
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 12.56579 0.00000 1.51889 8.273 1.29e-13 ***
## Age -0.05445 -0.39055 0.01188 -4.584 1.05e-05 ***
## SexFemale 1.72171 0.33209 0.40171 4.286 3.50e-05 ***
## EduYears 0.07534 0.07064 0.08285 0.909 0.365
## High_BPYes 1.07326 0.13006 0.70326 1.526 0.129
## SmokerSmoker 0.96059 0.06991 1.05219 0.913 0.363
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.302 on 131 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.2369, Adjusted R-squared: 0.2077
## F-statistic: 8.132 on 5 and 131 DF, p-value: 1.039e-06
print("Predicting Total Immediate Recall")
## [1] "Predicting Total Immediate Recall"
summary(lm.beta(model1 <- lm(CVLT_Imm_Total ~ Age + Sex + EduYears + High_BP + Smoker + COMT + BDNF2 + ApoE4, data = CVLT)))
##
## Call:
## lm(formula = CVLT_Imm_Total ~ Age + Sex + EduYears + High_BP +
## Smoker + COMT + BDNF2 + ApoE4, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.2846 -5.7129 -0.8437 6.0722 14.9569
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 56.4635792 0.0000000 5.2925784 10.668 < 2e-16 ***
## Age -0.2149555 -0.4333507 0.0397904 -5.402 3.10e-07 ***
## SexFemale 6.0388866 0.3273800 1.3577995 4.448 1.86e-05 ***
## EduYears 0.6765795 0.1783151 0.2900534 2.333 0.0212 *
## High_BPYes 0.3735136 0.0127220 2.3608462 0.158 0.8745
## SmokerSmoker 0.0322806 0.0006603 3.5801374 0.009 0.9928
## COMTVal-allele carrier -2.4967458 -0.1139546 1.6170786 -1.544 0.1251
## BDNF2Val/Val -1.6513923 -0.0846007 1.4288087 -1.156 0.2499
## ApoE4non-carrier -3.3003863 -0.1368463 1.8282529 -1.805 0.0734 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.698 on 128 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.3412, Adjusted R-squared: 0.3
## F-statistic: 8.285 on 8 and 128 DF, p-value: 5.254e-09
print("Predicting Short-Delayed Free Recall")
## [1] "Predicting Short-Delayed Free Recall"
summary(lm.beta(model2 <- lm(CVLT_DelR_SD_Free ~ Age + Sex + EduYears + High_BP + Smoker + COMT + BDNF2 + ApoE4, data = CVLT)))
##
## Call:
## lm(formula = CVLT_DelR_SD_Free ~ Age + Sex + EduYears + High_BP +
## Smoker + COMT + BDNF2 + ApoE4, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6688 -1.7688 0.1582 1.5934 3.7310
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 13.61260 0.00000 1.49439 9.109 1.43e-15 ***
## Age -0.07061 -0.50940 0.01124 -6.285 4.74e-09 ***
## SexFemale 1.58900 0.30826 0.38338 4.145 6.15e-05 ***
## EduYears 0.06666 0.06287 0.08190 0.814 0.4172
## High_BPYes 1.11961 0.13646 0.66660 1.680 0.0955 .
## SmokerSmoker 1.45751 0.10668 1.01088 1.442 0.1518
## COMTVal-allele carrier -0.35176 -0.05745 0.45659 -0.770 0.4425
## BDNF2Val/Val -0.15629 -0.02865 0.40343 -0.387 0.6991
## ApoE4non-carrier -0.36731 -0.05450 0.51622 -0.712 0.4780
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.174 on 128 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.3274, Adjusted R-squared: 0.2854
## F-statistic: 7.788 on 8 and 128 DF, p-value: 1.754e-08
print("Predicting Long-Delayed Free Recall")
## [1] "Predicting Long-Delayed Free Recall"
summary(lm.beta(model3 <- lm(CVLT_DelR_LD_Free ~ Age + Sex + EduYears + High_BP + Smoker + COMT + BDNF2 + ApoE4, data = CVLT)))
##
## Call:
## lm(formula = CVLT_DelR_LD_Free ~ Age + Sex + EduYears + High_BP +
## Smoker + COMT + BDNF2 + ApoE4, data = CVLT)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.764 -1.558 0.164 1.727 4.319
##
## Coefficients:
## Estimate Standardized Std. Error t value Pr(>|t|)
## (Intercept) 13.16652 0.00000 1.58709 8.296 1.29e-13 ***
## Age -0.05462 -0.39178 0.01193 -4.578 1.10e-05 ***
## SexFemale 1.66069 0.32032 0.40717 4.079 7.91e-05 ***
## EduYears 0.10325 0.09682 0.08698 1.187 0.237
## High_BPYes 1.01497 0.12300 0.70795 1.434 0.154
## SmokerSmoker 0.97633 0.07105 1.07358 0.909 0.365
## COMTVal-allele carrier -0.35513 -0.05767 0.48492 -0.732 0.465
## BDNF2Val/Val -0.44292 -0.08073 0.42846 -1.034 0.303
## ApoE4non-carrier -0.51281 -0.07565 0.54824 -0.935 0.351
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.309 on 128 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.25, Adjusted R-squared: 0.2031
## F-statistic: 5.334 on 8 and 128 DF, p-value: 8.688e-06
df <- CVLT[, c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free', 'LH_Total', 'RH_Total', 'L_HH_Total', 'R_HH_Total', 'L_HB_Total', 'R_HB_Total', 'L_HT_Total', 'R_HT_Total')]
res<-rcorr(as.matrix(df)) #correlation matrix
flat_corr <- flattenCorrMatrix(res$r, res$P)
#get p values for correlation with CVLT only
cvlt_corr <- flat_corr[flat_corr$row %in% c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free') ,] #get p values for correlation with CVLT only
cvlt_corr <- cvlt_corr[!(cvlt_corr$column %in% c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free')) ,]
cvlt_corr$adj_p <- p.adjust(cvlt_corr$p, 'fdr') # FDR adjusted p-values
cvlt_corr$Significance[cvlt_corr$adj_p >= .05 & cvlt_corr$adj_p < .10] <- "Trend"
cvlt_corr$Significance[cvlt_corr$adj_p < .05] <- "Significant"
cvlt_corr$Significance[cvlt_corr$adj_p > .10] <- "Non-Significant"
DT::datatable(cvlt_corr) #Correlation table of correlations between age and CVLT-II performance
cvlt_corr$cor <- round(cvlt_corr$cor, digits = 3)
plt <- ggplot(cvlt_corr,aes( row, column,fill=cor))
plt <- plt + geom_tile()
plt <- plt + theme_minimal()
plt <- plt + scale_fill_gradient(low="white", high="red")
plt <- plt + geom_text(aes(label = cor))
plt <- plt + labs(x ="CVLT", y ="Volumes")
plt
df <- CVLT[, c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free', 'L_CA_Total', 'R_CA_Total', 'L_DG_Total', 'R_DG_Total', 'L_Sub_Total', 'R_Sub_Total')]
res<-rcorr(as.matrix(df)) #correlation matrix
flat_corr <- flattenCorrMatrix(res$r, res$P)
#get p values for correlation with CVLT only
cvlt_corr <- flat_corr[flat_corr$row %in% c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free') ,] #get p values for correlation with CVLT only
cvlt_corr <- cvlt_corr[!(cvlt_corr$column %in% c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free')) ,]
cvlt_corr$adj_p <- p.adjust(cvlt_corr$p, 'fdr') # FDR adjusted p-values
cvlt_corr$Significance[cvlt_corr$adj_p >= .05 & cvlt_corr$adj_p < .10] <- "Trend"
cvlt_corr$Significance[cvlt_corr$adj_p < .05] <- "Significant"
cvlt_corr$Significance[cvlt_corr$adj_p > .10] <- "Non-Significant"
DT::datatable(cvlt_corr) #Correlation table of correlations between age and CVLT-II performance
cvlt_corr$cor <- round(cvlt_corr$cor, digits = 3)
plt <- ggplot(cvlt_corr,aes( row, column,fill=cor))
plt <- plt + geom_tile()
plt <- plt + theme_minimal()
plt <- plt + scale_fill_gradient(low="white", high="red")
plt <- plt + geom_text(aes(label = cor))
plt <- plt + labs(x ="CVLT", y ="Volumes")
plt
df <- CVLT[, c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free', 'L_HH_DG', 'R_HH_DG', 'L_HB_DG', 'R_HB_DG', 'L_HT_DG' , 'R_HT_DG', 'L_HH_Sub', 'R_HH_Sub', 'L_HB_Sub', 'R_HB_Sub', 'L_HT_Sub', 'R_HT_Sub', 'L_HH_CA', 'R_HH_CA', 'L_HB_CA', 'R_HB_CA', 'L_HT_CA', 'R_HT_CA')]
res<-rcorr(as.matrix(df)) #correlation matrix
flat_corr <- flattenCorrMatrix(res$r, res$P)
#get p values for correlation with CVLT only
cvlt_corr <- flat_corr[flat_corr$row %in% c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free') ,] #get p values for correlation with CVLT only
cvlt_corr <- cvlt_corr[!(cvlt_corr$column %in% c('CVLT_Imm_Total', 'CVLT_DelR_SD_Free', 'CVLT_DelR_LD_Free')) ,]
cvlt_corr$adj_p <- p.adjust(cvlt_corr$p, 'fdr') # FDR adjusted p-values
cvlt_corr$Significance[cvlt_corr$adj_p >= .05 & cvlt_corr$adj_p < .10] <- "Trend"
cvlt_corr$Significance[cvlt_corr$adj_p < .05] <- "Significant"
cvlt_corr$Significance[cvlt_corr$adj_p > .10] <- "Non-Significant"
DT::datatable(cvlt_corr) #Correlation table of correlations between age and CVLT-II performance
cvlt_corr$cor <- round(cvlt_corr$cor, digits = 3)
plt <- ggplot(cvlt_corr,aes( row, column,fill=cor))
plt <- plt + geom_tile()
plt <- plt + theme_minimal()
plt <- plt + scale_fill_gradient(low="white", high="red")
plt <- plt + geom_text(aes(label = cor))
plt <- plt + labs(x ="CVLT", y ="Volumes")
plt