library('glue')
- (Bayesian). A new test for multinucleoside-resistant (MNR) human
immunodeficiency virus type 1 (HIV-1) variants was recently developed.
The test maintains 96% sensitivity, meaning that, for those with the
disease, it will correctly report “positive” for 96% of them. The test
is also 98% specific, meaning that, for those without the disease, 98%
will be correctly reported as “negative.” MNR HIV-1 is considered to be
rare (albeit emerging), with about a .1% or .001 prevalence rate. Given
the prevalence rate, sensitivity, and specificity estimates, what is the
probability that an individual who is reported as positive by the new
test actually has the disease? If the median cost (consider this the
best point estimate) is about $100,000 per positive case total and the
test itself costs $1000 per administration, what is the total first-year
cost for treating 100,000 individuals?
PA1 = 0.001
PBA1 = 0.96
PBA2 = (1 - 0.98)
PA2 = 0.999
glue('Given the prevalence rate, sensitivity, and specificity estimates, the probability that an individual who is reported as positive by the new test actually has the disease is {round(PBA1 * PA1/(PBA1 * PA1 + PBA2 * PA2) *100, digits = 2)} %.')
## Given the prevalence rate, sensitivity, and specificity estimates, the probability that an individual who is reported as positive by the new test actually has the disease is 4.58 %.
CPPC = 1e+05
CPA = 1000
n = 1e+05
pr = 0.001
cost_per_case = CPPC + CPA
positive_case = n * pr
true_negative = (n - 100)
true_n = true_negative * 0.98
false_negative = true_negative - true_n
first_year_cost = (96 + false_negative) * cost_per_case
glue('If the median cost is about $100,000 per positive case total and the test itself costs $1000 per administration, the total first-year cost for treating 100,000 individuals is ${first_year_cost}')
## If the median cost is about $100,000 per positive case total and the test itself costs $1000 per administration, the total first-year cost for treating 100,000 individuals is $211494000
- (Binomial). The probability of your organization receiving a Joint
Commission inspection in any given month is .05. What is the probability
that, after 24 months, you received exactly 2 inspections? What is the
probability that, after 24 months, you received 2 or more inspections?
What is the probability that your received fewer than 2 inspections?
What is the expected number of inspections you should have received?
What is the standard deviation?
n = 24
P = 0.05
x = 2
glue('The probability that, after 24 months, you received exactly 2 inspections is {round(dbinom(x, n, P), 4) * 100} %.')
## The probability that, after 24 months, you received exactly 2 inspections is 22.32 %.
glue('The probability that, after 24 months, you received 2 or more inspections is {round(1 - (dbinom(1, n, P) + dbinom(0, n, P)), 4) * 100} %.')
## The probability that, after 24 months, you received 2 or more inspections is 33.92 %.
glue('The probability that your received fewer than 2 inspections is {round(dbinom(1, n, P) + dbinom(0, n, P), 4) * 100} %.')
## The probability that your received fewer than 2 inspections is 66.08 %.
glue('The expected number of inspections you should have received is {(n*P)}.')
## The expected number of inspections you should have received is 1.2.
glue('The standard deviation is {round(sqrt(n * P * (1 - P)),3)}.')
## The standard deviation is 1.068.
- (Poisson). You are modeling the family practice clinic and notice
that patients arrive at a rate of 10 per hour. What is the probability
that exactly 3 arrive in one hour? What is the probability that more
than 10 arrive in one hour? How many would you expect to arrive in 8
hours? What is the standard deviation of the appropriate probability
distribution? If there are three family practice providers that can see
24 templated patients each day, what is the percent utilization and what
are your recommendations?
r = 10
glue('The probability that exactly 3 arrive in one hour is {round(dpois(3, r), 4) * 100} %.')
## The probability that exactly 3 arrive in one hour is 0.76 %.
glue('The probability that exactly 3 arrive in one hour is {round(1 - ppois(10, r), 4) * 100} %.')
## The probability that exactly 3 arrive in one hour is 41.7 %.
per_hour = 10
glue('The amount you would expect to arrive in 8 hours is {(8 * per_hour)} patients.')
## The amount you would expect to arrive in 8 hours is 80 patients.
glue('The standard deviation of the appropriate probability distribution is {round(sqrt(r))}.')
## The standard deviation of the appropriate probability distribution is 3.
glue('The percent utilization for three family practice providers that can see 24 templated patients each day is {round(80/72 * 100)} and the recommendation is to extend the hours of operation or hire more staff to cover the 8 additional patients.')
## The percent utilization for three family practice providers that can see 24 templated patients each day is 111 and the recommendation is to extend the hours of operation or hire more staff to cover the 8 additional patients.
- (Hypergeometric). Your subordinate with 30 supervisors was recently
accused of favoring nurses. 15 of the subordinate’s workers are nurses
and 15 are other than nurses. As evidence of malfeasance, the accuser
stated that there were 6 company-paid trips to Disney World for which
everyone was eligible. The supervisor sent 5 nurses and 1 non-nurse. If
your subordinate acted innocently, what was the probability he/she would
have selected five nurses for the trips? How many nurses would we have
expected your subordinate to send? How many non-nurses would we have
expected your subordinate to send?
x = 5
m = 15
n = 15
k = 6
glue('The probability he/she would have selected five nurses for the trips is {round(dhyper(x, m, n, k, log = FALSE), 4) * 100} %.')
## The probability he/she would have selected five nurses for the trips is 7.59 %.
glue('The subordinate will need to send {m * k/(m + n)} nurses.')
## The subordinate will need to send 3 nurses.
glue('The subordinate will need to send {m * k/(m + n)} non-nurses.')
## The subordinate will need to send 3 non-nurses.
- (Geometric). The probability of being seriously injured in a car
crash in an unspecified location is about .1% per hour. A driver is
required to traverse this area for 1200 hours in the course of a year.
What is the probability that the driver will be seriously injured during
the course of the year? In the course of 15 months? What is the expected
number of hours that a driver will drive before being seriously injured?
Given that a driver has driven 1200 hours, what is the probability that
he or she will be injured in the next 100 hours?
p = 0.001
q = 1 - p
hours_12 = 1200
glue('The probability that the driver will be seriously injured during the course of the year is {round((pgeom(hours_12, p)), 4) * 100} %.')
## The probability that the driver will be seriously injured during the course of the year is 69.93 %.
glue('The probabilty that the driver will be seriously injured during the course of 15 months is {round((pgeom(hours_12 * (15/12), p)), 4) * 100} %.')
## The probabilty that the driver will be seriously injured during the course of 15 months is 77.73 %.
glue('The expected number of hours a driver will drive before being seriously injured is {1/p} hours.')
## The expected number of hours a driver will drive before being seriously injured is 1000 hours.
glue('The probability that he or she will be injured in the next 10 hours after driving 1200 hours is {round(pgeom(100, p), 4) * 100} %.')
## The probability that he or she will be injured in the next 10 hours after driving 1200 hours is 9.61 %.
- You are working in a hospital that is running off of a primary
generator which fails about once in 1000 hours. What is the probability
that the generator will fail more than twice in 1000 hours? What is the
expected value?
glue('The probability that the generator will fail more than twice in 1000 hours is {round(1 - ppois(2, 1), 4) * 100} %.')
## The probability that the generator will fail more than twice in 1000 hours is 8.03 %.
glue('The expected value is 1')
## The expected value is 1
- A surgical patient arrives for surgery precisely at a given time.
Based on previous analysis (or a lack of knowledge assumption), you know
that the waiting time is uniformly distributed from 0 to 30 minutes.
What is the probability that this patient will wait more than 10
minutes? If the patient has already waited 10 minutes, what is the
probability that he/she will wait at least another 5 minutes prior to
being seen? What is the expected waiting time?
w = 10
min = 0
max = 30
glue('The probability that this patient will wait for more than 10 minutes is {round(1 - punif(w, min, max), 4) * 100} %.')
## The probability that this patient will wait for more than 10 minutes is 66.67 %.
PA = 1 - punif(15, 10, 30)
PB = 1 - punif(10, 10, 30)
glue('The probability that he / she will wait at least anohter 5 minutes prior to being seen is {(PA/PB) * 100} %.')
## The probability that he / she will wait at least anohter 5 minutes prior to being seen is 75 %.
glue('The expected waiting time is {1/2 * (min + max)} minutes.')
## The expected waiting time is 15 minutes.
- Your hospital owns an old MRI, which has a manufacturer’s lifetime
of about 10 years (expected value). Based on previous studies, we know
that the failure of most MRIs obeys an exponential distribution. What is
the expected failure time? What is the standard deviation? What is the
probability that your MRI will fail after 8 years? Now assume that you
have owned the machine for 8 years. Given that you already owned the
machine 8 years, what is the probability that it will fail in the next
two years?
lambda = 1/10
glue('The expected failure time is 10 years.')
## The expected failure time is 10 years.
glue('The standard deviation is 10 years.')
## The standard deviation is 10 years.
glue('The probability that your MRI will fail after 8 years is {round(1 - pexp(8, lambda), 4) * 100} %.')
## The probability that your MRI will fail after 8 years is 44.93 %.
glue('The probability that it will fail in the next two years is {round(pexp((10 - 8), lambda), 4) * 100} %.')
## The probability that it will fail in the next two years is 18.13 %.