I want to analyse my data using the purr package and psych package. Here is part of my data:
df <- tribble(
~temp1, ~temp2, ~temp3, ~temp4, ~temp5, ~temp6, ~temp7, ~temp8,
75, 88, 85, 71, 98, 76, 71, 57,
80, 51, 84, 72, 59, 81, 70, 64,
54, 65, 90, 66, 93, 88, 77, 59,
59, 87, 94, 75, 74, 53, 56, 87,
52, 55, 64, 77, 50, 64, 83, 87,
)
Here, I want to match pay1 with pay2, pay3 with pay4 and pay5 with pay6 only. I could do it using the purr package for some methods, for example, correlation, I could use the following codes:
df %>%
split.default(rep_len(1:2, ncol(.))) %>%
pmap_dbl(~ cor( .x,.y))
But It does not work for ICC
in the psych
package
df %>%
split.default(rep_len(1:2, ncol(.))) %>%
pmap_dbl(~ ICC( .x,.y))
Can we do ICC
using the psych
package, basic r or other packages?
We can use pmap
here since ICC
doesn't return numeric values but an output of class "psych" "ICC"
..
library(purrr)
library(psych)
df %>% split.default(rep_len(1:2, ncol(.))) %>% pmap(~ICC(cbind(..1, ..2)))
#$temp1
#Call: ICC(x = cbind(..1, ..2))
#Intraclass correlation coefficients
# type ICC F df1 df2 p lower bound upper bound
#Single_raters_absolute ICC1 0.12 1.3 4 5 0.39 -0.61 0.78
#Single_random_raters ICC2 0.12 1.3 4 4 0.41 -0.65 0.78
#Single_fixed_raters ICC3 0.12 1.3 4 4 0.41 -0.67 0.78
#Average_raters_absolute ICC1k 0.21 1.3 4 5 0.39 -3.11 0.87
#Average_random_raters ICC2k 0.21 1.3 4 4 0.41 -3.68 0.88
#Average_fixed_raters ICC3k 0.21 1.3 4 4 0.41 -4.06 0.88
# Number of subjects = 5 Number of Judges = 2
#$temp3
#Call: ICC(x = cbind(..1, ..2))
#Intraclass correlation coefficients
# type ICC F df1 df2 p lower bound upper bound
#Single_raters_absolute ICC1 -0.24 0.61 4 5 0.67 -0.79 0.59
#...
#...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.