Need Greater Confidence in Your Confidence Intervals?

栏目: IT技术 · 发布时间: 4年前

内容简介:For those catching up here, bootstrap sampling refers to the process of sampling a given dataset ‘with replacement’… And this is where most people get lost. You take many samples and build a distribution to mark your confidence interval.Let’s take a quick

What is Bootstrap Replication Anyway?

Apr 27 ·3min read

Need Greater Confidence in Your Confidence Intervals?

by Peter H on Pixabay.com

What is Bootstrap Replication?

For those catching up here, bootstrap sampling refers to the process of sampling a given dataset ‘with replacement’… And this is where most people get lost. You take many samples and build a distribution to mark your confidence interval.

Let’s take a quick example.

Crypto at College

Let’s say that you want to find out how the general population at a college feels about cryptocurrency; well, you likely won’t be able to gather responses from everybody in the school; what will probably happen is that you’ll distribute some survey and you’ll get back a handful of responses that you hope are indicative of the general populous’ opinion, good or bad.

While you have a clear idea about the distribution among your respondents, you want to generate a realistic confidence interval that would be more indicative of the entire school. This is where boostrap replication comes in!

Sampling with Replacement

So far we know that bootstrap replication is a sampling approach. The main idea here being that when one sample is selected, it can be selected over and over again. This serves the purpose of re-creating the random re-occurrence of a respondent type that may actually be due to random chance.

Each bootstrap sample is called a replication. In this case, lets assume 1000 replications.

Once we have our 1000 replicates or samples, we now have 1000 values for the sample mean.

From this distribution, we’ll get our actual confidence interval.

Let’s say we want a confidence interval of 95%; we would get this by looking at our bootstrap distribution and taking the 2.5th value and the 97.5th value the act as our interval.

Let's Look at Some Code!

library(infer) 
replicates <- crypto_opinions %>% 
    specify(response = opinion, success = "positive") %>% 
    generate(reps = 1, type = "bootstrap")replicates %>% 
    summarize(prop_high = mean(response == 'positive')) %>% 
    pull()

We use specify to isolate the response variable we care about and what the variable value determines 'success'. From there we use generate to create our first bootstrap replicate. You'll also notice that we specify the type as bootstrap . We then use summarize and pull to generate a proportion of the specified level 'positive'.

replicates <- crypto_opinions %>% 
    specify(response = opinion, success = "positive") %>%        generate(reps = 1000, type = "bootstrap")%>% calculate(stat = "prop")

Similar to the former code block, we’ve expanded our repetitions to 1000 and are now chaining in the calculate function. The calculate function creates a data frame with one record for each replicate "stat" that corresponded to that replicate.

ggplot(replicates, aes(stat)) +
   geom_density()

Need Greater Confidence in Your Confidence Intervals?

The above chart shows you the density chart or distribution of the average outcome per each replicate.

From here it’s just a simple matter of calculating, the standard deviation and using that to identify the top and bottom of your range!

Lower_bound <- mean(replicates$stat) - sd(replicates$stat) * 2 upper_bound <- mean(replicates$stat) + sd(replicates$stat) * 2

Conclusion

I hope you’ve enjoyed this post and that it saves you some time! Please share whatever works and whatever doesn’t!

Feel free to check out some of my other posts at datasciencelessons.com

Happy Data Science-ing!


以上所述就是小编给大家介绍的《Need Greater Confidence in Your Confidence Intervals?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Wireshark网络分析实战

Wireshark网络分析实战

[以色列 Yoram Orzach / 古宏霞、孙余强 / 人民邮电出版社 / 2015-1 / 79.00元

本书采用步骤式为读者讲解了一些使用Wireshark来解决网络实际问题的技巧。 本书共分为14章,其内容涵盖了Wireshark的基础知识,抓包过滤器的用法,显示过滤器的用法,基本/高级信息统计工具的用法,Expert Info工具的用法,Wiresahrk在Ethernet、LAN及无线LAN中的用法,ARP和IP故障分析,TCP/UDP故障分析,HTTP和DNS故障分析,企业网应用程序行......一起来看看 《Wireshark网络分析实战》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具