Re: [R] Coverage probability for a Poisson parameter

2015-02-14 Thread JS Huang
Hi, Some suggestion about the arguments of the function defined below. Since theta is calculated with the value of lambda1 and lambda2, there is no need to include theta in the argument. Or, your function can be defined as function(lambda1, lambda2, significance.level) cover <- function(theta

Re: [R] Coverage probability for a Poisson parameter

2015-02-14 Thread JS Huang
Hi, Given the function cover, it's very likely that you will get 0 for both s1 and s1 with small value of lambda1 and lambda2. In that case the sum s will be 0. With s being 0, you will have issue with the expression in pi <- s2/s and root <- ((s2/s)*(1-s2/s)+k/(4*s))^(1/2). You need to take

Re: [R] Coverage probability for a Poisson parameter

2015-02-14 Thread JS Huang
Hi, In your function cover, lambda1 and lambda2 are used but not in the argument of the function. I suppose that you need to have lambda1 and lambda2 in the argument of the function cover, like function(lambda1, lambda2, n, significance.level). Give it a try. cover <- function(lambda, n,

Re: [R] Coverage probability for a Poisson parameter

2015-02-06 Thread JS Huang
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 <- m

Re: [R] Coverage probability for a Poisson parameter

2015-01-30 Thread JS Huang
Hi, My first question is what is your n when you say fixed n. I assume the lambda is the mean of the poisson distribution that you want to take sample from. Another question is about the sample size. It does not make too much sense to make a sample of size 1. Let's assume that you want t

Re: [R] Coverage probability for a Poisson parameter

2015-01-30 Thread JS Huang
Hi, Roughly reading the code, I find this statement "phat <- x / m" is probably incorrect since this will give you the set of 100 observed x values /100. I redefine the function cover with three inputs: lambda for the parameter of the poisson distribution, sample.size and significance.