Binomial Distribution - Hospital Example

The national 30-day case fatality rate for intracranial hemorrhage (ICH) surgical intervention is 16%. The neurosurgical team performed 20 of these operations last year and experienced 6 deaths. Does sufficient evidence exist to suggest that the neurosurgical practice pattern requires review? In other words, what is the probability that this team would experience something this or more severe, i.e., 6 or more deaths in 20 trials if they were operating at the national rate of .16? Use an evidentiary standard that investigates if the event is rare (routinely defined as less than .05 probability.)

1-(choose(20,0)*(.16)^0*(.84)^20 + choose(20,1)*(.16)^1*(.84)^19 + choose(20,2)*(.16)^2*(.84)^18 + choose(20,3)*(.16)^3*(.84)^17 + choose(20,4)*(.16)^4*(.84)^16 + choose(20, 5)*(.16)^5*(.84)^15) #this would be "brute force" method, fully written out
## [1] 0.08699685
?dbinom
## starting httpd help server ... done
sum(dbinom(6:20, 20, .16))
## [1] 0.08699685
1-sum(dbinom(0:5, 20, .16))
## [1] 0.08699685
dbinom(0:5, 20, .16)
## [1] 0.03059044 0.11653501 0.21087287 0.24099757 0.19509327 0.11891399
1-pbinom(5, 20, .16)
## [1] 0.08699685
pbinom(5, 20, .16, lower.tail=FALSE)
## [1] 0.08699685
dbinom(6, 20, .16) # this just illustrates the command, has no bearing on the problem
## [1] 0.05662571

Poisson Distribution - Hospital Example

The rate of medication errors across the United States is 2 per 1000 orders. (Volume). A sample from your local hospital finds 5 errors in a sample of 2000. What is the probability that this hospital is within the US standard?

?dpois

sum(dpois(5:2000, 4))
## [1] 0.3711631
1-ppois(4,4)
## [1] 0.3711631
ppois(4, 4, lower.tail=FALSE)
## [1] 0.3711631

Poisson as binomial

probability = lambda/interval = 2/1000 = .002

pbinom(4, 2000, .002, lower.tail=FALSE)
## [1] 0.371163

Poisson - another example

Defects occur along the length of cable at an average of six defects per 4000 feet. What is the probability that a 3000-foot cable will have at most two defects?

lambda = 6, t=3000/4000 = .75, lambda_t=6*.75 = 4.5

ppois(2, 4.5)
## [1] 0.1735781
sum(dpois(0:2, 4.5))
## [1] 0.1735781

Hypergeometric Distribution

Orthopedic example - 20 patients, 10 will require MRI, what is probability that if doctor sees 5 patients they will send all 5 to MRI

?dhyper
dhyper(5, 10, 10, 5)
## [1] 0.01625387

Probability of 4 or more?

sum(dhyper(4:5, 10, 10, 5))
## [1] 0.1517028
phyper(3, 10, 10, 5, lower.tail=FALSE)
## [1] 0.1517028

Lottery example

54 numbers, 6 numbers for jackpot, 3 or more to win something. Total number of successes = 6, number of non-successes = 48, sample 6 numbers

Jackpot = 6 successes out of sample of 6

dhyper(6, 6, 48, 6)
## [1] 3.871892e-08

Probability of a win (3 or more numbers)

sum(dhyper(3:6, 6, 48, 6))
## [1] 0.01405996
1-phyper(2, 6, 48, 6)
## [1] 0.01405996
phyper(2, 6, 48, 6, lower.tail=FALSE)
## [1] 0.01405996

Normal Distribution

Mean temperature = 98.6, standard deviation = 1

P(X<96)

?dnorm
pnorm(96, 98.6, 1)
## [1] 0.004661188
#via z-score

pnorm((96-98.6), 0, 1)
## [1] 0.004661188

P(X>99.5)

1-pnorm(99.5, 98.6, 1)
## [1] 0.1840601
pnorm(99.5, 98.6, 1, lower.tail=FALSE)
## [1] 0.1840601

P(96<X<98)

pnorm(98, 98.6, 1) - pnorm(96, 98.6, 1)
## [1] 0.2695919

P(X>100)

pnorm(100.5, 98.6, 1, lower.tail=FALSE)
## [1] 0.02871656