## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
+## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
+## ✓ tibble 3.1.2 ✓ dplyr 1.0.7
+## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
+## ✓ readr 1.4.0 ✓ forcats 0.5.1
+## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
+## x dplyr::filter() masks stats::filter()
+## x dplyr::lag() masks stats::lag()
+
+## corrplot 0.90 loaded
+
+Final DF
+rc <- read.csv("~/Box/Aging Decision Making R01/RAs/Juo-Lin/data/REDCap Data/R56 REDCap Data.csv")
+cm <- read.csv("~/Box/Aging Decision Making R01/RAs/Juo-Lin/data/cr_measures.csv")
+
+rc$subject_id <- stringr::str_pad(rc$record_id, width = 4, side = "left", pad = "0")
+cm$subject_id <- substring(cm$subject, 3, 6)
+
+df <- merge(rc, cm, by = c('subject_id'), all = T)
+
+spec_df <- df %>%
+ select(subject_id, starts_with("gender"), -gender_spec)
+
+spec <- spec_df %>% build_longer_spec(
+ cols = !subject_id,
+ names_to = "gender",
+ values_to = "count"
+)
+
+df1 <- pivot_longer_spec (spec_df, spec)
+df1[df1 == 0] <- NA
+
+df2 <- df1 %>%
+ drop_na(count)
+
+df3 <- merge(df2, df, by = c('subject_id'), all = T)
+
+finaldf <- df3 %>%
+ select(subject_id, redcap_event_name, age, IS, IV, RA, gender, contains("pre_bdi"), contains("pre_masq"), contains("pre_idas"), contains("pre_swls"), contains("pre_erq")) %>%
+ group_by(subject_id) %>%
+ fill(starts_with("gender"), .direction = "down") %>%
+ ungroup() %>%
+ filter(redcap_event_name == "session_1_arm_1") %>%
+ drop_na(RA)
+
+finaldf$gender <- gsub("gender___", "", as.character(finaldf$gender))
Age/RA Correlation Graph
+ra_age <- finaldf %>%
+ select(RA, age)
+ggplot(ra_age, aes(x = age, y = RA)) +
+ geom_point() +
+ ggtitle("Age / RA Correlation Graph")
BDI/RA Correlation Matrix
+ra_bdi <- finaldf %>%
+ select (RA, contains("pre_bdi"))
+
+correl_matrix <- data.matrix(ra_bdi)
+correl_numeric_matrix <- as.matrix((sapply(ra_bdi, as.numeric)))
+
+matrx <- cor(correl_numeric_matrix)
+#round(matrx,2)
+
+corrplot(matrx, method = "color")
BDI/RA Correlation Graphs
+BDI Total
+ra_bdi_total <- ra_bdi %>%
+ select(RA, "pre_bdi_total")
+ggplot(ra_bdi_total, aes(x = pre_bdi_total, y = RA)) +
+ geom_point() +
+ ggtitle("BDI Total / RA Correlation Graph")
BDI variables with >0.1 or >-0.1 correlation
+ra_bdi_1 <- ra_bdi %>%
+ select(RA, "pre_bdi_1")
+ggplot(ra_bdi_1, aes(x = pre_bdi_1, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 1 (Sadness) / RA Correlation Graph")
ra_bdi_2 <- ra_bdi %>%
+ select(RA, "pre_bdi_2")
+ggplot(ra_bdi_2, aes(x = pre_bdi_2, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 2 (Pessimism) / RA Correlation Graph")
ra_bdi_3 <- ra_bdi %>%
+ select(RA, "pre_bdi_3")
+ggplot(ra_bdi_3, aes(x = pre_bdi_3, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 3 (Past Failures) / RA Correlation Graph")
ra_bdi_6 <- ra_bdi %>%
+ select(RA, "pre_bdi_6")
+ggplot(ra_bdi_6, aes(x = pre_bdi_6, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 6 (Punishment Feelings) / RA Correlation Graph")
ra_bdi_11 <- ra_bdi %>%
+ select(RA, "pre_bdi_11")
+ggplot(ra_bdi_11, aes(x = pre_bdi_11, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 11 (Agitation) / RA Correlation Graph")
ra_bdi_12 <- ra_bdi %>%
+ select(RA, "pre_bdi_12")
+ggplot(ra_bdi_12, aes(x = pre_bdi_12, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 12 (Loss of Interest) / RA Correlation Graph")
ra_bdi_14 <- ra_bdi %>%
+ select(RA, "pre_bdi_14")
+ggplot(ra_bdi_14, aes(x = pre_bdi_14, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 14 (Worthlessness) / RA Correlation Graph")
ra_bdi_15 <- ra_bdi %>%
+ select(RA, "pre_bdi_15")
+ggplot(ra_bdi_15, aes(x = pre_bdi_15, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 15 (Loss of Energy) / RA Correlation Graph")
ra_bdi_17 <- ra_bdi %>%
+ select(RA, "pre_bdi_17")
+ggplot(ra_bdi_17, aes(x = pre_bdi_17, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 17 (Irritability)c/ RA Correlation Graph")
ra_bdi_20 <- ra_bdi %>%
+ select(RA, "pre_bdi_20")
+ggplot(ra_bdi_20, aes(x = pre_bdi_20, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 20 (Tiredness or Fatigue) / RA Correlation Graph")
ra_bdi_21 <- ra_bdi %>%
+ select(RA, "pre_bdi_21")
+ggplot(ra_bdi_21, aes(x = pre_bdi_21, y = RA)) +
+ geom_point() +
+ ggtitle("BDI 21 (Loss of Interest in Sex) / RA Correlation Graph")
MASQ/RA Correlation Matrix
+ra_masq <- finaldf %>%
+ select (RA, contains("pre_masq"), -pre_masq7, -pre_masq13, -pre_masq17, -pre_masq21, -pre_masq27)
+
+correl_matrix <- data.matrix(ra_masq)
+correl_numeric_matrix <- as.matrix((sapply(ra_masq, as.numeric)))
+
+matrx <- cor(correl_numeric_matrix)
+#round(matrx,2)
+
+corrplot(matrx, method = "color")
MASQ/RA Correlation Graphs
+MASQ General Distress(GD) and Anxious Arousal(AA)
+ra_masq_gd <- ra_masq %>%
+ select(RA, "pre_masq_gd")
+ggplot(ra_masq_gd, aes(x = pre_masq_gd, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ GD / RA Correlation Graph")
ra_masq_aa <- ra_masq %>%
+ select(RA, "pre_masq_aa")
+ggplot(ra_masq_aa, aes(x = pre_masq_aa, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ AA / RA Correlation Graph")
MASQ variables with >0.1 or >-0.1 correlation
+ra_masq_18 <- ra_masq %>%
+ select(RA, "pre_masq18")
+ggplot(ra_masq_18, aes(x = pre_masq18, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ 18 (Had pain in my chest) / RA Correlation Graph")
ra_masq_20 <- ra_masq %>%
+ select(RA, "pre_masq20")
+ggplot(ra_masq_20, aes(x = pre_masq20, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ 20 (Had hot or cold spells) / RA Correlation Graph")
ra_masq_24 <- ra_masq %>%
+ select(RA, "pre_masq24")
+ggplot(ra_masq_24, aes(x = pre_masq24, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ 24 (Muscles were tense or sore) / RA Correlation Graph")
ra_masq_25 <- ra_masq %>%
+ select(RA, "pre_masq25")
+ggplot(ra_masq_25, aes(x = pre_masq25, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ 25 (Had trouble making decisions) / RA Correlation Graph")
ra_masq_30 <- ra_masq %>%
+ select(RA, "pre_masq30")
+ggplot(ra_masq_30, aes(x = pre_masq30, y = RA)) +
+ geom_point() +
+ ggtitle("MASQ 30 (Had trouble swallowing) / RA Correlation Graph")
IDAS/RA Correlation Matrix
+IDAS variables with >0.1 or >-0.1 correlation
+ra_idas <- finaldf %>%
+ select (RA, pre_idas_3, pre_idas_18, pre_idas_22, pre_idas_38, pre_idas_42, pre_idas_49, pre_idas_57, pre_idas_58, pre_idas_60, pre_idas_62, pre_idas_63)
+
+correl_matrix <- data.matrix(ra_idas)
+correl_numeric_matrix <- as.matrix((sapply(ra_idas, as.numeric)))
+
+matrx <- cor(correl_numeric_matrix)
+#round(matrx,2)
+
+corrplot(matrx, method = "color")
IDAS/RA Correlation Graphs
+IDAS variables with >0.1 or >-0.1 correlation
+ra_idas_3 <- ra_idas %>%
+ select(RA, "pre_idas_3")
+ggplot(ra_idas_3, aes(x = pre_idas_3, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 3 (I felt depressed) / RA Correlation Graph")
ra_idas_18 <- ra_idas %>%
+ select(RA, "pre_idas_18")
+ggplot(ra_idas_18, aes(x = pre_idas_18, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 18 (I thought a lot about food) / RA Correlation Graph")
ra_idas_22 <- ra_idas %>%
+ select(RA, "pre_idas_22")
+ggplot(ra_idas_22, aes(x = pre_idas_22, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 22 (I ate more than usual) / RA Correlation Graph")
ra_idas_38 <- ra_idas %>%
+ select(RA, "pre_idas_38")
+ggplot(ra_idas_38, aes(x = pre_idas_38, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 38 (I felt a pain in my chest) / RA Correlation Graph")
ra_idas_42 <- ra_idas %>%
+ select(RA, "pre_idas_42")
+ggplot(ra_idas_42, aes(x = pre_idas_42, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 42 (I had little interest in my usual hobbies or activities) / RA Correlation Graph")
ra_idas_49 <- ra_idas %>%
+ select(RA, "pre_idas_49")
+ggplot(ra_idas_49, aes(x = pre_idas_49, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 49 (I talked more slowly than usual) / RA Correlation Graph")
ra_idas_57 <- ra_idas %>%
+ select(RA, "pre_idas_57")
+ggplot(ra_idas_57, aes(x = pre_idas_57, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 57 (I felt faint) / RA Correlation Graph")
ra_idas_58 <- ra_idas %>%
+ select(RA, "pre_idas_58")
+ggplot(ra_idas_58, aes(x = pre_idas_58, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 58 (I found it difficult to make eye contact with people) / RA Correlation Graph")
ra_idas_60 <- ra_idas %>%
+ select(RA, "pre_idas_60")
+ggplot(ra_idas_60, aes(x = pre_idas_60, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 60 (I got upset thinking about something bad that happened) / RA Correlation Graph")
ra_idas_62 <- ra_idas %>%
+ select(RA, "pre_idas_62")
+ggplot(ra_idas_62, aes(x = pre_idas_62, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 62 (I had a very dry mouth) / RA Correlation Graph")
ra_idas_63 <- ra_idas %>%
+ select(RA, "pre_idas_63")
+ggplot(ra_idas_63, aes(x = pre_idas_63, y = RA)) +
+ geom_point() +
+ ggtitle("IDAS 63 (I was short of breath) / RA Correlation Graph")
SWLS/RA Correlation Matrix
+ra_swls <- finaldf %>%
+ select (RA, starts_with("pre_swls"), -pre_swls2)
+
+correl_matrix <- data.matrix(ra_swls)
+correl_numeric_matrix <- as.matrix((sapply(ra_swls, as.numeric)))
+
+matrx <- cor(correl_numeric_matrix)
+#round(matrx,2)
+
+corrplot(matrx, method = "color")
SWLS/RA Correlation Graphs
+SWLS Total
+ra_swls_total <- ra_swls %>%
+ select(RA, "pre_swls_total")
+ggplot(ra_swls_total, aes(x = pre_swls_total, y = RA)) +
+ geom_point() +
+ ggtitle("SWLS Total / RA Correlation Graph")
SWLS/RA Correlation Graphs
+SWLS variables with >0.1 or >-0.1 correlation
+ra_swls_3 <- ra_swls %>%
+ select(RA, "pre_swls3")
+ggplot(ra_swls_3, aes(x = pre_swls3, y = RA)) +
+ geom_point() +
+ ggtitle("SWLS 3 (I am satisfied with life) / RA Correlation Graph")
ra_swls_4 <- ra_swls %>%
+ select(RA, "pre_swls4")
+ggplot(ra_swls_4, aes(x = pre_swls4, y = RA)) +
+ geom_point() +
+ ggtitle("SWLS 4 (So far I have gotten the important things I want in life) / RA Correlation Graph")
ERQ/RA Correlation Matrix
+ra_erq <- finaldf %>%
+ select (RA, starts_with("pre_erq"))
+
+correl_matrix <- data.matrix(ra_erq)
+correl_numeric_matrix <- as.matrix((sapply(ra_erq, as.numeric)))
+
+matrx <- cor(correl_numeric_matrix)
+#round(matrx,2)
+
+corrplot(matrx, method = "color")
ERQ/RA Correlation Graphs
+ERQ Total Score, Reappraisal, and Suppression
+ra_erq_total <- ra_erq %>%
+ select(RA, "pre_erq_total")
+ggplot(ra_erq_total, aes(x = pre_erq_total, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ Total / RA Correlation Graph")
ra_erq_reappraisal <- ra_erq %>%
+ select(RA, "pre_erq_reappraisal")
+ggplot(ra_erq_reappraisal, aes(x = pre_erq_reappraisal, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ Reappraisal / RA Correlation Graph")
ra_erq_suppression <- ra_erq %>%
+ select(RA, "pre_erq_suppression")
+ggplot(ra_erq_suppression, aes(x = pre_erq_suppression, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ Suppression / RA Correlation Graph")
ERQ/RA Correlation Graphs
+ERQ variables with >0.1 or >-0.1 correlation
+ra_erq_2 <- ra_erq %>%
+ select(RA, "pre_erq_2")
+ggplot(ra_erq_2, aes(x = pre_erq_2, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ 2 (I keep my emotions to myself) / RA Correlation Graph")
ra_erq_4 <- ra_erq %>%
+ select(RA, "pre_erq_4")
+ggplot(ra_erq_4, aes(x = pre_erq_4, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ 4 (When I am feeling positive emotions, I am careful not to express them) / RA Correlation Graph")
ra_erq_6 <- ra_erq %>%
+ select(RA, "pre_erq_6")
+ggplot(ra_erq_6, aes(x = pre_erq_6, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ 6 (I control my emotions by not expressing them) / RA Correlation Graph")
ra_erq_7 <- ra_erq %>%
+ select(RA, "pre_erq_7")
+ggplot(ra_erq_7, aes(x = pre_erq_7, y = RA)) +
+ geom_point() +
+ ggtitle("ERQ 7 (When I want to feel more positive emotion, I change the way I'm thinking about the situation) / RA Correlation Graph")