R-如何在psych包中正确运行testRetest命令?

R-如何在psych包中正确运行testRetest命令?,r,psych,R,Psych,我有一个非常简单的问题,但我不知道发生了什么。我想使用psych软件包计算在时间1time1和时间2time2测量的变量的重测信度。命令告诉我找不到对象“值”。我不知道这意味着什么。任何帮助都将不胜感激 psych::testRetest(t1=df$time1, t2=df$time2) df <- structure(list(time1 = c(2.11111111111111, 2.05555555555556, 4.44444444444444, 5.888888888888

我有一个非常简单的问题,但我不知道发生了什么。我想使用psych软件包计算在时间1
time1
和时间2
time2
测量的变量的重测信度。命令告诉我找不到对象“值”。我不知道这意味着什么。任何帮助都将不胜感激

psych::testRetest(t1=df$time1, t2=df$time2)

df <- structure(list(time1 = c(2.11111111111111, 2.05555555555556, 
4.44444444444444, 5.88888888888889, 5.16666666666667, 1.94444444444444, 
4.11111111111111, 2.22222222222222, 1.61111111111111, 1.5, 3.33333333333333, 
2.33333333333333, 3.66666666666667, 1.72222222222222, 4, 1.88888888888889, 
1.66666666666667, 3.33333333333333, 2.38888888888889, 2.77777777777778, 
2.38888888888889, 4.83333333333333, 1.88888888888889, 4, 2.61111111111111, 
4.83333333333333, 1.27777777777778, 1.55555555555556, 1.72222222222222, 
2.33333333333333, 2.16666666666667, 2.94444444444444, 2.11111111111111, 
1.11111111111111, 3.05555555555556, 3.5, 2.05555555555556, 6.16666666666667, 
2.33333333333333, 2.33333333333333, 2.77777777777778, 1.61111111111111, 
4, 1.27777777777778, 1.27777777777778, 3.16666666666667, 5.77777777777778, 
1.88888888888889, 1.94444444444444, 4.66666666666667, 3.5, 4.5, 
4.16666666666667, 3.94444444444444, 3.16666666666667, 2.11111111111111, 
2.44444444444444, 3.55555555555556, 2.94444444444444, 1.33333333333333, 
3.22222222222222, 4.94444444444444, 2.44444444444444, 4.11111111111111, 
2.38888888888889, 2.44444444444444, 3.5, 2.77777777777778, 4.77777777777778, 
3.77777777777778, 2.22222222222222, 2.11111111111111, 3.16666666666667, 
2.61111111111111, 2.16666666666667, 4.61111111111111, 4.83333333333333, 
4.72222222222222, 2.5, 3.44444444444444, 3.77777777777778, 2.22222222222222, 
3.88888888888889, 2.88888888888889, 2.16666666666667, 4.27777777777778, 
2.77777777777778, 3.5, 2.72222222222222, 3.61111111111111, 4.83333333333333, 
2.44444444444444, 4.27777777777778, 3.5, 4.72222222222222, 3.66666666666667, 
3.33333333333333, 3.5, 2.11111111111111, 2.22222222222222, 3.44444444444444, 
1.83333333333333, 1.94444444444444, 3.88888888888889, 4.33333333333333, 
2.83333333333333, 1.05555555555556, 4.61111111111111, 4.16666666666667, 
2.88888888888889, 2.11111111111111, 1.55555555555556, 2.5, 3.16666666666667, 
2.5, 4.05555555555556, 3.55555555555556, 4.83333333333333, 5.05555555555556, 
3.61111111111111, 2.27777777777778, 2.38888888888889, 3.55555555555556, 
1.94444444444444, 2.66666666666667, 4.38888888888889), time2 = c(2.05555555555556, 
2, 4.33333333333333, 5.55555555555556, 4.83333333333333, 1.94444444444444, 
4.33333333333333, 2.16666666666667, 1.44444444444444, 1.61111111111111, 
3.94444444444444, 1.83333333333333, 4.44444444444444, 1.5, 3.61111111111111, 
2.22222222222222, 2.5, 3.38888888888889, 2.55555555555556, 2.77777777777778, 
2.72222222222222, 5.55555555555556, 1.77777777777778, 3.77777777777778, 
2.83333333333333, 5.33333333333333, 1.5, 1.44444444444444, 1.33333333333333, 
2.44444444444444, 1.88888888888889, 3, 2, 1.33333333333333, 3.05555555555556, 
3.33333333333333, 1.94444444444444, 5.72222222222222, 2.38888888888889, 
2.61111111111111, 3.55555555555556, 1.94444444444444, 3.72222222222222, 
1.38888888888889, 1.38888888888889, 2.83333333333333, 5.72222222222222, 
1.83333333333333, 2.05555555555556, 4.5, 3.38888888888889, 4.94444444444444, 
4.27777777777778, 4.38888888888889, 2.44444444444444, 2.16666666666667, 
2.83333333333333, 3.72222222222222, 2.66666666666667, 1.16666666666667, 
2.72222222222222, 5.22222222222222, 2.11111111111111, 4.38888888888889, 
2.38888888888889, 4, 3.83333333333333, 2.22222222222222, 5.16666666666667, 
4.11111111111111, 1.94444444444444, 2.22222222222222, 3.55555555555556, 
2.88888888888889, 2.11111111111111, 4.61111111111111, 4.72222222222222, 
4.61111111111111, 2.16666666666667, 3.61111111111111, 3.66666666666667, 
2.94444444444444, 4.05555555555556, 3.27777777777778, 2.11111111111111, 
4.38888888888889, 2.83333333333333, 2.55555555555556, 3.16666666666667, 
3.33333333333333, 4.77777777777778, 2.55555555555556, 4.38888888888889, 
2.94444444444444, 4.77777777777778, 3.77777777777778, 3.33333333333333, 
3.55555555555556, 1.88888888888889, 2, 3.83333333333333, 2.22222222222222, 
1.38888888888889, 3.33333333333333, 3.27777777777778, 2.83333333333333, 
1.05555555555556, 4.61111111111111, 4.38888888888889, 2.94444444444444, 
1.94444444444444, 1.88888888888889, 2.22222222222222, 3.16666666666667, 
2.11111111111111, 5.5, 4.11111111111111, 4.83333333333333, 4.44444444444444, 
3.88888888888889, 2.05555555555556, 2, 3.44444444444444, 2.16666666666667, 
2.77777777777778, 4.72222222222222)), row.names = c(1L, 2L, 3L, 
4L, 5L, 6L, 8L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 18L, 19L, 
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 43L, 44L, 45L, 46L, 47L, 
48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 59L, 60L, 61L, 
63L, 64L, 65L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 
77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 86L, 88L, 89L, 90L, 91L, 
93L, 94L, 95L, 96L, 98L, 99L, 100L, 104L, 105L, 106L, 107L, 108L, 
109L, 110L, 111L, 112L, 114L, 116L, 117L, 118L, 119L, 120L, 121L, 
122L, 123L, 125L, 127L, 128L, 130L, 132L, 133L, 134L, 139L, 141L, 
144L, 146L, 147L, 149L, 150L, 154L, 156L, 157L, 158L, 163L, 167L
), class = "data.frame")
psych::testRetest(t1=df$time1,t2=df$time2)

df似乎
psych
中的
testRetest()
不适合查看单个项目;它面向多个项目,这些项目形成一个规模(如果您查看,返回值-除了r12-不适用于单个项目)

如果您正在寻找一种简单的重测信度,那么使用以下方法如何:

cor(df$time1, df$time2)
如果您正在使用
testRetest()
查看多个项目,您可能还希望
pivot\u longer()
您的数据(即,有一个指定测量时间点的“时间”列):

但如果我们添加另一项(随机数据),
testreset()
将起作用:

df2 <- df2 %>% 
  mutate(item2 = sample(0:100, n(), replace = TRUE))

testRetest(as.data.frame(df2), select = c("item1", "item2"))

# A tibble: 6 x 3
     id time  item1
  <int> <chr> <dbl>
1     1 1      2.11
2     1 2      2.06
3     2 1      2.06
4     2 2      2   
5     3 1      4.44
6     3 2      4.33
testRetest(as.data.frame(df2), select = "item1")

# Error: grouping factors must have > 1 sampled level
df2 <- df2 %>% 
  mutate(item2 = sample(0:100, n(), replace = TRUE))

testRetest(as.data.frame(df2), select = c("item1", "item2"))

Test Retest reliability 
Call: testRetest(t1 = as.data.frame(df2), select = c("item1", 
"item2"))

Number of subjects =  126  Number of items =  2
 Correlation of scale scores over time -0.11
 Alpha reliability statistics for time 1 and time 2 
       raw G3 std G3   G6 av.r  S/N   se lower upper var.r
Time 1   0.01   0.06 0.03 0.03 0.07 0.03  0.07     1     0
Time 2   0.01   0.11 0.06 0.06 0.12 0.03  0.11     1     0