Title: | Langa-Weir Classification of Cognitive Function for 2022 HRS Data |
---|---|
Description: | Generates the Langa-Weir classification of cognitive function for the 2022 Health and Retirement Study (HRS) cognition data. It is particularly useful for researchers studying cognitive aging who wish to work with the most recent release of HRS data. The package provides user-friendly functions for data preprocessing, scoring, and classification allowing users to easily apply the Langa-Weir classification system. For details regarding the; HRS <https://hrsdata.isr.umich.edu/> and Langa-Weir classifications <https://hrsdata.isr.umich.edu/data-products/langa-weir-classification-cognitive-function-1995-2020>. |
Authors: | Cormac Monaghan [cph, aut, cre] , Rafael de Andrade Moral [aut] , Joanna McHugh Power [aut] |
Maintainer: | Cormac Monaghan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-11-25 15:21:55 UTC |
Source: | CRAN |
This function classifies individuals into cognitive function groups based on their total cognition score, which is calculated from immediate word recall, delayed word recall, serial subtraction, and backwards counting scores. The classification creates three categories of cognitive function.
classify(data)
classify(data)
data |
A dataframe containing cognitive test scores, including total immediate word recall, delayed word recall, serial subtraction, and backwards counting scores. |
The function creates a total cognitive score by summing the scores for immediate word recall, delayed word recall, serial subtraction, and backwards counting. It then classifies the cognitive function into three levels:
Class 1: Normal (total score >= 12).
Class 2: Cognitive impairment no dementia (total score between 7 and 11).
Class 3: Demented (total score <= 6).
A dataframe with:
Total_cog_score
: Total cognitive score (sum of all individual task scores).
Class
: Cognitive function classification (1 = Normal, 2 = Cognitive impairment no dementia, 3 = Demented).
Renamed columns with updated labels for 2022 data: imrc_imp2022
, dlrc_imp2022
,
ser7_imp2022
, bwc20_imp2022
, cogtot27_imp2022
, and cogfunction2022
.
# Assuming `cog_data` is a dataframe with the relevant columns classified_data <- classify(cog_data_score)
# Assuming `cog_data` is a dataframe with the relevant columns classified_data <- classify(cog_data_score)
A simulated dataset with cognition test scores, following the same methodology as the Health and Retirement Study (HRS). The dataset includes immediate word recall, delayed word recall, serial subtraction, backwards counting tasks, and mouse click clicking with scores representing cognitive performance on these tests.
cog_data
cog_data
A dataframe with 10 rows and 35 variables:
Household identifier, a unique 6-digit integer.
Person number, a unique 1- or 2-digit integer within each household.
Immediate word recall test score for the first word.
Immediate word recall test score for the second word.
Immediate word recall test score for the third word.
Immediate word recall test score for the fourth word.
Immediate word recall test score for the fifth word.
Immediate word recall test score for the sixth word.
Immediate word recall test score for the seventh word.
Immediate word recall test score for the eight word.
Immediate word recall test score for the ninth word.
Immediate word recall test score for the tenth word.
Delayed word recall test score for the first word.
Delayed word recall test score for the second word.
Delayed word recall test score for the third word.
Delayed word recall test score for the fourth word.
Delayed word recall test score for the fifth word.
Delayed word recall test score for the sixth word.
Delayed word recall test score for the seventh word.
Delayed word recall test score for the eight word.
Delayed word recall test score for the ninth word.
Delayed word recall test score for the tenth word.
Serial subtraction, result of subtracting 7 from 100.
Serial subtraction, result of subtracting 7 from the previous number.
Serial subtraction, result of subtracting 7 from the previous number.
Serial subtraction, result of subtracting 7 from the previous number.
Serial subtraction, result of subtracting 7 from the previous number.
Backwards counting test, success on the first attempt (1 = success, 0 = fail).
Backwards counting test, success on the second attempt (1 = success, 0 = fail).
Mouse clicking test: accuracy result (first attemp)
Mouse clicking test: total click count (first attemp)
Mouse clicking test: total time spent (in seconds; first attempt)
Mouse clicking test: accuracy result (second attemp)
Mouse clicking test: total click count (second attemp)
Mouse clicking test: total time spent (in seconds; second attempt)
# Load the data data(cog_data) # View the first few rows head(cog_data)
# Load the data data(cog_data) # View the first few rows head(cog_data)
A simulated dataset with scored cognition test results. This dataset contains calculated total scores for immediate recall, delayed recall, serial subtraction.
cog_data_score
cog_data_score
A dataframe with 10 rows and 6 variables:
Household identifier, a unique 6-digit integer.
Person number, a unique 1- or 2-digit integer within each household.
Total immediate word recall score, ranging from 0 to 5 (sum of 5 items from the immediate recall test).
Total delayed word recall score, ranging from 0 to 5 (sum of 5 items from the delayed recall test).
Total serial subtraction score, ranging from 0 to 5 (sum of successful subtractions from the serial subtraction test).
Total backwards counting score, ranging from 0 to 2 (2 points for success on the first try, 1 point for success on the second try, and 0 for failure).
# Load the data data(cog_data_score) # View the first few rows head(cog_data_score)
# Load the data data(cog_data_score) # View the first few rows head(cog_data_score)
This function extracts specific cognitive measures from a dataset, including immediate and delayed word recall, serial subtraction, and backwards counting, along with household and person identifiers.
extract(data)
extract(data)
data |
A dataframe containing the full dataset from which specific variables will be selected. |
The function selects key cognitive test results and identifiers from the dataset.
It uses dplyr::select()
to retrieve:
Immediate and delayed word recall variables (those starting with "SD182M" and "SD183M").
Serial subtraction results (SD142
to SD146
).
Backwards counting variables (SD124
, SD129
).
A dataframe with the following variables:
HHID
: Household ID.
PN
: Person number (individual identifier).
Immediate and delayed word recall variables (columns starting with "SD182M"
and "SD183M"
).
Serial subtraction variables (SD142
to SD146
).
Backwards counting variables (SD124
, SD129
).
# Assuming `cog_data` is a dataframe with the relevant columns extract(cog_data)
# Assuming `cog_data` is a dataframe with the relevant columns extract(cog_data)
This function calculates various cognitive test scores from a dataset, including word recall, serial subtraction, and backwards counting. It computes total scores for immediate and delayed word recall, scores for serial subtraction tasks, and a total score for backwards counting.
score(data)
score(data)
data |
A dataframe containing the cognitive test data, including columns for word recall, serial subtraction, and backwards counting tasks. |
The function applies scoring functions to the cognitive test data:
Word recall: Scores immediate and delayed recall using the score_recall
function, and computes total scores.
Serial subtraction: Applies the score_subtraction
function to calculate scores for each subtraction step, and computes the total score.
Backwards counting: Assigns 2 points for correct counting on the first try, 1 point for correct counting on the second try, and 0 for incorrect counting.
A dataframe with the following computed scores:
Total_I
: Total score for immediate word recall.
Total_D
: Total score for delayed word recall.
Total_Sub
: Total score for serial subtraction.
Total_Count
: Total score for backwards counting.
# Assuming `cog_data` is a dataframe with the relevant columns scored_data <- score(cog_data)
# Assuming `cog_data` is a dataframe with the relevant columns scored_data <- score(cog_data)
This function scores a word recall task where respondents are given 1 for a correct recall and 0 for an incorrect recall. Missing values (NA) are retained as NA in the output.
score_recall(x)
score_recall(x)
x |
A numeric vector representing respondents' word recall responses. Specific numeric codes are used to define incorrect responses. |
The function assigns a score of 1 for a correct word recall. Incorrect recall is determined by specific numeric codes (51 to 67, 96, 98, and 99) and assigned a score of 0. Any NA values in the input will remain NA in the output.
A numeric vector where:
1
: Correct recall.
0
: Incorrect recall (based on specific codes).
NA
: If the original value was missing, it remains NA.
responses <- c(53, 62, 100, NA, 66) score_recall(responses)
responses <- c(53, 62, 100, NA, 66) score_recall(responses)
This function scores a serial subtraction task where respondents are scored based on their ability to successfully subtract a specific value (e.g., 7) from the previous value. A score of 1 is given for correct subtraction, and a score of 0 is given for incorrect subtraction. However, a respondent can still receive a score of 1 if they recover from an initial mistake by correctly subtracting later.
score_subtraction(val, diff)
score_subtraction(val, diff)
val |
A numeric vector representing the respondent's current answer. |
diff |
A numeric vector representing the correct difference (e.g., expected subtraction value). |
The function checks if the respondent's answer (val
) is equal to the correct subtraction
difference (diff
). If so, they are awarded a score of 1. If they make a mistake, they get 0.
However, if they correct their mistake in the next step, they can receive a score of 1 for that step.
Missing values (NA) in the input remain as NA in the output.
A numeric vector where:
1
: Correct subtraction.
0
: Incorrect subtraction.
NA
: If the original value is missing (NA), it remains NA.
responses <- c(93, 86, 79, 72, NA) correct_diffs <- c(93, 86, 79, 72, 65) - 7 score_subtraction(responses, correct_diffs)
responses <- c(93, 86, 79, 72, NA) correct_diffs <- c(93, 86, 79, 72, 65) - 7 score_subtraction(responses, correct_diffs)