【问题标题】:Using Bootstrapping for Confidence Intervals for Proportions - Matlab使用自举法计算比例的置信区间 - Matlab
【发布时间】:2013-07-30 10:33:21
【问题描述】:

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

我找到了 IBM SPSS 的解决方案,但我想使用 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,如下表达式:

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

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

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

ci= bootci(1000,n,c);

我知道我的 bootfun 设置有误,但我不知道如何修复它,因此我希望得到您的帮助。我希望问题足够清楚。

【问题讨论】:

    标签: matlab statistics-bootstrap


    【解决方案1】:

    你可以看看这样的东西

    >> 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%),依此类推。

    【讨论】:

    • 嗨,克里斯,非常感谢您的帮助。我在 R2009b 中使用了您的代码:全部清除;比例 = @(x) histc(x, unique(x)) / length(x); %NB 这是一个函数 x = randsample(1:6, 100, 1); % 样本替换为 1:6 ci = bootci(10000, ratios, x) ; % 计算 95 个置信区间,但我收到此错误:???在 160 处使用 ==> bootci 时出错 BOOTFUN 必须返回标量。错误 ==> Untitled at 4 ci = bootci(10000, ratios, x) ; %计算 95 个置信区间
    猜你喜欢
    • 1970-01-01
    • 2021-04-12
    • 2020-12-30
    • 2019-03-12
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多