楼主: elsieye119
2802 0

[问答] 求问怎么用R做bootstrap然后把结果画成散点图 [推广有奖]

  • 0关注
  • 0粉丝

等待验证会员

学前班

60%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
20 点
帖子
1
精华
0
在线时间
2 小时
注册时间
2014-2-18
最后登录
2022-2-22

楼主
elsieye119 发表于 2015-4-23 22:34:21 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如题,怎么把三组数据,格式是(x,y),x是正确率,y是反应时,bootstrap抽2000次,然后把结果画成散点图,得到如下的图。 bootstrap散点图
目前已有的语句如下,求问怎么改~~~

setwd("E:/EXP/example");  # set the working directory
load("students.RData");             # load the data

#############2. Test the hypothesis using the Barron and Kenney method with Bootsrapping.
#############Print out the histogram with normal distribution curve as well as the confidence intervals and mean indirect effect.
original = 1:nrow(students) # Original sample: All cases in our data
N = nrow(students)  # sample size

output.boot = data.frame(ab = rep(NA, 2000))  # make a NA array to contain all output

for(i in 1:2000) {                   # repeat 2000 times

    boot.sample = students[sample(original, N, replace = TRUE), ] # Draw a sample of size N with replacement

    boot.a = lm(gb.1 ~ neuro, data = boot.sample)   # Estimate models again
    boot.b_cprime = lm(ls.1 ~ neuro + gb.1, data = boot.sample)

    ab.boot = coef(boot.a)[2] * coef(boot.b_cprime)[3]  # Calculate indirect effect
    output.boot$ab = ab.boot
}


plot(output.boot$a,output.boot$b, breaks = 50)  
curve(dnorm(x, mean(output.boot$ab), sd(output.boot$ab)), add = T, lwd = 2) # add normal distribution curve

mean(output.boot$ab)   # mean as the estimate for the indirect effect
quantile(output.boot$ab, probs = c(.025, .975))  #the confidence interval



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Bootstrap Bootstra boots boot Trap 散点图

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 10:34