OSCR

Chronic stress, social support, and domain-specific cognitive decline in HABS-HD.

Code ↔ Paper

2 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 2 matches
  1. [1] § METHODS › Cognitive assessment and diagnostic classification ↔ HABSHD_Github.Rmd, lines 70–84 · score 0.97 · Spanish English Verbal, Mini Mental State, WMS III, Logical Memory, Digit Symbol Substitution, Digit Span
  2. [2] § METHODS › Cognitive assessment and diagnostic classification ↔ HABSHD_Github.Rmd, lines 70–84 · score 0.94 · WMS III Logical, WMS III Digit, Delayed Recall, Immediate Recall, Digit Symbol Substitution, Digit Span

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R Markdown · 1,568 lines · 60 KB · no license · 2 matches

  1. ---
  2. title: "HABS-HD_2026 - Github"
  3. output: html_document
  4. date: "2026-05-01"
  5. ---
  6. ######CLEANING STEPS#######
  7. #Removing those with dementia at baseline (N=243) and all their subsequent visits
  8. ```{r}
  9. library(dplyr)
  10. # Find Med_IDs with CDX_Cog == 2 at Visit_ID == 1
  11. ids_to_remove <- df %>%
  12. filter(Visit_ID == 1, CDX_Cog == 2) %>%
  13. pull(Med_ID)
  14. # Remove all rows for these Med_IDs (all visits)
  15. df_nodementia <- df %>%
  16. filter(!Med_ID %in% ids_to_remove)
  17. #View(df_nodementia)
  18. #N=6360
  19. ```
  20. #Setting factors for comorbidities
  21. ```{r}
  22. # Convert gender to factor and relevel
  23. #IMH_Diabetes
  24. df_nodementia$Baseline_IMH_Diabetes <- factor(
  25. df_nodementia$Baseline_IMH_Diabetes,
  26. levels = c(0, 1),
  27. labels = c("No", "Yes")
  28. )
  29. df_nodementia$Baseline_IMH_Diabetes <- relevel(
  30. df_nodementia$Baseline_IMH_Diabetes, ref = "No"
  31. )
  32. #IMH_HeartAttack
  33. df_nodementia$Baseline_IMH_HeartAttack<- factor(
  34. df_nodementia$Baseline_IMH_HeartAttack,
  35. levels = c(0, 1),
  36. labels = c("No", "Yes")
  37. )
  38. df_nodementia$Baseline_IMH_HeartAttack <- relevel(
  39. df_nodementia$Baseline_IMH_HeartAttack, ref = "No"
  40. )
  41. #IMH_KidneyDisease
  42. df_nodementia$Baseline_IMH_KidneyDisease<- factor(
  43. df_nodementia$Baseline_IMH_KidneyDisease,
  44. levels = c(0, 1),
  45. labels = c("No", "Yes")
  46. )
  47. df_nodementia$Baseline_IMH_KidneyDisease <- relevel(
  48. df_nodementia$Baseline_IMH_KidneyDisease, ref = "No"
  49. )
  50. #IMH_Stroke
  51. df_nodementia$Baseline_IMH_Stroke<- factor(
  52. df_nodementia$Baseline_IMH_Stroke,
  53. levels = c(0, 1),
  54. labels = c("No", "Yes")
  55. )
  56. df_nodementia$Baseline_IMH_Stroke<- relevel(
  57. df_nodementia$Baseline_IMH_Stroke, ref = "No"
  58. )
  59. #View(df_nodementia)
  60. ```
  61. #Creating Cognitive Domains
  62. ```{r}
  63. #Global: Mini-Mental State Examination (MMSE)
  64. #Attention: WMS-III Digit Span, Trail Making Test A
  65. #Memory: Spanish-English Verbal Learning Test (SEVLT, Immediate Recall & Delayed Recall); WMS-III Logical Memory (Immediate & Delayed)
  66. #Executive: Digit Symbol Substitution, Trail Making Test B
  67. #Language: Animal Naming, FAS
  68. df_nodementia$AttentionDomain <- rowMeans(df_nodementia[, c("DS_ZScore", "Trails_A_ZScore")], na.rm = TRUE)
  69. df_nodementia$MemoryDomain <- rowMeans(df_nodementia[, c("SEVLT_T1235_ZScore", "SEVLT_DR_ZScore" , "LM1_AB_ZScore", "LM2_AB_ZScore")], na.rm = TRUE)
  70. df_nodementia$ExecutiveDomain <- rowMeans(df_nodementia[, c("Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore")], na.rm = TRUE)
  71. df_nodementia$LanguageDomain <- rowMeans(df_nodementia[, c("FAS_ZScore" , "Animal_ZScore")], na.rm = TRUE)
  72. #View(df_nodementia)
  73. ```
  74. #Creating Baseline Dataset
  75. ```{r}
  76. Baseline_df_nodementia <- df_nodementia %>%
  77. filter(Visit_ID == 1)
  78. #View(Baseline_df_nodementia )
  79. #3875
  80. ```
  81. #Downloading and Saving BaselineSheet
  82. ```{r}
  83. library(writexl)
  84. write_xlsx(Baseline_df_nodementia, "Baseline_df_nodementia.xlsx")
  85. ```
  86. #Renaming Baseline Variables
  87. ```{r}
  88. Baseline_df_nodementia <- Baseline_df_nodementia %>%
  89. # Add Baseline_ prefix to a long list of variables
  90. rename_with(.fn = ~paste0("Baseline_", .),
  91. .cols = c(
  92. Visit_ID, Visit_Date, Ethnicity, Age, ID_Gender, ID_Education, CDX_Cog, PSWQ_Total,
  93. SocialSupport_Total, ChronicStress_Total, GDS_Total,
  94. SEVLT_T1235_ZScore, SEVLT_DR_ZScore, LM1_AB_ZScore, LM2_AB_ZScore,
  95. Digit_Symbol_Substitution_ZScore, Trails_B_ZScore,
  96. FAS_ZScore, Animal_ZScore,
  97. CDP_Myocardial, CDP_HeartDisease, CDP_Stroke, CDP_MiniStroke, CDR_Sum, CDR_Global, MMSE_Total,
  98. PSWQ_1, PSWQ_2, PSWQ_3, PSWQ_4, PSWQ_5, PSWQ_6, PSWQ_7, PSWQ_8, PSWQ_9, PSWQ_10, PSWQ_11, PSWQ_12, PSWQ_13, PSWQ_14, PSWQ_15, PSWQ_16,
  99. SocialSupport_1, SocialSupport_2, SocialSupport_3, SocialSupport_4, SocialSupport_5, SocialSupport_6, SocialSupport_7, SocialSupport_8, SocialSupport_9,
  100. SocialSupport_10, SocialSupport_11, SocialSupport_12,
  101. ChronicStress_1, ChronicStress_1a, ChronicStress_1b, ChronicStress_2, ChronicStress_2a, ChronicStress_2b, ChronicStress_3, ChronicStress_3a, ChronicStress_3b,
  102. ChronicStress_4, ChronicStress_4a, ChronicStress_4b, ChronicStress_5, ChronicStress_5a, ChronicStress_5b, ChronicStress_6, ChronicStress_6a, ChronicStress_6b,
  103. ChronicStress_7, ChronicStress_7a, ChronicStress_7b, ChronicStress_8, ChronicStress_8a, ChronicStress_8b, ChronicStress_8c,
  104. SEVLT_T1_Total, SEVLT_T2_Total, SEVLT_T3_Total, SEVLT_T5_Total, SEVLT_T1235_Total, SEVLT_DR_Total,
  105. LM1_A_Total, LM1_B1_Total, LM1_B2_Total, LM1_AB_Total, LM2_A_Total, LM2_B_Total, LM2_AB_Total,
  106. DSF_Total, DSB_Total, DS_Total, DS_ZScore,
  107. Trails_A_Time, Trails_A_Errors, Trails_A_ZScore, Trails_B_Time, Trails_B_Errors, FAS_Total,
  108. GDS_Category, GDS_Score_D, GDS_Score_M, GDS_Score_A, GDS_Score_C,
  109. Animal_Total, Digit_Symbol_Substitution,
  110. CDX_Hypertension, CDX_Dyslipidemia, CDX_Diabetes, CDX_Hyperthyroid, CDX_Hypothyroid, CDX_CVD, CDX_Anemia, CDX_VitaminB12, CDX_Depression,
  111. CDX_Anxiety, CDX_Alcohol, CDX_Tobacco,
  112. AttentionDomain, MemoryDomain, ExecutiveDomain, LanguageDomain
  113. )
  114. )
  115. #View(Baseline_df_nodementia)
  116. ```
  117. #Merging back Baselinesheet with Full longitudinal sheet
  118. ```{r}
  119. library(dplyr)
  120. # Step 1: Merge baseline data into longitudinal follow-up dataset by Med_ID
  121. FULLMERGE_df_nodementia <- df_nodementia %>%
  122. left_join(
  123. Baseline_df_nodementia,
  124. by = "Med_ID"
  125. )
  126. #View(FULLMERGE_RP_HD_7_Clinical_Cleaned_071025_nodementia)
  127. #6354
  128. ```
  129. #Creating the time variable
  130. ```{r}
  131. FULLMERGE_df_nodementia <- FULLMERGE_df_nodementia %>%
  132. mutate(Time = Age - Baseline_Age)
  133. #View(FULLMERGE_df_nodementia)
  134. ```
  135. ##Table 1 - Baseline Demographics of Participants
  136. ```{r}
  137. # Open a file to save the output
  138. #sink("Table1_Cognition_Release7_Baseline_080525.txt")
  139. # Load the required package
  140. library(tableone)
  141. # Create the table for Visit_ID 1 (Baseline)
  142. Table1_Cognition_Release7_Baseline_080525 <- CreateTableOne(
  143. data = Baseline_df_nodementia, # Use the filtered data for baseline
  144. vars = c("Med_ID", "Baseline_Age", "Baseline_Ethnicity", "Baseline_ID_Gender", "Baseline_ID_Education",
  145. "Baseline_PSWQ_Total", "Baseline_GDS_Total", "Baseline_CDX_Cog", "Baseline_SocialSupport_Total",
  146. "Baseline_ChronicStress_Total",
  147. "Baseline_IMH_Diabetes", "Baseline_IMH_HeartAttack", "Baseline_IMH_KidneyDisease", "Baseline_IMH_Stroke", "Baseline_OM_BMI",
  148. "Baseline_AttentionDomain", "Baseline_MemoryDomain", "Baseline_LanguageDomain", "Baseline_ExecutiveDomain"),
  149. test = TRUE,
  150. includeNA = TRUE
  151. )
  152. # Print the table to the output file
  153. print(Table1_Cognition_Release7_Baseline_080525)
  154. # Close the sink (finish writing to the file)
  155. #sink()
  156. ```
  157. #eTable 1 - Baseline Demographics of participants; Stratified by Gender
  158. ```{r}
  159. # Table 1 Stratified by Gender --------------------------------------------
  160. # Set the output file name
  161. output_file <- "Table1_BaselineDemographics_strgender_Release7_CognitiveDomains_UPDATED080525.txt"
  162. #sink(output_file)
  163. table1_STRGender_UPDATED080525 <- CreateTableOne(
  164. data = Baseline_df_nodementia,
  165. vars = c("Med_ID", "Baseline_Age", "Baseline_Ethnicity", "Baseline_ID_Education",
  166. "Baseline_PSWQ_Total", "Baseline_GDS_Total", "Baseline_CDX_Cog", "Baseline_SocialSupport_Total",
  167. "Baseline_ChronicStress_Total",
  168. "Baseline_IMH_Diabetes", "Baseline_IMH_HeartAttack", "Baseline_IMH_KidneyDisease", "Baseline_IMH_Stroke", "Baseline_OM_BMI",
  169. "Baseline_AttentionDomain", "Baseline_MemoryDomain", "Baseline_LanguageDomain", "Baseline_ExecutiveDomain"),
  170. strata = "Baseline_ID_Gender",
  171. test = TRUE,
  172. includeNA = TRUE
  173. )
  174. # Print the updated table
  175. print(table1_STRGender_UPDATED080525)
  176. #sink()
  177. ```
  178. #eTable 2 - Baseline Demographics of participants; Stratified by Race/Ethnicity
  179. ```{r}
  180. # Table 1 Stratified by Race --------------------------------------------
  181. # Set the output file name
  182. output_file <- "Table1_BaselineDemographics_strrace_Release7_CognitiveDomains_UPDATED080525.txt"
  183. sink(output_file)
  184. table1_STRRace_UPDATED080525 <- CreateTableOne(
  185. data = Baseline_df_nodementia,
  186. vars = c("Med_ID", "Baseline_Age", "Baseline_ID_Gender", "Baseline_ID_Education",
  187. "Baseline_PSWQ_Total", "Baseline_GDS_Total", "Baseline_CDX_Cog", "Baseline_SocialSupport_Total",
  188. "Baseline_ChronicStress_Total",
  189. "Baseline_IMH_Diabetes", "Baseline_IMH_HeartAttack", "Baseline_IMH_KidneyDisease", "Baseline_IMH_Stroke", "Baseline_OM_BMI",
  190. "Baseline_AttentionDomain", "Baseline_MemoryDomain", "Baseline_LanguageDomain", "Baseline_ExecutiveDomain"),
  191. strata = "Baseline_Ethnicity",
  192. test = TRUE,
  193. includeNA = TRUE
  194. )
  195. # Print the updated table
  196. print(table1_STRRace_UPDATED080525)
  197. sink()
  198. ```
  199. ##Setting reference groups for gender & race/ethnicity
  200. ```{r}
  201. # Convert to an unordered factor
  202. FULLMERGE_df_nodementia$Baseline_ID_Gender <- as.factor(FULLMERGE_df_nodementia$Baseline_ID_Gender)
  203. # Relevel to make "Non-Hispanic White" the reference group
  204. FULLMERGE_df_nodementia$Baseline_ID_Gender <- relevel(FULLMERGE_df_nodementia$Baseline_ID_Gender, ref = "Males")
  205. FULLMERGE_df_nodementia$Baseline_Ethnicity <- as.factor(FULLMERGE_df_nodementia$Baseline_Ethnicity)
  206. # Relevel to make "Non-Hispanic White" the reference group
  207. FULLMERGE_df_nodementia$Baseline_Ethnicity <- relevel(FULLMERGE_df_nodementia$Baseline_Ethnicity, ref = "White")
  208. ```
  209. ###Mixed Effects Model###
  210. ####CHRONIC STRESS#####
  211. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Unadjusted)
  212. #eTable 4 - Longitudinal Associations of Baseline Chronic Stress and Domain-Specific Cognitive Z-scores (Unadjusted)
  213. ##Chronic Stress - Unadjusted
  214. ```{r}
  215. library(dplyr)
  216. #library(lme4)
  217. library(lmerTest) #this package prints p values
  218. #sink("Mixed_Effect_Models_071225_ChronicStress_lme4_pvaluesUPDATED072125.txt")
  219. # Define the cognitive domain variables to loop through
  220. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  221. # Create an empty list to store the models
  222. models_chronicstress_unadjusted <- list()
  223. # Loop through the domains and fit the linear mixed-effects model for each
  224. for (domain in domains) {
  225. # Define the formula dynamically for each domain
  226. formula <- as.formula(paste(domain, "~ Baseline_ChronicStress_Total + Time + Baseline_ChronicStress_Total*Time + (1 | Med_ID)"))
  227. # Fit the linear mixed-effects model
  228. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  229. # Store the model in the list (use the correct list name here)
  230. models_chronicstress_unadjusted [[domain]] <- model
  231. # Optionally, print the summary of the model
  232. print(paste("Model for", domain))
  233. print(summary(model))
  234. }
  235. #sink()
  236. ```
  237. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Partial adjusted)
  238. #eTable 4 - Longitudinal Associations of Baseline Chronic Stress and Domain-Specific Cognitive Z-scores (Partial Adjusted)
  239. ##Chronic Stress - Partial Adjusted
  240. ```{r}
  241. library(dplyr)
  242. library(lme4)
  243. library(lmerTest) #this package prints p values
  244. #sink("Mixed_Effect_Models_071225_ChronicStress_adjusted_w_depression_lme4_pvalues_UPDATED072725.txt")
  245. # Define the cognitive domain variables to loop through
  246. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  247. # Create an empty list to store the models
  248. models_chronicstress_partialadjusted <- list()
  249. # Loop through the domains and fit the linear mixed-effects model for each
  250. for (domain in domains) {
  251. # Define the formula dynamically for each domain
  252. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_ChronicStress_Total + Time + Baseline_ChronicStress_Total*Time + (1 | Med_ID)"))
  253. # Fit the linear mixed-effects model
  254. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  255. # Store the model in the list (use the correct list name here)
  256. models_chronicstress_partialadjusted [[domain]] <- model
  257. # Optionally, print the summary of the model
  258. print(paste("Model for", domain))
  259. print(summary(model))
  260. }
  261. #sink()
  262. ```
  263. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Fully adjusted)
  264. #eTable 4 - Longitudinal Associations of Baseline Chronic Stress and Domain-Specific Cognitive Z-scores (Fully Adjusted)
  265. ##Chronic Stress - Fully Adjusted
  266. ```{r}
  267. library(dplyr)
  268. library(lme4)
  269. library(lmerTest) #this package prints p values
  270. #sink("Mixed_Effect_Models_071225_ChronicStress_fullyadjusted_lme4_pvalues_UPDATED072725.txt")
  271. # Define the cognitive domain variables to loop through
  272. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  273. # Create an empty list to store the models
  274. models_chronicstress_fullyadjusted <- list()
  275. # Loop through the domains and fit the linear mixed-effects model for each
  276. for (domain in domains) {
  277. # Define the formula dynamically for each domain
  278. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Time + Baseline_ChronicStress_Total*Time + (1 | Med_ID)"))
  279. # Fit the linear mixed-effects model
  280. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  281. # Store the model in the list (use the correct list name here)
  282. models_chronicstress_fullyadjusted[[domain]] <- model
  283. # Optionally, print the summary of the model
  284. print(paste("Model for", domain))
  285. print(summary(model))
  286. }
  287. #sink()
  288. ```
  289. ###Mixed Effects Model###
  290. ####SOCIAL SUPPORT#####
  291. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Unadjusted)
  292. #eTable 7 - Longitudinal Associations of Baseline Chronic Stress and Domain-Specific Cognitive Z-scores (Unadjusted)
  293. ##Social Support- Unadjusted
  294. ```{r}
  295. library(dplyr)
  296. library(lme4)
  297. library(lmerTest) #this package prints p values
  298. #sink("Mixed_Effect_Models_071225_SocialSupport_lme4_pvalues_UPDATED071625.txt")
  299. # Define the cognitive domain variables to loop through
  300. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  301. # Create an empty list to store the models
  302. models_socialsupport_unadjusted<- list()
  303. # Loop through the domains and fit the linear mixed-effects model for each
  304. for (domain in domains) {
  305. # Define the formula dynamically for each domain
  306. formula <- as.formula(paste(domain, "~ Baseline_SocialSupport_Total + Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  307. # Fit the linear mixed-effects model
  308. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  309. # Store the model in the list (use the correct list name here)
  310. models_socialsupport_unadjusted[[domain]] <- model
  311. # Optionally, print the summary of the model
  312. print(paste("Model for", domain))
  313. print(summary(model))
  314. }
  315. #sink()
  316. ```
  317. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Partial adjusted)
  318. #eTable 7 - Longitudinal Associations of Baseline Chronic Stress and Domain-Specific Cognitive Z-scores (Partial adjusted)
  319. ##Social Support- Partial Adjusted
  320. ```{r}
  321. library(dplyr)
  322. library(lme4)
  323. library(lmerTest) #this package prints p values
  324. sink("Mixed_Effect_Models_071225_SocialSupport_adjusted_w_depression_lme4_pvalues_UPDATED072725.txt")
  325. # Define the cognitive domain variables to loop through
  326. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  327. # Create an empty list to store the models
  328. models_socialsupport_partialadjusted <- list()
  329. # Loop through the domains and fit the linear mixed-effects model for each
  330. for (domain in domains) {
  331. # Define the formula dynamically for each domain
  332. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_SocialSupport_Total + Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  333. # Fit the linear mixed-effects model
  334. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  335. # Store the model in the list (use the correct list name here)
  336. models_socialsupport_partialadjusted[[domain]] <- model
  337. # Optionally, print the summary of the model
  338. print(paste("Model for", domain))
  339. print(summary(model))
  340. }
  341. sink()
  342. ```
  343. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Fully adjusted)
  344. #eTable 7 - Longitudinal Associations of Baseline Chronic Stress and Domain-Specific Cognitive Z-scores (Fully adjusted)
  345. ##Social Support- Fully Adjusted
  346. ```{r}
  347. library(dplyr)
  348. library(lme4)
  349. library(lmerTest) #this package prints p values
  350. sink("Mixed_Effect_Models_071225_SocialSupport_fullyadjusted_lme4_pvalues_UPDATED072725.txt")
  351. # Define the cognitive domain variables to loop through
  352. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  353. # Create an empty list to store the models
  354. models_socialsupport_fullyadjusted <- list()
  355. # Loop through the domains and fit the linear mixed-effects model for each
  356. for (domain in domains) {
  357. # Define the formula dynamically for each domain
  358. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_SocialSupport_Total + Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  359. # Fit the linear mixed-effects model
  360. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  361. # Store the model in the list (use the correct list name here)
  362. models_socialsupport_fullyadjusted[[domain]] <- model
  363. # Optionally, print the summary of the model
  364. print(paste("Model for", domain))
  365. print(summary(model))
  366. }
  367. sink()
  368. ```
  369. ####INTERACTION TERMS###
  370. #####CHRONIC STRESS######
  371. ##GENDER##
  372. #eTable 5- Interaction between Baseline Chronic Stress and Gender in relation to Domain-Specific Cognitive Z-scores (Unadjusted)
  373. #CS*GENDER*Time (Unadjusted)
  374. ```{r}
  375. ##Chronic Stress - Unadjusted - Interaction with Gender
  376. #_UPDATED071625
  377. library(dplyr)
  378. library(lmerTest) #this package prints p values
  379. sink("Mixed_Effect_Models_071225_Release7_ChronicStress_unadjustedgender_UPDATED071625.txt")
  380. # Define the cognitive domain variables to loop through
  381. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  382. # Create an empty list to store the models
  383. models_chronicstress_unadjusted_interactiongender <- list()
  384. # Loop through the domains and fit the linear mixed-effects model for each
  385. for (domain in domains) {
  386. # Define the formula dynamically for each domain
  387. formula <- as.formula(paste(domain, "~ Baseline_ChronicStress_Total + Baseline_ID_Gender + Time + Baseline_ChronicStress_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  388. # Fit the linear mixed-effects model
  389. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  390. # Store the model in the list (use the correct list name here)
  391. models_chronicstress_unadjusted_interactiongender[[domain]] <- model
  392. # Optionally, print the summary of the model
  393. print(paste("Model for", domain))
  394. print(summary(model))
  395. }
  396. sink()
  397. ```
  398. #eTable 5- Interaction between Baseline Chronic Stress and Gender in relation to Domain-Specific Cognitive Z-scores (Partial Adjusted)
  399. #CS*GENDER*Time (Partial Adjusted)
  400. ```{r}
  401. ##Chronic Stress - Adjusted - Interaction with Gender
  402. library(dplyr)
  403. library(lmerTest) #this package prints p values
  404. sink("Mixed_Effect_Models_071225_Release7_ChronicStress_adjustedgender_partialadjusted_UPDATED073025.txt")
  405. # Define the cognitive domain variables to loop through
  406. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  407. # Create an empty list to store the models
  408. models_chronicstress_partialadjusted_interactiongender <- list()
  409. # Loop through the domains and fit the linear mixed-effects model for each
  410. for (domain in domains) {
  411. # Define the formula dynamically for each domain
  412. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_ChronicStress_Total + Baseline_ID_Gender + Time + Baseline_ChronicStress_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  413. # Fit the linear mixed-effects model
  414. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  415. # Store the model in the list (use the correct list name here)
  416. models_chronicstress_partialadjusted_interactiongender[[domain]] <- model
  417. # Optionally, print the summary of the model
  418. print(paste("Model for", domain))
  419. print(summary(model))
  420. }
  421. sink()
  422. ```
  423. #eTable 5- Interaction between Baseline Chronic Stress and Gender in relation to Domain-Specific Cognitive Z-scores (Fully Adjusted)
  424. #CS*GENDER*Time (Fully Adjusted)
  425. ```{r}
  426. ##Chronic Stress - Adjusted - Interaction with Gender
  427. library(dplyr)
  428. library(lmerTest) #this package prints p values
  429. sink("Mixed_Effect_Models_071225_Release7_ChronicStress_adjustedgender_fullyadjusted_UPDATED073025.txt")
  430. # Define the cognitive domain variables to loop through
  431. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  432. # Create an empty list to store the models
  433. models_chronicstress_fullyadjusted_interactiongender <- list()
  434. # Loop through the domains and fit the linear mixed-effects model for each
  435. for (domain in domains) {
  436. # Define the formula dynamically for each domain
  437. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_ID_Gender + Time + Baseline_ChronicStress_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  438. # Fit the linear mixed-effects model
  439. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  440. # Store the model in the list (use the correct list name here)
  441. models_chronicstress_fullyadjusted_interactiongender[[domain]] <- model
  442. # Optionally, print the summary of the model
  443. print(paste("Model for", domain))
  444. print(summary(model))
  445. }
  446. sink()
  447. ```
  448. ##RACE##
  449. #Setting White as the reference group
  450. ```{r}
  451. # Convert to an unordered factor
  452. FULLMERGE_df_nodementia$Baseline_Ethnicity <- as.factor(FULLMERGE_df_nodementia$Baseline_Ethnicity)
  453. # Relevel to make "Non-Hispanic White" the reference group
  454. FULLMERGE_df_nodementia$Baseline_Ethnicity <- relevel(FULLMERGE_df_nodementia$Baseline_Ethnicity, ref = "White")
  455. ```
  456. #eTable 6 - Interaction between Baseline Chronic Stress and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores (Unadjusted)
  457. #CS*Race*Time (unadjusted)
  458. ```{r}
  459. ##Chronic Stress - Unadjusted - Interaction with Race
  460. library(dplyr)
  461. library(lmerTest) #this package prints p values
  462. sink("Mixed_Effect_Models_071225_ChronicStress_unadjustedrace_r7_UPDATED071625.txt")
  463. # Define the cognitive domain variables to loop through
  464. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  465. # Create an empty list to store the models
  466. models_chronicstress_unadjusted_interactionrace <- list()
  467. # Loop through the domains and fit the linear mixed-effects model for each
  468. for (domain in domains) {
  469. # Define the formula dynamically for each domain
  470. formula <- as.formula(paste(domain, "~ Baseline_ChronicStress_Total + Baseline_Ethnicity + Time + Baseline_ChronicStress_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  471. # Fit the linear mixed-effects model
  472. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  473. # Store the model in the list (use the correct list name here)
  474. models_chronicstress_unadjusted_interactionrace[[domain]] <- model
  475. # Optionally, print the summary of the model
  476. print(paste("Model for", domain))
  477. print(summary(model))
  478. }
  479. sink()
  480. ```
  481. #eTable 6 - Interaction between Baseline Chronic Stress and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores (Partial Adjusted)
  482. #CS*Race*Time (Partial Adjusted)
  483. ```{r}
  484. ##Chronic Stress - Partially Adjusted w. Depression - Interaction with Race
  485. library(dplyr)
  486. library(lmerTest) #this package prints p values
  487. sink("Mixed_Effect_Models_073025_ChronicStress_partialadjustedrace_r7_UPDATED073025.txt")
  488. # Define the cognitive domain variables to loop through
  489. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  490. # Create an empty list to store the models
  491. models_chronicstress_partialadjusted_interactionrace <- list()
  492. # Loop through the domains and fit the linear mixed-effects model for each
  493. for (domain in domains) {
  494. # Define the formula dynamically for each domain
  495. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_PSWQ_Total + Baseline_ID_Gender + Baseline_GDS_Total + Baseline_ChronicStress_Total + Baseline_Ethnicity + Time + Baseline_ChronicStress_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  496. # Fit the linear mixed-effects model
  497. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  498. # Store the model in the list (use the correct list name here)
  499. models_chronicstress_partialadjusted_interactionrace[[domain]] <- model
  500. # Optionally, print the summary of the model
  501. print(paste("Model for", domain))
  502. print(summary(model))
  503. }
  504. sink()
  505. ```
  506. #eTable 6 - Interaction between Baseline Chronic Stress and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores (Fully Adjusted)
  507. #CS*Race*Time (Fully Adjusted)
  508. ```{r}
  509. ##Chronic Stress - Fully Adjusted - Interaction with Race
  510. library(dplyr)
  511. library(lmerTest) #this package prints p values
  512. sink("Mixed_Effect_Models_073025_ChronicStress_fullyadjustedrace_r7_UPDATED073025.txt")
  513. # Define the cognitive domain variables to loop through
  514. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  515. # Create an empty list to store the models
  516. models_chronicstress_fullyjusted_interactionrace <- list()
  517. # Loop through the domains and fit the linear mixed-effects model for each
  518. for (domain in domains) {
  519. # Define the formula dynamically for each domain
  520. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_PSWQ_Total + Baseline_ID_Gender + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_Ethnicity + Time + Baseline_ChronicStress_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  521. # Fit the linear mixed-effects model
  522. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  523. # Store the model in the list (use the correct list name here)
  524. models_chronicstress_fullyjusted_interactionrace[[domain]] <- model
  525. # Optionally, print the summary of the model
  526. print(paste("Model for", domain))
  527. print(summary(model))
  528. }
  529. sink()
  530. ```
  531. ####INTERACTION TERMS###
  532. #####SOCIAL SUPPORT######
  533. ##GENDER##
  534. #eTable 8 - Interaction between Baseline Social Support and Gender in relation to Domain-Specific Cognitive Z-scores (Unadjusted)
  535. #SS*GENDER*Time (unadjusted)
  536. ```{r}
  537. ##Social Support - Unadjusted - Interaction with Gender
  538. library(dplyr)
  539. library(lmerTest) #this package prints p values
  540. sink("Mixed_Effect_Models_071225_Release7_SocialSupport_unadjustedgender_UPDATED071625.txt")
  541. # Define the cognitive domain variables to loop through
  542. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  543. # Create an empty list to store the models
  544. models_socialsupport_unadjusted_interactiongender<- list()
  545. # Loop through the domains and fit the linear mixed-effects model for each
  546. for (domain in domains) {
  547. # Define the formula dynamically for each domain
  548. formula <- as.formula(paste(domain, "~ Baseline_SocialSupport_Total + Baseline_ID_Gender + Time + Baseline_SocialSupport_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  549. # Fit the linear mixed-effects model
  550. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  551. # Store the model in the list (use the correct list name here)
  552. models_socialsupport_unadjusted_interactiongender[[domain]] <- model
  553. # Optionally, print the summary of the model
  554. print(paste("Model for", domain))
  555. print(summary(model))
  556. }
  557. sink()
  558. ```
  559. #eTable 8 - Interaction between Baseline Social Support and Gender in relation to Domain-Specific Cognitive Z-scores (Partial Adjusted)
  560. #SS*GENDER*Time (Partial Adjusted)
  561. ```{r}
  562. ##Social Support - Adjusted - Interaction with Gender
  563. library(dplyr)
  564. library(lmerTest) #this package prints p values
  565. sink("Mixed_Effect_Models_Release7_SocialSupport_partialadjustedgender_UPDATED080525.txt")
  566. # Define the cognitive domain variables to loop through
  567. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  568. # Create an empty list to store the models
  569. models_socialsupport_partialadjusted_interactiongender <- list()
  570. # Loop through the domains and fit the linear mixed-effects model for each
  571. for (domain in domains) {
  572. # Define the formula dynamically for each domain
  573. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_SocialSupport_Total + Baseline_ID_Gender + Time + Baseline_SocialSupport_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  574. # Fit the linear mixed-effects model
  575. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  576. # Store the model in the list (use the correct list name here)
  577. models_socialsupport_partialadjusted_interactiongender[[domain]] <- model
  578. # Optionally, print the summary of the model
  579. print(paste("Model for", domain))
  580. print(summary(model))
  581. }
  582. sink()
  583. ```
  584. #eTable 8 - Interaction between Baseline Social Support and Gender in relation to Domain-Specific Cognitive Z-scores (Fully Adjusted)
  585. #SS*GENDER*Time (Fully Adjusted)
  586. ```{r}
  587. ##Social Support - Adjusted - Interaction with Gender
  588. library(dplyr)
  589. library(lmerTest) #this package prints p values
  590. sink("Mixed_Effect_Models_Release7_SocialSupport_fullyadjustedgender_UPDATED080525.txt")
  591. # Define the cognitive domain variables to loop through
  592. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  593. # Create an empty list to store the models
  594. models_socialsupport_fullyadjusted_interactiongender <- list()
  595. # Loop through the domains and fit the linear mixed-effects model for each
  596. for (domain in domains) {
  597. # Define the formula dynamically for each domain
  598. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_SocialSupport_Total + Baseline_ID_Gender + Time + Baseline_SocialSupport_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  599. # Fit the linear mixed-effects model
  600. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  601. # Store the model in the list (use the correct list name here)
  602. models_socialsupport_fullyadjusted_interactiongender[[domain]] <- model
  603. # Optionally, print the summary of the model
  604. print(paste("Model for", domain))
  605. print(summary(model))
  606. }
  607. sink()
  608. ```
  609. ##RACE###
  610. #eTable 9 - Interaction between Baseline Social Support and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores (unadjusted)
  611. #SS*Race*Time (unadjusted)
  612. ```{r}
  613. ##Social Support - Unadjusted - Interaction with Race
  614. library(dplyr)
  615. library(lmerTest) #this package prints p values
  616. sink("Mixed_Effect_Models_071225_SocialSupport_unadjustedrace_r7_UPDATED071625.txt")
  617. # Define the cognitive domain variables to loop through
  618. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  619. # Create an empty list to store the models
  620. models_socialsupport_unadjusted_interactionrace <- list()
  621. # Loop through the domains and fit the linear mixed-effects model for each
  622. for (domain in domains) {
  623. # Define the formula dynamically for each domain
  624. formula <- as.formula(paste(domain, "~ Baseline_SocialSupport_Total + Baseline_Ethnicity + Time + Baseline_SocialSupport_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  625. # Fit the linear mixed-effects model
  626. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  627. # Store the model in the list (use the correct list name here)
  628. models_socialsupport_unadjusted_interactionrace[[domain]] <- model
  629. # Optionally, print the summary of the model
  630. print(paste("Model for", domain))
  631. print(summary(model))
  632. }
  633. sink()
  634. ```
  635. #eTable 9 - Interaction between Baseline Social Support and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores (Partial Adjusted)
  636. #SS*Race*Time (Partial Adjusted)
  637. ```{r}
  638. ##Social Support - Unadjusted - Interaction with Race
  639. library(dplyr)
  640. library(lmerTest) #this package prints p values
  641. sink("Mixed_Effect_Models_SocialSupport_partiallyadjustedrace_r7_UPDATED080525.txt")
  642. # Define the cognitive domain variables to loop through
  643. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  644. # Create an empty list to store the models
  645. models_socialsupport_partiallyadjusted_interactionrace <- list()
  646. # Loop through the domains and fit the linear mixed-effects model for each
  647. for (domain in domains) {
  648. # Define the formula dynamically for each domain
  649. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_ID_Gender + Baseline_SocialSupport_Total + Baseline_Ethnicity + Time + Baseline_SocialSupport_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  650. # Fit the linear mixed-effects model
  651. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  652. # Store the model in the list (use the correct list name here)
  653. models_socialsupport_partiallyadjusted_interactionrace[[domain]] <- model
  654. # Optionally, print the summary of the model
  655. print(paste("Model for", domain))
  656. print(summary(model))
  657. }
  658. sink()
  659. ```
  660. #eTable 9 - Interaction between Baseline Social Support and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores (Fully Adjusted)
  661. #SS*Race*Time (Fully Adjusted)
  662. ```{r}
  663. ##Social Support - Unadjusted - Interaction with Race
  664. library(dplyr)
  665. library(lmerTest) #this package prints p values
  666. sink("Mixed_Effect_Models_SocialSupport_fullyadjustedrace_r7_UPDATED080525.txt")
  667. # Define the cognitive domain variables to loop through
  668. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  669. # Create an empty list to store the models
  670. models_socialsupport_fullyadjusted_interactionrace<- list()
  671. # Loop through the domains and fit the linear mixed-effects model for each
  672. for (domain in domains) {
  673. # Define the formula dynamically for each domain
  674. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ID_Gender + Baseline_SocialSupport_Total + Baseline_Ethnicity + Time + Baseline_SocialSupport_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  675. # Fit the linear mixed-effects model
  676. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  677. # Store the model in the list (use the correct list name here)
  678. models_socialsupport_fullyadjusted_interactionrace[[domain]] <- model
  679. # Optionally, print the summary of the model
  680. print(paste("Model for", domain))
  681. print(summary(model))
  682. }
  683. sink()
  684. ```
  685. #####CHRONIC STRESS & SOCIAL SUPPORT - COMBINATION MODEL######
  686. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Unadjusted)
  687. #eTable 10 - Interrelationship of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Unadjusted)
  688. ##Chronic Stress & Social Support (Combination Model) (Unadjusted)
  689. ```{r}
  690. library(dplyr)
  691. library(lmerTest) #this package prints p values
  692. sink("Mixed_Effect_Models_071225_CS_SS_samemodel_unadjusted_Updated072125.txt")
  693. # Define the cognitive domain variables to loop through
  694. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  695. options(scipen = 999)
  696. # Create an empty list to store the models
  697. models_cs_ss_unadjusted <- list()
  698. # Loop through the domains and fit the linear mixed-effects model for each
  699. for (domain in domains) {
  700. # Define the formula dynamically for each domain
  701. formula <- as.formula(paste(domain, "~ Baseline_ChronicStress_Total + Baseline_SocialSupport_Total + Time + Baseline_ChronicStress_Total*Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  702. # Fit the linear mixed-effects model
  703. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  704. # Store the model in the list (use the correct list name here)
  705. models_cs_ss_unadjusted[[domain]] <- model
  706. # Optionally, print the summary of the model
  707. print(paste("Model for", domain))
  708. print(summary(model))
  709. }
  710. sink()
  711. ```
  712. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Partial Adjusted)
  713. #eTable 10 - Interrelationship of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Partial Adjusted)
  714. ##Chronic Stress & Social Support (Combination Model) (Partial Adjusted)
  715. ```{r}
  716. library(dplyr)
  717. library(lmerTest) #this package prints p values
  718. sink("Mixed_Effect_Models_CS_SS_samemodel_adjusted_w_Depression_Updated072725.txt")
  719. # Define the cognitive domain variables to loop through
  720. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  721. options(scipen = 999)
  722. # Create an empty list to store the models
  723. models_cs_ss_partialadjusted <- list()
  724. # Loop through the domains and fit the linear mixed-effects model for each
  725. for (domain in domains) {
  726. # Define the formula dynamically for each domain
  727. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_ChronicStress_Total + Baseline_SocialSupport_Total + Time + Baseline_ChronicStress_Total*Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  728. # Fit the linear mixed-effects model
  729. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  730. # Store the model in the list (use the correct list name here)
  731. models_cs_ss_partialadjusted[[domain]] <- model
  732. # Optionally, print the summary of the model
  733. print(paste("Model for", domain))
  734. print(summary(model))
  735. }
  736. sink()
  737. ```
  738. #Table 2 - Longitudinal Associations of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Fully Adjusted)
  739. #eTable 10 - Interrelationship of Baseline Chronic Stress, Social Support, and Domain-Specific Cognitive Z-scores (Fully Adjusted)
  740. ##Chronic Stress & Social Support (Combination Model) (Fully Adjusted)
  741. ```{r}
  742. library(dplyr)
  743. library(lmerTest) #this package prints p values
  744. sink("Mixed_Effect_Models_CS_SS_samemodel_fullyadjusted_Updated072725.txt")
  745. # Define the cognitive domain variables to loop through
  746. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  747. options(scipen = 999)
  748. # Create an empty list to store the models
  749. models_cs_ss_fullyadjusted <- list()
  750. # Loop through the domains and fit the linear mixed-effects model for each
  751. for (domain in domains) {
  752. # Define the formula dynamically for each domain
  753. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_SocialSupport_Total + Time + Baseline_ChronicStress_Total*Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  754. # Fit the linear mixed-effects model
  755. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  756. # Store the model in the list (use the correct list name here)
  757. models_cs_ss_fullyadjusted[[domain]] <- model
  758. # Optionally, print the summary of the model
  759. print(paste("Model for", domain))
  760. print(summary(model))
  761. }
  762. sink()
  763. ```
  764. #Table 3 - Interaction between Baseline Chronic Stress, Social Support, and Gender in relation to Domain-Specific Cognitive Z-scores
  765. #CS*GENDER*Time + SS*Gender*Time (Fully Adjusted)
  766. ```{r}
  767. ##CS SS Combo - Adjusted - Interaction with Gender
  768. library(dplyr)
  769. library(lmerTest) #this package prints p values
  770. sink("Mixed_Effect_Models_071225_Release7_CS_SS_Combo_adjustedgender_fullyadjusted_UPDATED08052025.txt")
  771. # Define the cognitive domain variables to loop through
  772. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  773. # Create an empty list to store the models
  774. models_cs_ss_combo_fullyadjusted_interactiongender <- list()
  775. # Loop through the domains and fit the linear mixed-effects model for each
  776. for (domain in domains) {
  777. # Define the formula dynamically for each domain
  778. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_SocialSupport_Total + Baseline_ID_Gender + Time + Baseline_ChronicStress_Total*Baseline_ID_Gender*Time + Baseline_SocialSupport_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  779. # Fit the linear mixed-effects model
  780. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  781. # Store the model in the list (use the correct list name here)
  782. models_cs_ss_combo_fullyadjusted_interactiongender[[domain]] <- model
  783. # Optionally, print the summary of the model
  784. print(paste("Model for", domain))
  785. print(summary(model))
  786. }
  787. sink()
  788. ```
  789. #Table 4 - Interaction between Baseline Chronic Stress, Social Support, and Race/Ethnicity in relation to Domain-Specific Cognitive Z-scores
  790. #CS*Ethnicity*Time + SS*Ethnicity*Time (Fully Adjusted)
  791. ```{r}
  792. ##CS SS Combo - Adjusted - Interaction with Gender
  793. library(dplyr)
  794. library(lmerTest) #this package prints p values
  795. sink("Mixed_Effect_Models_071225_Release7_CS_SS_Combo_adjustedethnicity_fullyadjusted_UPDATED08052025.txt")
  796. # Define the cognitive domain variables to loop through
  797. domains <- c("AttentionDomain", "MemoryDomain", "ExecutiveDomain", "LanguageDomain")
  798. # Create an empty list to store the models
  799. models_cs_ss_combo_fullyadjusted_interactionethnicity <- list()
  800. # Loop through the domains and fit the linear mixed-effects model for each
  801. for (domain in domains) {
  802. # Define the formula dynamically for each domain
  803. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_SocialSupport_Total + Baseline_Ethnicity + Time + Baseline_ChronicStress_Total*Baseline_Ethnicity*Time + Baseline_SocialSupport_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  804. # Fit the linear mixed-effects model
  805. model <- lmer(formula, data = FULLMERGE_df_nodementia)
  806. # Store the model in the list (use the correct list name here)
  807. models_cs_ss_combo_fullyadjusted_interactionethnicity[[domain]] <- model
  808. # Optionally, print the summary of the model
  809. print(paste("Model for", domain))
  810. print(summary(model))
  811. }
  812. sink()
  813. ```
  814. #eTable 3. Distribution of Longitudinal Visits and Follow-Up Time
  815. ```{r}
  816. #Count visits per participant
  817. visit_counts_012126 <- FULLMERGE_df_nodementia %>%
  818. group_by(Med_ID) %>%
  819. summarise(
  820. n_visits = n_distinct(Visit_ID),
  821. .groups = "drop"
  822. )
  823. print(visit_counts_012126)
  824. visit_table_012126 <- visit_counts_012126 %>%
  825. count(n_visits) %>%
  826. arrange(n_visits) %>%
  827. mutate(
  828. percent = round(100 * n / sum(n), 1)
  829. )
  830. visit_table_012126
  831. #1 Visit - 2191
  832. #2 Visit - 1070
  833. #3 Visit - 430
  834. #4 Visit - 182
  835. ```
  836. #######
  837. ##Running Individual tests
  838. ```{r}
  839. FULLMERGE_df_nodementia_individualtests <- FULLMERGE_df_nodementia %>%
  840. select(
  841. Visit_ID,
  842. Med_ID,
  843. AttentionDomain,
  844. MemoryDomain,
  845. ExecutiveDomain,
  846. LanguageDomain,
  847. DS_ZScore,
  848. Trails_A_ZScore,
  849. SEVLT_T1235_ZScore,
  850. SEVLT_DR_ZScore,
  851. LM1_AB_ZScore,
  852. LM2_AB_ZScore,
  853. Digit_Symbol_Substitution_ZScore,
  854. Trails_B_ZScore,
  855. FAS_ZScore,
  856. Animal_ZScore
  857. )
  858. View(FULLMERGE_df_nodementia_individualtests)
  859. library(dplyr)
  860. FULLMERGE_df_nodementia_individualtests <-FULLMERGE_df_nodementia_individualtests %>%
  861. dplyr::rename(
  862. AttentionDomain_Check = AttentionDomain,
  863. MemoryDomain_Check = MemoryDomain,
  864. ExecutiveDomain_Check = ExecutiveDomain,
  865. LanguageDomain_Check = LanguageDomain
  866. )
  867. View(FULLMERGE_df_nodementia_individualtests)
  868. ```
  869. ##Individual Tests
  870. ##Chronic Stress - Fully Adjusted 05.07.2026
  871. #eTable 11. Longitudinal Associations of Baseline Chronic Stress and Individual Cognitive Assessment Z-scores
  872. ```{r}
  873. library(dplyr)
  874. library(lme4)
  875. library(lmerTest) #this package prints p values
  876. sink("Updatedreference_Mixed_Effect_IndividualTests_ChronicStress_Fullyadjusted_050726.txt")
  877. # Define the cognitive domain variables to loop through
  878. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  879. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  880. # Create an empty list to store the models
  881. models_chronicstress_fullyadjusted_050726 <- list()
  882. # Loop through the domains and fit the linear mixed-effects model for each
  883. for (domain in domains) {
  884. # Define the formula dynamically for each domain
  885. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Time + Baseline_ChronicStress_Total*Time + (1 | Med_ID)"))
  886. # Fit the linear mixed-effects model
  887. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  888. # Store the model in the list (use the correct list name here)
  889. models_chronicstress_fullyadjusted_050726[[domain]] <- model
  890. # Optionally, print the summary of the model
  891. print(paste("Model for", domain))
  892. print(summary(model))
  893. }
  894. sink()
  895. ```
  896. ##Chronic Stress - Partial Adjusted 05.07.2026
  897. #Individual Tests
  898. #eTable 11. Longitudinal Associations of Baseline Chronic Stress and Individual Cognitive Assessment Z-scores
  899. ```{r}
  900. library(dplyr)
  901. library(lme4)
  902. library(lmerTest) #this package prints p values
  903. sink("Mixed_Effect_IndividualTests_ChronicStress_partialadjusted_050726.txt")
  904. # Define the cognitive domain variables to loop through
  905. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  906. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  907. # Create an empty list to store the models
  908. models_chronicstress_partialadjusted_050726 <- list()
  909. # Loop through the domains and fit the linear mixed-effects model for each
  910. for (domain in domains) {
  911. # Define the formula dynamically for each domain
  912. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_ChronicStress_Total + Time + Baseline_ChronicStress_Total*Time + (1 | Med_ID)"))
  913. # Fit the linear mixed-effects model
  914. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  915. # Store the model in the list (use the correct list name here)
  916. models_chronicstress_partialadjusted_050726[[domain]] <- model
  917. # Optionally, print the summary of the model
  918. print(paste("Model for", domain))
  919. print(summary(model))
  920. }
  921. sink()
  922. ```
  923. ##Chronic Stress - Unadjusted 05.07.2026
  924. #Individual Tests
  925. #eTable 11. Longitudinal Associations of Baseline Chronic Stress and Individual Cognitive Assessment Z-scores
  926. ```{r}
  927. library(dplyr)
  928. library(lme4)
  929. library(lmerTest) #this package prints p values
  930. sink("Mixed_Effect_IndividualTests_ChronicStress_unadjusted_050726.txt")
  931. # Define the cognitive domain variables to loop through
  932. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  933. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  934. # Create an empty list to store the models
  935. models_chronicstress_unadjusted_050726 <- list()
  936. # Loop through the domains and fit the linear mixed-effects model for each
  937. for (domain in domains) {
  938. # Define the formula dynamically for each domain
  939. formula <- as.formula(paste(domain, "~Baseline_ChronicStress_Total + Time + Baseline_ChronicStress_Total*Time + (1 | Med_ID)"))
  940. # Fit the linear mixed-effects model
  941. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  942. # Store the model in the list (use the correct list name here)
  943. models_chronicstress_unadjusted_050726[[domain]] <- model
  944. # Optionally, print the summary of the model
  945. print(paste("Model for", domain))
  946. print(summary(model))
  947. }
  948. sink()
  949. ```
  950. ##Individual Tests
  951. ##Social Support - Fully Adjusted
  952. #eTable 12. Longitudinal Associations of Baseline Social Support and Individual Cognitive Assessment Z-scores
  953. ```{r}
  954. library(dplyr)
  955. library(lme4)
  956. library(lmerTest) #this package prints p values
  957. sink("Mixed_Effect_IndividualTests_SocialSupport_Fullyadjusted_050726.txt")
  958. # Define the cognitive domain variables to loop through
  959. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  960. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  961. # Create an empty list to store the models
  962. models_socialsupport_fullyadjusted_050726 <- list()
  963. # Loop through the domains and fit the linear mixed-effects model for each
  964. for (domain in domains) {
  965. # Define the formula dynamically for each domain
  966. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_SocialSupport_Total + Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  967. # Fit the linear mixed-effects model
  968. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  969. # Store the model in the list (use the correct list name here)
  970. models_socialsupport_fullyadjusted_050726[[domain]] <- model
  971. # Optionally, print the summary of the model
  972. print(paste("Model for", domain))
  973. print(summary(model))
  974. }
  975. sink()
  976. ```
  977. ##Social - Partial Adjusted 05.07.2026
  978. #Individual Tests
  979. ##eTable 12. Longitudinal Associations of Baseline Social Support and Individual Cognitive Assessment Z-scores
  980. ```{r}
  981. library(dplyr)
  982. library(lme4)
  983. library(lmerTest) #this package prints p values
  984. sink("Mixed_Effect_IndividualTests_SocialSupport_partialadjusted_050726.txt")
  985. # Define the cognitive domain variables to loop through
  986. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  987. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  988. # Create an empty list to store the models
  989. models_socialsupport_partialadjusted_050726 <- list()
  990. # Loop through the domains and fit the linear mixed-effects model for each
  991. for (domain in domains) {
  992. # Define the formula dynamically for each domain
  993. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_ID_Gender + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_SocialSupport_Total + Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  994. # Fit the linear mixed-effects model
  995. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  996. # Store the model in the list (use the correct list name here)
  997. models_socialsupport_partialadjusted_050726[[domain]] <- model
  998. # Optionally, print the summary of the model
  999. print(paste("Model for", domain))
  1000. print(summary(model))
  1001. }
  1002. sink()
  1003. ```
  1004. ##Social Support - Unadjusted 05.07.2026
  1005. #Individual Tests
  1006. ##eTable 12. Longitudinal Associations of Baseline Social Support and Individual Cognitive Assessment Z-scores
  1007. ```{r}
  1008. library(dplyr)
  1009. library(lme4)
  1010. library(lmerTest) #this package prints p values
  1011. sink("Mixed_Effect_IndividualTests_SocialSupport_unadjusted_050726.txt")
  1012. # Define the cognitive domain variables to loop through
  1013. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  1014. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  1015. # Create an empty list to store the models
  1016. models_socialsupport_unadjusted_050726 <- list()
  1017. # Loop through the domains and fit the linear mixed-effects model for each
  1018. for (domain in domains) {
  1019. # Define the formula dynamically for each domain
  1020. formula <- as.formula(paste(domain, "~Baseline_SocialSupport_Total + Time + Baseline_SocialSupport_Total*Time + (1 | Med_ID)"))
  1021. # Fit the linear mixed-effects model
  1022. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  1023. # Store the model in the list (use the correct list name here)
  1024. models_socialsupport_unadjusted_050726[[domain]] <- model
  1025. # Optionally, print the summary of the model
  1026. print(paste("Model for", domain))
  1027. print(summary(model))
  1028. }
  1029. sink()
  1030. ```
  1031. ###Individual Tests####
  1032. ####Interactions####
  1033. ###Gender & Chronic Stress###
  1034. ##Individual Tests##
  1035. #CS*GENDER*Time (Fully Adjusted)
  1036. #eTable 13. Interaction between Baseline Chronic Stress, Social Support, and Gender in relation to Individual Cognitive Assessment Z-Scores
  1037. ```{r}
  1038. ##Chronic Stress - Adjusted - Interaction with Gender
  1039. library(dplyr)
  1040. library(lmerTest) #this package prints p values
  1041. sink("Mixed_Effect_IndividualTests_ChronicStress_adjustedgender_fullyadjusted_050826.txt")
  1042. # Define the cognitive domain variables to loop through
  1043. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  1044. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  1045. # Create an empty list to store the models
  1046. models_chronicstress_fullyadjusted_interactiongender_050726 <- list()
  1047. # Loop through the domains and fit the linear mixed-effects model for each
  1048. for (domain in domains) {
  1049. # Define the formula dynamically for each domain
  1050. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_ID_Gender + Time + Baseline_ChronicStress_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  1051. # Fit the linear mixed-effects model
  1052. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  1053. # Store the model in the list (use the correct list name here)
  1054. models_chronicstress_fullyadjusted_interactiongender_050726[[domain]] <- model
  1055. # Optionally, print the summary of the model
  1056. print(paste("Model for", domain))
  1057. print(summary(model))
  1058. }
  1059. sink()
  1060. ```
  1061. ###Gender & Social Support###
  1062. ##Individual Tests##
  1063. #SS*GENDER*Time (Fully Adjusted)
  1064. #eTable 13. Interaction between Baseline Chronic Stress, Social Support, and Gender in relation to Individual Cognitive Assessment Z-Scores
  1065. ```{r}
  1066. ##Chronic Stress - Adjusted - Interaction with Gender
  1067. library(dplyr)
  1068. library(lmerTest) #this package prints p values
  1069. sink("Mixed_Effect_IndividualTests_SocialSupport_adjustedgender_fullyadjusted_050826.txt")
  1070. # Define the cognitive domain variables to loop through
  1071. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  1072. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  1073. # Create an empty list to store the models
  1074. models_socialsupport_fullyadjusted_interactiongender_050726 <- list()
  1075. # Loop through the domains and fit the linear mixed-effects model for each
  1076. for (domain in domains) {
  1077. # Define the formula dynamically for each domain
  1078. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_Ethnicity + Baseline_PSWQ_Total + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_SocialSupport_Total + Baseline_ID_Gender + Time + Baseline_SocialSupport_Total*Baseline_ID_Gender*Time + (1 | Med_ID)"))
  1079. # Fit the linear mixed-effects model
  1080. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  1081. # Store the model in the list (use the correct list name here)
  1082. models_socialsupport_fullyadjusted_interactiongender_050726[[domain]] <- model
  1083. # Optionally, print the summary of the model
  1084. print(paste("Model for", domain))
  1085. print(summary(model))
  1086. }
  1087. sink()
  1088. ```
  1089. ##Interaction###
  1090. ###Race##
  1091. ##Individual Tests##
  1092. #CS*Race*Time (Fully Adjusted)
  1093. #eTable 14. Interaction between Baseline Chronic Stress, Social Support, and Race/Ethnicity in relation to Individual Cognitive Assessment Z-Scores
  1094. ```{r}
  1095. ##Chronic Stress - Fully Adjusted - Interaction with Race
  1096. library(dplyr)
  1097. library(lmerTest) #this package prints p values
  1098. sink("Mixed_Effect_IndividualTests_ChronicStress_adjustedrace_fullyadjusted_050826.txt")
  1099. # Define the cognitive domain variables to loop through
  1100. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  1101. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  1102. # Create an empty list to store the models
  1103. models_chronicstress_fullyadjusted_interactionrace_050726 <- list()
  1104. # Loop through the domains and fit the linear mixed-effects model for each
  1105. for (domain in domains) {
  1106. # Define the formula dynamically for each domain
  1107. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_PSWQ_Total + Baseline_ID_Gender + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_ChronicStress_Total + Baseline_Ethnicity + Time + Baseline_ChronicStress_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  1108. # Fit the linear mixed-effects model
  1109. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  1110. # Store the model in the list (use the correct list name here)
  1111. models_chronicstress_fullyadjusted_interactionrace_050726[[domain]] <- model
  1112. # Optionally, print the summary of the model
  1113. print(paste("Model for", domain))
  1114. print(summary(model))
  1115. }
  1116. sink()
  1117. ```
  1118. ##Individual Tests##
  1119. #SS*Race*Time (Fully Adjusted)
  1120. #eTable 14. Interaction between Baseline Chronic Stress, Social Support, and Race/Ethnicity in relation to Individual Cognitive Assessment Z-Scores
  1121. ```{r}
  1122. ##Chronic Stress - Fully Adjusted - Interaction with Race
  1123. library(dplyr)
  1124. library(lmerTest) #this package prints p values
  1125. sink("Mixed_Effect_IndividualTests_SocialSupport_adjustedrace_fullyadjusted_050826.txt")
  1126. # Define the cognitive domain variables to loop through
  1127. domains <- c("DS_ZScore", "Trails_A_ZScore", "SEVLT_T1235_ZScore", "SEVLT_DR_ZScore", "LM1_AB_ZScore", "LM2_AB_ZScore",
  1128. "Digit_Symbol_Substitution_ZScore", "Trails_B_ZScore", "FAS_ZScore", "Animal_ZScore")
  1129. # Create an empty list to store the models
  1130. models_socialsupport_fullyadjusted_interactionrace_050726 <- list()
  1131. # Loop through the domains and fit the linear mixed-effects model for each
  1132. for (domain in domains) {
  1133. # Define the formula dynamically for each domain
  1134. formula <- as.formula(paste(domain, "~ Baseline_Age + Baseline_ID_Education + Baseline_PSWQ_Total + Baseline_ID_Gender + Baseline_GDS_Total + Baseline_IMH_Diabetes + Baseline_IMH_HeartAttack + Baseline_IMH_KidneyDisease + Baseline_IMH_Stroke + Baseline_OM_BMI + Baseline_SocialSupport_Total + Baseline_Ethnicity + Time + Baseline_SocialSupport_Total*Baseline_Ethnicity*Time + (1 | Med_ID)"))
  1135. # Fit the linear mixed-effects model
  1136. model <- lmer(formula, data = FULLMERGE_df_nodementia_individualtests)
  1137. # Store the model in the list (use the correct list name here)
  1138. models_socialsupport_fullyadjusted_interactionrace_050726[[domain]] <- model
  1139. # Optionally, print the summary of the model
  1140. print(paste("Model for", domain))
  1141. print(summary(model))
  1142. }
  1143. sink()
  1144. ```

HABSHD_Github.Rmd at commit 130a796, no license · at the source

Overview

Authors: Jillian K. Lee1, Leigh Johnson2, James R. Hall2, James R. Bateman3, Michelle M. Mielke1
  1. Department of Epidemiology and Prevention Wake Forest University School of Medicine Winston‐Salem North Carolina USA
  2. Institute for Translational Research University of North Texas Health Science Center Fort Worth Texas USA
  3. Department of Neurology Virginia Commonwealth University Richmond Virginia USA
Journal: Alzheimer's & dementia : the journal of the Alzheimer's Association, volume 22, issue 8, article e71760
Dates: received 17 February 2026; accepted 15 July 2026; published online 25 August 2026; in print August 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1002/alz.71760 · PMID 42642823 · PMCID PMC13507027 · OpenAlex W7204277785
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: behavior only (modality), human (organism), Alzheimer's / dementia (population), cognitive (subfield)
Methods: Statistics, Connectivity
Keywords: Alzheimer's disease, chronic stress, cognitive decline, gender, race/ethnicity, social support
MeSH: Cognitive Dysfunction*, Social Support*, Stress, Psychological*, Aged, Aged, 80 and over, Attention, Executive Function, Female, Humans, Longitudinal Studies, Male, Neuropsychological Tests (* major topic)
Topic: Dementia and Cognitive Impairment Research (Psychiatry and Mental health, Medicine), according to OpenAlex
Funding: National Institute on Aging of the National Institutes of Health (F31AG087696, 5T32NS115704, R01AG054073, R01AG058533, R01AG070862, P41EB015922, U19AG078109)
Citations: not cited yet (Europe PMC); 66 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 2 matches between paragraphs and lines of code.

jkleeri/mielkelab_chronicstress_socialsupport_HABSHD

License: none: the authors keep all their rights
State: the link answers, verified on 26 September 2026
Evidence: files inventoried
Commit: 130a796426833dd30c393ba0956d41f1901fe7be, 20 May 2026
Languages: R (1)
Size: 2 files, 1 script
Software Heritage: not archived
Found in: “CODE AVAILABILITY”
Holds: README, 1 notebook
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: lme4 (1 file), lmerTest (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 26 September 2026: the link answers
  • 26 September 2026: the link answers
2 files

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1002/alz.71760.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 1 script, each with its path and the digest of its content;
  • 2 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability statement

The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • no repository, dataset or request procedure was recognized in it

Read it in the paper: doi.org/10.1002/alz.71760.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 6 keywords, 12 MeSH terms, 1 funder, 63 references.

Cite

This paper

Lee, J. K., Johnson, L., Hall, J. R., Bateman, J. R., & Mielke, M. M. (2026). Chronic stress, social support, and domain-specific cognitive decline in HABS-HD. Alzheimer's & dementia : the journal of the Alzheimer's Association, 22(8), e71760. https://doi.org/10.1002/alz.71760

BibTeX

@article{lee2026chronic,
author = {Lee, Jillian K. and Johnson, Leigh and Hall, James R. and Bateman, James R. and Mielke, Michelle M.},
title = {{Chronic stress, social support, and domain-specific cognitive decline in HABS-HD}},
journal = {Alzheimer's \& dementia : the journal of the Alzheimer's Association},
year = {2026},
month = aug,
volume = {22},
number = {8},
pages = {e71760},
publisher = {Wiley},
issn = {1552-5260},
doi = {10.1002/alz.71760},
url = {https://doi.org/10.1002/alz.71760},
pmid = {42642823},
pmcid = {PMC13507027}
}

RIS

TY - JOUR
AU - Lee, Jillian K.
AU - Johnson, Leigh
AU - Hall, James R.
AU - Bateman, James R.
AU - Mielke, Michelle M.
TI - Chronic stress, social support, and domain-specific cognitive decline in HABS-HD
T2 - Alzheimer's & dementia : the journal of the Alzheimer's Association
J2 - Alzheimers Dement
PY - 2026
DA - 2026/08/01
VL - 22
IS - 8
SP - e71760
SN - 1552-5260
PB - Wiley
DO - 10.1002/alz.71760
UR - https://doi.org/10.1002/alz.71760
LA - en
ER -

CSL-JSON

{
"id": "10.1002/alz.71760",
"type": "article-journal",
"title": "Chronic stress, social support, and domain-specific cognitive decline in HABS-HD",
"container-title": "Alzheimer's & dementia : the journal of the Alzheimer's Association",
"author": [
{
"family": "Lee",
"given": "Jillian K."
},
{
"family": "Johnson",
"given": "Leigh"
},
{
"family": "Hall",
"given": "James R."
},
{
"family": "Bateman",
"given": "James R."
},
{
"family": "Mielke",
"given": "Michelle M."
}
],
"container-title-short": "Alzheimers Dement",
"volume": "22",
"issue": "8",
"page": "e71760",
"DOI": "10.1002/alz.71760",
"PMID": "42642823",
"PMCID": "PMC13507027",
"ISSN": "1552-5260",
"publisher": "Wiley",
"URL": "https://doi.org/10.1002/alz.71760",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
1
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1093/ageing/afag263 [code]
Cardiometabolic medication exposures and cognitive outcomes in Alzheimer's disease.
Journal: Age and ageing
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia, 1 reference
[2] doi:10.1016/j.tjpad.2026.100622 [code]
The time interval from amyloid to tau PET positivity varies by age, sex and APOE-ε4 status.
Journal: The journal of prevention of Alzheimer's disease
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia, 1 reference
[3] doi:10.1002/alz.71567 [code]
Associations of dementia polyexposure scores to Alzheimer's disease endophenotypes in a diverse population.
Journal: Alzheimer's & dementia : the journal of the Alzheimer's Association
In common: tidyverse, Alzheimer's / dementia, 2 references
[4] doi:10.1096/fba.2026-00194 [code]
Glial and Vascular Plasma Biomarkers Across the Alzheimer's Disease Continuum: An ADNI-Based Longitudinal Study.
Journal: FASEB bioAdvances
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia
[5] doi:10.1038/s41588-026-02722-8 [code]
A multiancestry polygenic risk score for Alzheimer's disease is associated with cognitive decline and neuropathological hallmarks in diverse populations.
Journal: Nature genetics
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia
[6] doi:10.1038/s41593-026-02363-4 [code]
Cortical thickness changes precede high levels of amyloid by at least 7 years.
Journal: Nature neuroscience
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia
[7] doi:10.1038/s42003-026-10282-0 [code]
Genetic risk of Alzheimer's disease is associated with loss of brain network segregation in midlife.
Journal: Communications biology
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia
[8] doi:10.1093/braincomms/fcag176 [code]
Tau topography subtypes account for clinical heterogeneity and longitudinal trajectories in early-onset Alzheimer's disease.
Journal: Brain communications
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia
[9] doi:10.1186/s13195-026-02036-1 [code]
Genetic drivers of progression in Alzheimer's disease are distinct from disease risk.
Journal: Alzheimer's research & therapy
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia
[10] doi:10.1007/s11357-026-02195-x [code]
The aging epigenome: integrative analyses reveal intersection with Alzheimer's disease.
Journal: GeroScience
In common: lmerTest, lme4, tidyverse, Alzheimer's / dementia

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.