Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R简单引导_R_Statistics Bootstrap - Fatal编程技术网

R简单引导

R简单引导,r,statistics-bootstrap,R,Statistics Bootstrap,我有一个有两列的数据框(应用程序) Customer Application 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 申请率是多少 sum(Applications$Application)/sum(Applications

我有一个有两列的数据框(应用程序)

Customer    Application
1           1
1           0
1           0
1           1
1           1
1           0
1           1
1           0
1           0
1           1
1           1
申请率是多少

sum(Applications$Application)/sum(Applications$Customer).
我被要求通过对1000名客户的1000个样本进行测试,以获得应用率的分布和置信水平,从而提高应用率。我尝试使用
boot
包,如下所示

f2 <- function(Loan,Customer){sum(Applications$Application)/sum(Applications$Customer)}
bootapp1 <-(boot(Applications, f2, 1000))
bootapp1

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = Bootstrap_Test, statistic = f2, R = 1000)


Bootstrap Statistics :
       original  bias    std. error
t1* 0.003052608       0           0

f2您只需要调整函数,它需要两个参数。从
boot
上的帮助文件中,在参数
statistic
下:

一种函数,当应用于数据时,返回一个包含感兴趣的统计信息的向量。当sim=“parametric”时,statistic的第一个参数必须是数据。对于每个复制,将传递由ran.gen返回的模拟数据集。在所有其他情况下,统计必须至少包含两个参数。传递的第一个参数始终是原始数据。第二个是定义引导样本的指数、频率或权重向量

库(启动)
x
library(boot)
x <- structure(list(Customer = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                 1L, 1L), Application = c(1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 
                                                          1L, 1L)), .Names = c("Customer", "Application"), class = "data.frame", row.names = c(NA, 
                                                                                                                                               -11L))
f2 <- function(x, index){sum(x[index, "Application"])/sum(x[index, "Customer"])}
bootapp1 <- boot(data = x, statistic = f2, R = 1000)
> bootapp1

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
  boot(data = x, statistic = f2, R = 1000)


Bootstrap Statistics :
  original       bias    std. error
t1* 0.5454545 0.0005454545     0.14995