Title: | Repeated Measures Correlation |
---|---|
Description: | Compute the repeated measures correlation, a statistical technique for determining the overall within-individual relationship among paired measures assessed on two or more occasions, first introduced by Bland and Altman (1995). Includes functions for diagnostics, p-value, effect size with confidence interval including optional bootstrapping, as well as graphing. Also includes several example datasets. For more details, see the web documentation <https://lmarusich.github.io/rmcorr/index.html> and the original paper: Bakdash and Marusich (2017) <doi:10.3389/fpsyg.2017.00456>. |
Authors: | Jonathan Z. Bakdash [aut] |
Maintainer: | Laura R. Marusich <[email protected]> |
License: | GPL-2 |
Version: | 0.7.0 |
Built: | 2025-02-10 05:00:44 UTC |
Source: | https://github.com/lmarusich/rmcorr |
A dataset containing the repeated measurements of intramural pH and PaCO2 for eight subjects, from Bland & Altman (1995).
bland1995
bland1995
A data frame with 47 rows and 3 variables
[,1] |
Subject |
Unique identifer |
[,2] |
pH |
Potential of hydrogen, acidity to base |
[,3] |
PaCO2 |
Partial pressure of carbon dioxide |
Bland, J.M., & Altman, D.G. (1995). Calculating correlation coefficients with repeated observations: Part 1 – correlation within subjects. BMJ, 310, 446, doi:10.1136/bmj.310.6977.446
geom_rmc: ggplot2 geom for simplified graphing
geom_rmc(rmc)
geom_rmc(rmc)
rmc |
an object of class "rmc" generated from the |
rmcorr, plot.rmc for base plotting
my.rmc <- rmcorr(participant = Subject, measure1 = PaCO2, measure2 = pH, dataset = bland1995) ggplot2::ggplot(bland1995, ggplot2::aes(x = PaCO2, y = pH, color = factor(Subject))) + geom_rmc(my.rmc) ##manually: ggplot2::ggplot(bland1995, ggplot2::aes(x = PaCO2, y = pH, color = factor(Subject))) + ggplot2::geom_point(ggplot2::aes(colour = factor(Subject))) + ggplot2::geom_line(ggplot2::aes(y = my.rmc$model$fitted.values), linetype = 1) ##another example: ##new theme, remove legend, and custom color pal ggplot2::ggplot(bland1995, ggplot2::aes(x = PaCO2, y = pH, color = factor(Subject))) + geom_rmc(my.rmc) + ggplot2::theme_minimal() + ggplot2::theme(legend.position="none") + ggplot2::scale_color_brewer(palette="Dark2")
my.rmc <- rmcorr(participant = Subject, measure1 = PaCO2, measure2 = pH, dataset = bland1995) ggplot2::ggplot(bland1995, ggplot2::aes(x = PaCO2, y = pH, color = factor(Subject))) + geom_rmc(my.rmc) ##manually: ggplot2::ggplot(bland1995, ggplot2::aes(x = PaCO2, y = pH, color = factor(Subject))) + ggplot2::geom_point(ggplot2::aes(colour = factor(Subject))) + ggplot2::geom_line(ggplot2::aes(y = my.rmc$model$fitted.values), linetype = 1) ##another example: ##new theme, remove legend, and custom color pal ggplot2::ggplot(bland1995, ggplot2::aes(x = PaCO2, y = pH, color = factor(Subject))) + geom_rmc(my.rmc) + ggplot2::theme_minimal() + ggplot2::theme(legend.position="none") + ggplot2::scale_color_brewer(palette="Dark2")
A dataset containing four repeated measurements of reaction time (RT) and accuracy from eleven subjects in a visual search experiment. Each measurement is the mean RT and accuracy from a block of 288 search trials. blocks of visual search, for eleven subjects.
gilden2010
gilden2010
A data frame with 44 rows and 4 variables
[,1] |
sub |
Subject ID |
[,2] |
block |
Block ID |
[,3] |
rt |
Mean reaction time |
[,4] |
acc |
Mean accuracy |
Gilden, D.L., Thornton, T.L., & Marusich, L.R. (2010). The serial process in visual search. Journal of Experimental Psychology: Human Perception and Performance, 36, 533-542, doi:10.1037/a0016464
A summary dataset from non-independent units of analysis (six regions nesting 50 U.S. states and 3 U.S. territories) with multivariate (composite) measures. This is a survey assessing patient experience for hospitalized care, the Hospital Consumer Assessment of Healthcare Providers and Systems (HCAHPS) Survey; also referred to as the CAHPS® Hospital Survey. The data were publicly released in April 2023 by the U.S. Centers for Medicare & Medicaid Services (CMS).
HCAHPS is a standardized and validated survey instrument for evaluating patient experience. Patient experience is an indicator of healthcare quality and is defined as the "... range of interactions at patients have with the healthcare system, including their care from health plans, and from doctors, nurses, and staff in hospitals..." https://web.archive.org/web/20230206233908/https://www.ahrq.gov/cahps/about-cahps/patient-experience/index.html.
The HCAHPS composite measures consist of multiple questions and, here, are top box scores (see https://www.hcahpsonline.org/en/summary-analyses/). In addition to patient experience, there are additional measures such as whether the hospital is recommended or not, the number or participating hospitals, and the survey response rate
Note this is not a representative sample
Measures are averaged at the state/territory level
Respondents were discharged from a hospital between July 2021 to July 2022
Results are patient-mix adjusted, see doi:10.1111/j.1475-6773.2008.00914.x
Additional Information:
For details about the data and questions comprising composite measures, see https://www.hcahpsonline.org/globalassets/hcahps/star-ratings/tech-notes/april_2023_star-ratings_tech_notes.pdf
For the specific questions on the HCAHPS survey, see https://www.hcahpsonline.org/globalassets/hcahps/quality-assurance/2023_survey-instruments_english_mail.pdf
CAHPS® is a registered trademark of the U.S. Agency for Healthcare Research and Quality: https://www.ahrq.gov/cahps/about-cahps/using-cahps-name/index.html
HCAHPS2022
HCAHPS2022
A data frame with 53 rows and 14 columns
[,1] |
State |
Unique identifier for each U.S. state/territory, see https://npiregistry.cms.hhs.gov/help-api/state |
[,2] |
Region |
The region nesting states and territories, according to the U.S. Census Bureau |
[,3] |
Communication with Nurses |
Composite measure (3 questions) for nurse communication with patient (e.g., "During this hospital stay, how often did nurses listen carefully to you?") |
[,4] |
Communication with Doctors |
Composite measure (3 questions) for doctor communication with patient (e.g., "During this hospital stay, how often did doctors explain things in a way you could understand?") |
[,5] |
Responsiveness of Hospital Staff |
Composite measure (2 questions) for responsiveness of hospital staff (e.g., How often did you get help in getting to the bathroom or in using a bedpan as soon as you wanted?) |
[,6] |
Communication About Medicines |
Composite measure (2 questions) for healthcare provider communication about medicines (e.g., Before giving you any new medicine, how often did hospital staff tell you what the medicine was for?) |
[,7] |
Cleanliness of Hospital Environment |
Individual item: "During this hospital stay, how often were your room and bathroom kept clean?" |
[,8] |
Quietness of Hospital Environment |
Individual item: "During this hospital stay, how often was the area around your room quiet at night?" |
[,9] |
Discharge Information |
Composite measure (2 questions) for communication about care needed after leaving the hospital (e.g., was help needed after leaving the hospital discussed?) |
[,10] |
Care Transition |
Composite measure (3 questions) for understanding of care needed (e.g., "When I left the hospital, I had a good understanding of the things I was responsible for in managing my health?") |
[,11] |
Hospital Rating |
Ten point Likert scale rating of hospital (worse possible to best possible) |
[,12] |
Recommend the Hospital |
Individual item: "Would you recommend this hospital...?" Percent of "yes" responses |
[,13] |
Participating Hospitals |
Number of participating hospitals in the region |
[,14] |
Survey Response Rate |
Patient survey response rate for each state/territory (%) |
CAHPS Hospital Survey (2022). HCAHPS Survey Results Table (Dataset) https://www.hcahpsonline.org/globalassets/hcahps/summary-analyses/summary-results/april-2023-public-report-july-2021—june-2022-discharges.pdf
A dataset containing three repeated measures of dyads (paired participants) working together to capture High Value Targets (lower task time is better performance) and their averaged Mission Awareness Rating Scale (MARS) score for each block, repeated three times. MARS evaluates subjective situation awareness (”knowing what is going on”), higher values indicate better situation awareness.
marusich2016_exp2
marusich2016_exp2
A data frame with 84 rows (28 dyads/pairs) and 4 variables
[,1] |
Pair |
Unique identifer for each dyad |
[,2] |
HVT_capture |
Capture time |
[,3] |
MARS |
subjective situation awareness |
[,4] |
Source Reliability |
1 = none, 2 = accurate, and 3 = inaccurate |
Marusich et al. (2016). Effects of information availability on command-and-control decision making: performance, trust, and situation awareness. Human Factors, 58(2), 301-321, doi:10.1177/0018720815619515
plot.rmc
produces a scatterplot of measure1
on the x-axis and
measure2
on the y-axis, with a different color used for each subject.
Parallel lines are fitted to each subject's data.
## S3 method for class 'rmc' plot(x, palette = NULL, xlab = NULL, ylab = NULL, ...)
## S3 method for class 'rmc' plot(x, palette = NULL, xlab = NULL, ylab = NULL, ...)
x |
an object of class "rmc" generated from the |
palette |
the palette to be used. Defaults to the RColorBrewer "Paired" palette |
xlab |
label for the x axis, defaults to the variable name for measure1. |
ylab |
label for the y axis, defaults to the variable name for measure2. |
... |
additional arguments to |
rmcorr, geom_rmc for plotting with ggplot
## Bland Altman 1995 data my.rmc <- rmcorr(participant = Subject, measure1 = PaCO2, measure2 = pH, dataset = bland1995) plot(my.rmc) ## Raz et al. 2005 data my.rmc <- rmcorr(participant = Participant, measure1 = Age, measure2 = Volume, dataset = raz2005) library(RColorBrewer) blueset <- brewer.pal(8, 'Blues') pal <- colorRampPalette(blueset) plot(my.rmc, overall = TRUE, palette = pal, overall.col = 'black') ## Gilden et al. 2010 data my.rmc <- rmcorr(participant = sub, measure1 = rt, measure2 = acc, dataset = gilden2010) plot(my.rmc, overall = FALSE, lty = 2, xlab = "Reaction Time", ylab = "Accuracy")
## Bland Altman 1995 data my.rmc <- rmcorr(participant = Subject, measure1 = PaCO2, measure2 = pH, dataset = bland1995) plot(my.rmc) ## Raz et al. 2005 data my.rmc <- rmcorr(participant = Participant, measure1 = Age, measure2 = Volume, dataset = raz2005) library(RColorBrewer) blueset <- brewer.pal(8, 'Blues') pal <- colorRampPalette(blueset) plot(my.rmc, overall = TRUE, palette = pal, overall.col = 'black') ## Gilden et al. 2010 data my.rmc <- rmcorr(participant = sub, measure1 = rt, measure2 = acc, dataset = gilden2010) plot(my.rmc, overall = FALSE, lty = 2, xlab = "Reaction Time", ylab = "Accuracy")
Print the results of a repeated measures correlation
## S3 method for class 'rmc' print(x, ...)
## S3 method for class 'rmc' print(x, ...)
x |
An object of class "rmc", a result of a call to rmcorr. |
... |
additional arguments to |
## Bland Altman 1995 data blandrmc <- rmcorr(Subject, PaCO2, pH, bland1995) blandrmc
## Bland Altman 1995 data blandrmc <- rmcorr(Subject, PaCO2, pH, bland1995) blandrmc
Print the repeated measures correlation matrix
## S3 method for class 'rmcmat' print(x, ...)
## S3 method for class 'rmcmat' print(x, ...)
x |
An object of class "rmcmat", a result of a call to |
... |
additional arguments to |
## Bland Altman 1995 data blandrmc <- rmcorr(Subject, PaCO2, pH, bland1995) blandrmc
## Bland Altman 1995 data blandrmc <- rmcorr(Subject, PaCO2, pH, bland1995) blandrmc
A dataset containing two repeated measures, on two occasions
(Time
), of age and adjusted volume of cerebellar hemispheres from 72
participants. Data were captured from Figure 8, Cerebellar Hemispheres
(lower right) of Raz et al. (2005).
raz2005
raz2005
A data frame with 144 rows and 4 variables
[,1] |
Participant |
Participant ID |
[,2] |
Time |
Measurement time |
[,3] |
Age |
Participant's age (years) |
[,4] |
Volume |
Adjusted volume of cerebellar hemispheres (cm^3) |
Raz, N., Lindenberger, U., Rodrigue, K.M., Kennedy, K.M., Head, D., Williamson, A., Dahle, C., Gerstorf, D., & Acker, J.D. (2005). Regional brain changes in aging healthy adults: General trends, individual differences, and modifiers. Cerebral Cortex, 15, 1676-1689, doi:10.1093/cercor/bhi044
Calculate the repeated measures correlation coefficient.
rmcorr( participant, measure1, measure2, dataset, CI.level = 0.95, CIs = c("analytic", "bootstrap"), nreps = 100, bstrap.out = F )
rmcorr( participant, measure1, measure2, dataset, CI.level = 0.95, CIs = c("analytic", "bootstrap"), nreps = 100, bstrap.out = F )
participant |
A variable giving the subject name/id for each observation. |
measure1 |
A numeric variable giving the observations for one measure. |
measure2 |
A numeric variable giving the observations for the second measure. |
dataset |
The data frame containing the variables. |
CI.level |
The confidence level of the interval |
CIs |
The method of calculating confidence intervals. |
nreps |
The number of resamples to take if bootstrapping. |
bstrap.out |
Determines if the output include the bootstrap resamples. |
A list with class "rmc" containing the following components.
r |
the value of the repeated measures correlation coefficient. |
df |
the degrees of freedom |
p |
the p-value for the repeated measures correlation coefficient. |
CI |
the 95% confidence interval for the repeated measures correlation coefficient. |
model |
the multiple regression model used to calculate the correlation coefficient. |
resamples |
the bootstrap resampled correlation values. |
Bakdash, J.Z., & Marusich, L.R. (2017). Repeated Measures Correlation. Frontiers in Psychology, 8, 456, doi:10.3389/fpsyg.2017.00456.
Bakdash, J. Z., & Marusich, L. R. (2019). Corrigendum: Repeated Measures Correlation. Frontiers in Psychology, 10, doi:10.3389/fpsyg.2019.01201.
Bland, J.M., & Altman, D.G. (1995a). Calculating correlation coefficients with repeated observations: Part 1 – correlation within subjects. BMJ, 310, 446, doi:10.1136/bmj.310.6977.446
Bland, J.M., & Altman, D.G. (1995b). Calculating correlation coefficients with repeated observations: Part 2 – correlation within subjects. BMJ, 310, 633, doi:10.1136/bmj.310.6980.633
## Bland Altman 1995 data rmcorr(Subject, PaCO2, pH, bland1995)
## Bland Altman 1995 data rmcorr(Subject, PaCO2, pH, bland1995)
Create a repeated measures correlation matrix.
rmcorr_mat(participant, variables, dataset, CI.level = 0.95)
rmcorr_mat(participant, variables, dataset, CI.level = 0.95)
participant |
A variable giving the subject name/id for each observation. |
variables |
A character vector indicating the columns of variables to include in the correlation matrix. |
dataset |
The data frame containing the variables. |
CI.level |
The level of confidence intervals to use in the rmcorr models. |
A list with class "rmcmat" containing the following components.
matrix |
the repeated measures correlation matrix |
summary |
a dataframe showing rmcorr stats for each pair of variables |
models |
a list of the full rmcorr model for each pair of variables |
Bakdash, J.Z., & Marusich, L.R. (2017). Repeated Measures Correlation. Frontiers in Psychology, 8, 456. doi:10.3389/fpsyg.2017.00456.
Bland, J.M., & Altman, D.G. (1995). Calculating correlation coefficients with repeated observations: Part 1 – correlation within subjects. BMJ, 310, 446, doi:10.1136/bmj.310.6977.446.
Cohen, P., West, S. G., & Aiken, L. S. (2002). Applied multiple regression/correlation analysis for the behavioral sciences (3rd edition), Routledge. ISBN: 9780805822236.
dist_rmc_mat <- rmcorr_mat(participant = Subject, variables = c("Blindwalk Away", "Blindwalk Toward", "Triangulated BW", "Verbal", "Visual matching"), dataset = twedt_dist_measures, CI.level = 0.95) plot(dist_rmc_mat$models[[2]])
dist_rmc_mat <- rmcorr_mat(participant = Subject, variables = c("Blindwalk Away", "Blindwalk Toward", "Triangulated BW", "Verbal", "Visual matching"), dataset = twedt_dist_measures, CI.level = 0.95) plot(dist_rmc_mat$models[[2]])
A dataset of repeated measures of distance perception at physical distances of 7, 8, 9, 10, and 11 meters. The data are also multivariate, with five dependent measures of distance perception. This is a 5 (physical distance) x 5 (dependent measure) within-participants design with a sample size of 46. Note data is missing for 15 trials due to participant and experimenter errors.
twedt_dist_measures
twedt_dist_measures
A data frame with 230 rows and 7 columns
[,1] |
Subject |
Unique identifier for each participant |
[,2] |
Physical Distance |
Physical distance from the participant to the target cone, in meters |
[,3] |
Blindwalk Away |
Participants put on the blindfold after viewing the target. Next, participants took one step to the left and turned 180 degrees to face the opposite direction. Participants were instructed to walk forward until they had walked the original distance to the target |
[,4] |
Blindwalk Toward |
Participants put on the blindfold after viewing the target. Next, participants walked forward until they thought they had reached the target cone |
[,5] |
Triangulated BW |
Participants put on the blindfold after viewing the target. Next, participants turned right 90 degrees and walked forward 5 meters. The experimenter told participants when to stop walking. Finally, participants turned to face toward the target and walked forward two steps |
[,6] |
Verbal |
Participants stated the distance between the target cone and themselves, in feet and inches |
[,7] |
Visual Matching |
An experimenter stood next to the target cone and walked away from the cone in a straight line that was perpendicular to the extent between the target and the participant. Participants instructed the experimenter to stop walking when they thought that the distance between the target and the experimenter was equal to the target distance |
Twedt, E. Bakdash, J.Z., and Proffitt, D.R. (2022). Repeated and multivariate measures of perceived distance (Dataset) doi:10.5281/zenodo.6967162