There are several ways to define two-sided $p$-values in this case. Michael Fay lists three in his article. The following is mostly taken from his article.
Suppose you have a discrete test statistic $t$ with random variable $T$ such that larger values of $T$ imply larger values of a parameter of interest, $\theta$. Let $F_{\theta}(t)=Pr[T\leq t;\theta]$ and $\bar{F}_{\theta}(t)=Pr[T\geq t;\theta]$. Suppose the null value is $\theta_{0}$. The one-sided $p$-values are then denoted by $F_{\theta_{0}}(t), \bar{F}_{\theta_{0}}(t)$, respectively.
The three ways listed to define two-sided $p$-values are as follows:
$\textbf{central:}$ $p_{c}$ is 2 times the minimum of the one-sided $p$-values bounded above by 1: $$ p_{c}=\textrm{min}\{1,2\times\textrm{min}(F_{\theta_{0}}(t), \bar{F}_{\theta_{0}}(t))\}. $$
$\textbf{minlike:}$ $p_{m}$ is the sum of probabilities of outcomes with likelihoods less than or equal to the observed likelihood: $$ p_{m}=\sum\limits_{T:f(T)\leq f(t)}f(T) $$ where $f(t) = Pr[T=t;\theta_{0}]$.
$\textbf{blaker:}$ $p_{b}$ combines the probability of the smaller observed tail with the smallest probability of the opposite tail that does not exceed that observed probability. This may be expressed as: $$ p_{b}=Pr[\gamma(T)\leq\gamma(t)] $$ where $\gamma(T)=\textrm{min}\{F_{\theta_{0}}(T), \bar{F}_{\theta_{0}}(T))\}$.
If $p(\theta_{0})$ is a two-sided $p$-value testing $H_{0}:\theta=\theta_{0}$, then its $100(1-\alpha)$% matching confidence interval is the smallest interval that contains all $\theta_{0}$ such that $p(\theta_{0})>\alpha$. The matching confidence limits to the $\textbf{central}$ test are $(\theta_{L},\theta_{U})$ which are the solutions to: $$ \alpha/2=\bar{F}_{\theta_{L}}(t) $$ and $$ \alpha/2=F_{\theta_{U}}(t). $$
The contradiction arises because
poisson.test
returns $p_{m}$ as the $p$-value but confidence limits that are based on the $\textrm{central}$ test!
The exactci
package returns the correct matching $p$-values and confidence limits (you can set the method using the option tsmethod
):
library(exactci)
poisson.exact(x=10, r=5.22, tsmethod = "central")
Exact two-sided Poisson test (central method)
data: 10 time base: 1
number of events = 10, time base = 1, p-value = 0.08105
alternative hypothesis: true event rate is not equal to 5.22
95 percent confidence interval:
4.795389 18.390356
sample estimates:
event rate
10
Now there is no conflict between the $p$-value and the confidence intervals. In rare cases, even the exactci
function will result in inconsistencies, which is mentioned in Michael Fays article.