首页 文章

使用Bootstrapping进行比例的置信区间 - Matlab

提问于
浏览
0

我有一个简单的nx1整数数组,我想引导它来评估比例的置信区间 .

我想用matlab做这个分析,你可以在这里找到例子:http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp?topic=%2Fcom.ibm.spss.statistics.cs%2Fbootstrap_telco_frequencies_table.htm

在Matlab中我有这些数据,它来自名为 c 的数组的列表:

Value | Count | Percent
  1      300      2.99%
  2     2928     29.16%
  3        0      0.00%
  4     3244     32.31%
  5        0      0.00%
  6     2589     25.78%
  7      980      9.76%

我尝试使用BOOTFUN作为bootstrap置信区间,如下表达式:

n = histc(c,unique(c))/sum(n);

我的意思是 n 前一个数组的比例 .

最后我使用bootci函数来评估间隔:

ci= bootci(1000,n,c);

我知道我在bootfun的设置上错了,但我不知道如何解决它,因此我想得到你的帮助 . 我希望问题很清楚 .

1 回答

  • 0

    你可以看看这样的东西

    >> proportions = @(x) histc(x, unique(x)) / length(x); # NB this is a function
    >> x = randsample(1:6, 100, 1);        # sample with replacement from 1:6
    >> ci = bootci(10000, @proportions, x) # compute 95% confidence intervals
    0.0600    0.1100    0.0400    0.1700    0.1300    0.1100
    0.1800    0.2700    0.1600    0.3400    0.2900    0.2500
    

    第一类的置信区间为(6%,18%),第二类为(11%,27%)等 .

相关问题