Discussion-Binomial and Poisson
Let’s assume that a hospital’s neurosurgical team performed N
procedures for in-brain bleeding last year. x of these procedures
resulted in death within 30 days. If the national proportion for death
in these cases is π, then is there evidence to suggest that your
hospital’s proportion of deaths is more extreme than the national
proportion?
Binomial model
# x is a random variable of the numbers of deaths
#what is N?
n <- 100
#probability of success
pi <- 0.15
# Number of deaths within 30 days
x <- 20
#Check for conditions
## Outcomes are mutually exclusive
## Each trial is independent
## result of a count
## there are only two possible outcomes
#probability statement
## P(x >= 20 | n = 100, pi=0.15)
?dbinom
p_dbinom <- 1 - pbinom(q = 19, size = 100, prob = 0.15, lower.tail = TRUE)
p_dbinom
## [1] 0.1065443
print(paste0("the result is ", round(x = p_dbinom, digits = 7)))
## [1] "the result is 0.1065443"
Double checking result
sum(dbinom(x = 20:100, size = 100, prob = 0.15))
## [1] 0.1065443
pbinom(q = 19, size = 100, prob = 0.15, lower.tail = FALSE)
## [1] 0.1065443
Poisson example
lambda <- (n * pi)
?ppois
result2 <- ppois( q = 19, lambda = 15, lower.tail = FALSE)
print(paste0("the result is ", round(x = result2, digits = 7)))
## [1] "the result is 0.1247812"
sum(dpois(x = 20:100, lambda= 15) )
## [1] 0.1247812
Both asnwer are a close due to the fact that the poisson
distribution is actually a liminting case of the binomial distribution.
The Poisson distribution is a good aproxiamtion to the binomial
distribution when the numbers of trials is large and the probability of
success is small, such tha np is close the lambda. In my example we can
see that np = 15 and lambda is also = 15.