R语言参数自抽样法Bootstrap:估计MSE、经验功效、杰克刀Jackknife、非参数自抽样法可视化自测题

本文涉及的产品
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
注册配置 MSE Nacos/ZooKeeper,118元/月
云原生网关 MSE Higress,422元/月
简介: R语言参数自抽样法Bootstrap:估计MSE、经验功效、杰克刀Jackknife、非参数自抽样法可视化自测题

全文链接:http://tecdat.cn/?p=27695


参数引导:估计 MSE


统计学问题:水平(k\)修剪后的平均值的MSE是多少?

我们如何回答它:估计从标准柯西分布(t 分布 w/df = 1)生成的大小为 20 的随机样本的水平 kk 修剪均值的 MSE。目标参数 θ 是中心或中位数。柯西分布不存在均值。在表中总结 MSE 的估计值 k=1,2,...9。

result=rep(0,9)for(j in 1:9){
  n<-20  for(i in 1:m){
    x<-sort(rcauchy(n))

参数自抽样法:经验功效计算


统计问题:随着零假设与现实之间的差异发生变化,功效如何变化?

我们如何回答:绘制 t 检验的经验功效曲线。

_t 检验的原假设是 _

。另一种选择是

您将从具有

_ 的正态分布总体中抽取大小为 20 的样本。您将使用 0.05 的显着性水平。_

显示当总体的实际平均值从 350 变为 650(增量为 10)时,功效如何变化。

y 轴是经验功效(通过 bootstrap 估计),x 轴是 \(\mu\) 的不同值(350、360、370 … 650)。

   x <- rnorm(n, mean = muA, sd = sigma) #抽取平均值=450的样本    ts <- t.test(x, mu = mu0) #对无效的mu=500进行t检验    ts$p.value

点击标题查阅往期内容


数据分享|R语言Bootstrap、百分位Bootstrap法抽样参数估计置信区间分析通勤时间和学生锻炼数据


01

02

03

04


参数自抽样法:经验功效计算


统计问题:样本量如何影响功效?


我们如何回答:创建更多的功效曲线,因为实际均值在 350 到 650 之间变化,但使用大小为 n = 10、n = 20、n = 30、n = 40 和 n = 50 的样本生成它们。同一图上的所有 5 条功效曲线。

pvals <- replicate(m, pvalue())
power <- mean(pvals <= 0.05)points(sequence,final2\[2,\],col="red",pch=1)points(sequence,final2\[3,\],col="blue",pch=2)

参数自抽样法:经验置信水平


统计问题:在制作 95% CI 时,如果我们的样本很小并且不是来自正态分布,我们是否仍有 95% 的置信度?

我们如何回答:根据样本为总体的平均值创建一堆置信区间 (95%)。

您的样本大小应为 16,取自具有 2 个自由度的卡方分布。

for(i in 1:m){
  samp=rchisq(n,df=2)
  mean=mean(samp)
  sd=sd(samp)
  upper=mean+qt(0.975,df=15)*sd/4

非参数自抽样法置信区间


统计问题:基于一个样本,我们可以为总体相关性创建一个置信区间吗?

我们如何回答:为相关统计量创建一个 bootstrap t 置信区间估计。

boot.ti <-
  function(x, B = 500, R = 100, level = .95, stattic){
    
    x <- as.matrix(x)
library(boot)       #for boot and boot.cidata(law, package = "bootstrap")dat <- law
ci <- boot.t.ci(dat, statistic = stat, B=2000, R=200)
ci

自抽样法后的Jackknife


统计问题:R 的标准误差的 bootstrap 估计的标准误差是多少?


我们如何回答: data(law) 像上一个问题一样使用。在 bootstrap 后执行 Jackknife 以获得标准误差估计的标准误差估计。(bootstrap 用于获得总体中 R 的 SE 的估计值。然后使用Jackknife法获得该 SE 估计值的 SE。)

indices <- matrix(0, nrow = B, ncol = n)
# 进行自举for(b in 1:B){
    i <- sample(1:n, size = n, replace = TRUE)
    LSAT <- law$LSAT\[i\]
#  jackknifefor(i in 1:n){
    keepers <- function(k){
         !any(k == i)   
    }


自测题


Submit the rendered HTML file. Make sure all requested output (tables, graphs, etc.) appear in your document when you submit.

Parametric Bootstrap: Estimate MSE

Statistical question: What is the MSE of a level \(k\) trimmed mean?

How we can answer it: Estimate the MSE of the level \(k\) trimmed mean for random samples of size 20 generated from a standard Cauchy distribution (t-distribution w/df = 1). The target parameter \(\theta\) is the center or median. The mean does not exist for a Cauchy distribution. Summarize the estimates of MSE in a table for \(k = 1, 2, ... 9\).

Parametric Bootstrap: Empirical Power Calculations

Statistical question: How does power change as the difference between the null hypothes and the reality changes?

How we can answer it: Plot an empirical power curve for a t-test.

The null hypothesis of the t-test is \(\mu = 500\). The alternative is \(\mu \ne 500\).

You will draw samples of size 20, from a normally distributed population with \(\sigma = 100\). You will use a significance level of 0.05.

Show how the power changes as the actual mean of the population changes from 350 to 650 (increments of 10).

On the y-axis will be the empirical power (estimated via bootstrap) and the x-axis will be the different values of \(\mu\) (350, 360, 370 … 650).

Parametric Bootstrap: Empirical Power Calculations

Statistical question: How does sample size affect power?

How we can answer it: Create more power curves as the actual mean varies from 350 to 650, but produce them for using samples of size n = 10, n = 20, n = 30, n = 40, and n = 50. Put all 5 power curves on the same plot.

Parametric Bootstrap: Empirical Confidence Level

Statistical question: When making a 95% CI, are we still 95% confident if our samples are small and do not come from a normal distribution?

How we can answer it: Create a bunch of Confidence Intervals (95%) for the mean of a population based on a sample.

\[\bar{x} \pm t^{*} \times \frac{s}{\sqrt{n}}\]

Your samples should be of size 16, drawn from a chi-squared distribution with 2 degrees of freedom.

Find the proportion of Confidence Intervals that fail to capture the true mean of the population. (Reminder: a chi-squared distribution with \(k\) degrees of freedom has a mean of \(k\).)

Non Parametric Bootstrap Confidence Interval

Statistical question: Based on one sample, can we create a confidence interval for the correlation of the population?

How we can answer it: Create a bootstrap t confidence interval estimate for the correlation statistic.

Jackknife after bootstrap

Statistical question: What is the standard error of the bootstrap estimate of the standard error of R?

How we can answer it: Use data(law) like the previous problem. Perform Jackknife after bootstrap to get a standard error estimate of the standard error estimate. (The bootstrap is used to get an estimate of the SE of R in the population. The jackknife is then used to get an SE of that SE estimate.)

相关实践学习
基于MSE实现微服务的全链路灰度
通过本场景的实验操作,您将了解并实现在线业务的微服务全链路灰度能力。
相关文章
|
2月前
|
数据可视化 数据挖掘 图形学
R语言基础可视化:使用ggplot2构建精美图形的探索
【8月更文挑战第29天】 `ggplot2`是R语言中一个非常强大的图形构建工具,它基于图形语法提供了一种灵活且直观的方式来创建各种统计图形。通过掌握`ggplot2`的基本用法和美化技巧,你可以轻松地将复杂的数据转化为直观易懂的图形,从而更好地理解和展示你的数据分析结果。希望本文能够为你探索`ggplot2`的世界提供一些帮助和启发。
|
2月前
|
数据可视化 数据挖掘 数据处理
R语言高级可视化技巧:使用Plotly与Shiny制作互动图表
【8月更文挑战第30天】通过使用`plotly`和`shiny`,我们可以轻松地创建高度互动的数据可视化图表。这不仅增强了图表的表现力,还提高了用户与数据的交互性,使得数据探索变得更加直观和高效。本文仅介绍了基本的使用方法,`plotly`和`shiny`还提供了更多高级功能和自定义选项,等待你去探索和发现。希望这篇文章能帮助你掌握使用`plotly`和`shiny`制作互动图表的技巧,并在你的数据分析和可视化工作中发挥更大的作用。
|
2月前
|
搜索推荐 前端开发 数据可视化
【优秀python web毕设案例】基于协同过滤算法的酒店推荐系统,django框架+bootstrap前端+echarts可视化,有后台有爬虫
本文介绍了一个基于Django框架、协同过滤算法、ECharts数据可视化以及Bootstrap前端技术的酒店推荐系统,该系统通过用户行为分析和推荐算法优化,提供个性化的酒店推荐和直观的数据展示,以提升用户体验。
100 1
|
5月前
|
数据可视化 数据挖掘 API
【R语言实战】聚类分析及可视化
【R语言实战】聚类分析及可视化
|
2月前
|
搜索推荐 前端开发 数据可视化
基于Python协同过滤的旅游景点推荐系统,采用Django框架,MySQL数据存储,Bootstrap前端,echarts可视化实现
本文介绍了一个基于Python协同过滤算法的旅游景点推荐系统,该系统采用Django框架、MySQL数据库、Bootstrap前端和echarts数据可视化技术,旨在为用户提供个性化的旅游推荐服务,提升用户体验和旅游市场增长。
128 9
基于Python协同过滤的旅游景点推荐系统,采用Django框架,MySQL数据存储,Bootstrap前端,echarts可视化实现
|
2月前
|
数据可视化
R语言可视化设计原则:打造吸引力十足的数据可视化
【8月更文挑战第30天】R语言可视化设计是一个综合性的过程,需要综合运用多个设计原则来创作出吸引力十足的作品。通过明确目标、选择合适的图表类型、合理运用色彩与视觉层次、明确标注与引导视线以及引入互动性与动态效果等原则的应用,你可以显著提升你的数据可视化作品的吸引力和实用性。希望本文能为你提供一些有益的启示和帮助。
|
5月前
|
Web App开发 数据可视化 数据挖掘
利用R语言进行聚类分析实战(数据+代码+可视化+详细分析)
利用R语言进行聚类分析实战(数据+代码+可视化+详细分析)
|
10天前
|
安全 应用服务中间件 API
微服务分布式系统架构之zookeeper与dubbo-2
微服务分布式系统架构之zookeeper与dubbo-2
|
10天前
|
负载均衡 Java 应用服务中间件
微服务分布式系统架构之zookeeper与dubbor-1
微服务分布式系统架构之zookeeper与dubbor-1
|
11天前
|
存储 负载均衡 Dubbo
分布式-Zookeeper(一)
分布式-Zookeeper(一)
下一篇
无影云桌面