cookie monster
cookie monster

Reputation: 27

How can I calculate the standard error of the poisson.test in R?

I have such a dataset,

ID   Freq.x Freq.y
 1      1    8
 2      5    3
        ...

I calculated the ratio between two rate parameters of Freq.x and Freq.y by using R-programming language poisson.test function, but I want to calculate the standard error. How can I do that?

Upvotes: 0

Views: 627

Answers (1)

Allan Cameron
Allan Cameron

Reputation: 173803

You don't have any reproducible data in your question, so let's make some:

set.seed(69)

x <- rpois(100, lambda = 7)
y <- rpois(100, lambda = 8)

You can get the standard error for each of these two variables like this:

se_x <- sqrt(mean(x)) / length(x)
se_y <- sqrt(mean(y)) / length(y)

se_x
#> [1] 0.02638181

se_y
#> [1] 0.02840775

and you can compare the two to determine if the underlying rate is significantly different like this:

poisson.test(c(sum(x), sum(y)))
#> 
#>  Comparison of Poisson rates
#> 
#> data:  c(sum(x), sum(y)) time base: 1
#> count1 = 696, expected count1 = 751.5, p-value = 0.004533
#> alternative hypothesis: true rate ratio is not equal to 1
#> 95 percent confidence interval:
#>  0.7781748 0.9556714
#> sample estimates:
#> rate ratio 
#>  0.8624535

It's not clear what you mean by the standard error of the poisson.test though.

Upvotes: 2

Related Questions