PAaSO/2 Longterm/sdmt correction.R

24 lines
1.2 KiB
R
Raw Normal View History

2026-08-19 09:27:27 +02:00
# During study time, the SDMT was performed in a non-standardised way until around 2015-02-18, only giving subjects 60 seconds.
# Some filled assessments were marked and were all manually evaluated for correction.
# A decision was reached to multiply old results by a factor of 1.5 assuming a proportional increase in completed fields.
sdmt_time<-openxlsx::read.xlsx("/Volumes/Data/source/tid.sdmt.xlsx") |>
tidyr::pivot_longer(cols = c(tid.1md, tid.6md)) |> mutate(deltager=as.character(deltager))
sdmt_time$name <- as.double(as.character(factor(sdmt_time$name,labels = c("2","4"))))
# Setting cut date
sdmt_cut<-as.Date("2015-02-18")
# Joining datasets to have date of visit
sdmt_corr <- left_join(ls_nas$sdmt,sdmt_time |> mutate(name=as.character(name)), by = c("rnumb"="deltager","instance"="name"))
# Modyfying old correction table to be complete
sdmt_corr$value <- if_else(sdmt_corr$talos_sdmt00<sdmt_cut|sdmt_corr$value==60,60,90,missing = 90)
# Write for database upload and easier future handling
# write.csv(select(sdmt_corr, rnumb, instance, value),"2 Longterm/sdmt_time_correction.csv")
# Multiplying meassure by correction valued turned weight and rounded
sdmt_corr$talos_sdmt01a <- round(as.numeric(sdmt_corr$talos_sdmt01a)*(90/sdmt_corr$value),0)