Spearman-Brown struggle

I am trying to apply this example to my data to get a Spearman-Brown coefficient for a sum variable with two items.

# Generate two variables with different means, variances and a correlation of about 0.5
library(MASS)
vars = mvrnorm(30, mu = c(0, 2), Sigma = matrix(c(5, 2, 2, 3), ncol = 2), empirical = TRUE)
# Calculate coefficient based on Pearson correlation
spearman_brown(vars[,1], vars[,2])
# Calculate coefficient based on ICC, two-way, random effects, absolute agreement, single rater
spearman_brown(vars[,1], vars[,2], short_icc, type = "ICC1", lmer = FALSE)

But I don't get far because I don't understand that code. I don't know how to apply it to this data:

structure(list(var1 = c(5, 2, NA, 2, 3, 1, 6, 1, 4, 5, 5, 2, 
2, 3, 1, 3, 2, NA, 5, 7, 5, 2, 2, 2, NA, 2, NA, 2, 2, 5, 2, 4, 
2, 3, 5, 5, 2, 5, 5, 2, 4, NA, 6, 7, 7, 3), var2 = c(2, 1, NA, 
2, 2, 1, 1, 1, 2, 2, 3, 1, 2, 2, 1, 2, 2, NA, 3, 2, 1, 2, 2, 
1, NA, 1, NA, 1, 1, 2, 1, 1, 2, 2, 2, 4, 2, 3, 2, 2, 1, NA, 2, 
2, 4, 1)), row.names = c(NA, -46L), class = c("tbl_df", "tbl", 
"data.frame"))
  1. How should I modify this mvrnorm(30, mu = c(0, 2) ?
  2. How should I modify this Sigma = matrix(c(5, 2, 2, 3), ncol = 2) ?

Your questions are both regarding how the example data featured in your example code was generated; but you supposedly have your own data to analyse and therefore dont need to make up random data; You do not need mvrnorm, nor its Sigma/matrix input.

1 Like