【发布时间】:2017-04-26 21:27:33
【问题描述】:
我有以下Poisson 分布:
Data
3 5 3 1 2 1 2 1 0 2 4 3 1 4 1 2 2 0 4 2 2 4 0 2 1 0 5 2 0 1
2 1 3 0 2 1 1 2 2 0 3 2 1 1 2 2 5 0 4 3 1 2 3 0 0 0 2 1 2 2
3 2 4 4 2 1 4 3 2 0 3 1 2 1 3 2 6 0 3 5 1 3 0 1 2 0 1 0 0 1
1 0 3 1 2 3 3 3 2 1 1 2 3 0 0 1 5 1 1 3 1 2 2 1 0 3 1 0 1 1
我使用下面的代码找到了 MLE Θ̂
lik<-function(lam) prod(dpois(data,lambda=lam)) #likelihood function
nlik<- function(lam) -lik(lam) #negative-likelihood function
optim(par=1, nlik)
我想要做的是创建一个引导置信区间来测试 Θ = 1 在 0.05 水平的零假设,并使用我上面使用的数值优化找到 p 值。 我认为这将是类似的事情
n<-length(data)
nboot<-1000
boot.xbar <- rep(NA, nboot)
for (i in 1:nboot) {
data.star <- data[sample(1:n,replace=TRUE)]
boot.xbar[i]<-mean(data.star)
}
quantile(boot.xbar,c(0.025,0.975))
但我不认为这利用了优化,我不确定如何获得 p 值。
【问题讨论】:
标签: r machine-learning statistics poisson statistics-bootstrap