在r中实现小样本的符号测试

时间:2017-06-23 20:24:20

标签: r statistics

我有一些样本量很小的非参数数据。我想使用sign test来测试某些变量是否与0明显不同。我使用了seen examples binom.test,但我不确定如何为我的数据实现它测试我感兴趣。

我想测试以下数据的中位数

data <- c(-300,-289,-315)

明显不同于0.我尝试过的函数如SIGN.test对我的小样本量不起作用。

我可以使用r中的功能吗?如果不是,我如何使用我的数据实施binom.test

1 个答案:

答案 0 :(得分:2)

符号测试具有零假设,即中位数M低于某个设定值M0。然后,符号测试将缩减为二项式测试,其中成功次数是低于M0的值的数量。使用您的数据,您可以执行

data <- c(-300,-289,-315)

binom.test(x = sum(!is.na(data)),
           n = sum(data < 0, na.rm = TRUE))

    Exact binomial test

data:  length(data) and sum(data < 0)
number of successes = 3, number of trials = 3, p-value = 0.25
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
 0.2924018 1.0000000
sample estimates:
probability of success 
                     1 

请注意,您的比较是中位数,而不是平均值。