Concurrence is the number of times two locations on the CBM are endorsed together by patients in a data set. For example, take two patients where one endorses the locations numbered “101, 102, 103, 104, 201, 202” and the other indicates “101, 102, 201, 202.” In this case, the location coded “101” co-occurs with “103” and “104” once, but with “102”, “201”, and “202” twice. This is helpful to calculate, for example, because we can use this for CBMs across different conditions to determine if certain pain locations are more commonly endorsed together due to a particular pathology.
In this vignette, we will go over calculating and visualizing the concurrence matrix for a randomly sampled portion of the validation data distributed with the CHOIRBM package.
data(validation)
set.seed(123)
sampled_data <- validation[
sample(
seq_len(nrow(validation))
, 100
, replace = FALSE
)
, ]
We will then use the comp_concurrence()
function to
calculate the co-occurrence of each location on the CBM. For the
purposes of generalizability, the function requires the column of data
containing a patient’s CBM to be in a string-delimited form and with the
column name “bodymap.”
colnames(sampled_data)[5] <- "bodymap" # name the body map column 'bodymap'
con_mat <- comp_cooccurrence(sampled_data)
head(con_mat)
#> Var1 Var2 cooccurrence
#> 1 101 101 0
#> 2 101 102 9
#> 3 101 103 4
#> 4 101 104 4
#> 5 101 105 3
#> 6 101 106 1
As we can see, the concurrence matrix is in a “long” form, where each
row is one pairing of CBM locations and the number of times they occur
together in the data set. The function’s output is formatted this way
for the sake of plotting with the plot_concurrence()
function.