The below methodology is for a one-sided test.I am trying to use the two methods for obtaining the p-value where it should be the same in case of Binomial hypothesis testing. But I am receiving a slight difference in the values.
pi.H0 <- 0.65
n <- 121
alpha <- 0.05
pbar <- 87/121
( x.hi <- qbinom(1-alpha,size=n,prob=pi.H0) ) # upper critical value **##87**
( pi.hi <- pbinom(x.hi,size=n,prob=pi.H0,lower.tail=FALSE) ) # exact upper alpha **##0.043**
By using binom.test I have received a slight different pvalue.
binom.test(87,121,0.65,alternative = "greater",conf.level = 0.95)
Exact binomial test
data: 87 and 121
number of successes = 87, number of trials = 121, p-value = 0.06552
alternative hypothesis: true probability of success is greater than 0.65
95 percent confidence interval:
0.644058 1.000000
sample estimates:
probability of success
0.7190083