[R] Coverage probability for a Poisson parameter

JS Huang js.huang at protective.com
Fri Feb 6 22:56:01 CET 2015


Hi,

  After some thought, I found the treatment of sample mean equal 0 was not
appropriate.  I modified the function likelihood.ratio.test.Poisson. 
resulting.matrix now has 0.0512 as the average of type I error.

function(lambda, sample.size, significance.level)
{
  reject <- 0
  sample.mean <- mean(rpois(sample.size, lambda))
  if (sample.mean == 0)
  {
    test.statistics <- 2 * sample.size * lambda
  }
  else
  {
    test.statistics <- 2 * sample.size * (lambda - sample.mean + sample.mean
* log(sample.mean / lambda))
  }
  if (test.statistics >= qchisq(1 - significance.level, 1)) {reject <- 1}
else {reject <- 0}
  return(reject)
} 
> for (i in 1:500){
+   resulting.matrix[i,1] <- 0.01 * i
+   resulting.matrix[i,2] <- mean(sapply(1:100,function(x)
likelihood.ratio.test.Poisson(0.01*i,10,0.05)))  
+ }
> mean(resulting.matrix[,2])
[1] 0.05102



--
View this message in context: http://r.789695.n4.nabble.com/Coverage-probability-for-a-Poisson-parameter-tp4702535p4702909.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list