CI_ELR: A function that uses uniroot to solve for the (1-alpha)...

Description Usage Arguments Details Value Examples

View source: R/ci_comp.R

Description

A function that uses uniroot to solve for the (1-alpha) confidence interval of sample mean by the method of empirical likelihood

Usage

1
CI_ELR(y, alpha, ub)

Arguments

y

samples

alpha

significance level

ub

upper bound for solving for the root

Details

For empirical likelihood method, the (1-alpha) CI for mu is mu|sum(log(np[i](mu)),i==1,n)>-0.5 chi[1-alpha]^2*(1) Noticing that mu doesn't have explicit formula to calculate, I solved the equation numerically.

Value

a (1-alpha) confidence interval by the method of empirical likelihood

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
set.seed(7524)
n=c(500,5000,50000)
lik=matrix(0,ncol=2,nrow=3)
rownames(lik)=paste("n=",n);colnames(lik)=c("left","right")
up=c(1.23,1.07,1.07)
for (i in 1:3){
 x=rnorm(n[i])
 y=x^2 #turn var into mean
 lik[i,]=CI_ELR(y,0.05,up[i])}
lik

## End(Not run)

XixuHu/SC19090 documentation built on Jan. 2, 2020, 8:40 p.m.