我有一个矩阵x:
> x
x1 x2
[1,] 6 9
[2,] 10 6
[3,] 8 3
我正在尝试统计T ^ 2:
> library(DescTools)
> HotellingsT2Test(x)
Hotelling's one sample T2-test for mu' = [9, 5]
data: x
T.2 = 28, df1 = 2, df2 = 1, p-value = 0.1325
alternative hypothesis: true location is not equal to c(0,0)
统计数据似乎已关闭(正确答案为7/9)。我究竟做错了什么?
其他变量:
> mu
[1] 9 5
> means
x1 x2
8 6
> S # variance-covariance matrix
[,1] [,2]
[1,] 4 -3
[2,] -3 9
> S_inv # inverse matrix
[,1] [,2]
[1,] 0.3333333 0.1111111
[2,] 0.1111111 0.1481481
答案 0 :(得分:1)
首先,您没有向函数提供mu
参数。但是然后
HotellingsT2Test(x, mu = mu)
#
# Hotelling's one sample T2-test
#
# data: x
# T.2 = 0.19444, df1 = 2, df2 = 1, p-value = 0.8485
# alternative hypothesis: true location is not equal to c(9,5)
仍然不是您所期望的,这是因为默认情况下该决定基于F分布,在这种情况下,统计量将乘以另一个因子(即(n-p)/(p *( n-1)),其中n = 3,p = 2。使用卡方逼近,我们可以根据需要获得
HotellingsT2Test(x, mu = mu, test = "chi")
#
# Hotelling's one sample T2-test
#
# data: x
# T.2 = 0.77778, df = 2, p-value = 0.6778
# alternative hypothesis: true location is not equal to c(9,5)