Week 5 Homework

Exercise 1

(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?

\[ P(P|D) = 0.96, P(P'|D')=0.8, P(D) = 0.001\\ \text{We need to solve for } P(D|P)\\ P(D|P) = \frac{P(D \cap P)}{P(P)}\\ \text{To solve for } P(D\cap P):\\ P(P|D) = \frac{P(P\cap D)}{P(D)} \rightarrow P(P\cap D) = 0.001 \cdot 0.96 = 0.00096 = P(D \cap P)\\ \text{To solve for } P(P):\\ P(P) = P(P\cap D) + P(P \bigcap D')\\ P(P \cap D') = 1 - P(P' \cap D')\\ P(P' \cap D') = P(P'|D') \cdot P(D') = 0.98 \cdot (1-0.001) = 0.97902 = P(P' \cap D')\\ P(P \cap D')= 1 - P(P' \cap D') = 1- 0.97902 = 0.02098 = P(P \cap D')\\ \text{Now we can solve for } P(P):\\ P(P) = P(P\cap D) + P(P \cap D') = 0.00096 + 0.02098 = 0.02194 = P(P)\\ \text{Now we can solve for } P(D|P):\\ P(D|P) = \frac{P(D\cap P)}{P(P)} = \frac{0.00096}{0.02194} = 0.04375...\\ \text{So the probability that an individual who is positive actually has the disease is } \approx 4.375 \%\\ \]

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?

\[ \text{Total Cost} = (\text{Cost of Testing} \cdot \text{Number of Individuals}) + \\(\text{Median cost per positive case} \cdot \text{Number of Individuals} \cdot \text{Number of Positive Cases})\\ = (\$ 1,000 \cdot 100,000) + (\$100,000 \cdot 100,000 \cdot 4.375\%)\\ = \$537,500,000 \]

Exercise 2

(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?

\[ p = 0.05, q = 1 - p = 0.95, n = 24\\ P(X=2) = \binom{24}{2}(0.05)^2(0.95)^{22} \approx 0.223\\ P(X\geq 2) = 1- P(X<2) = 1- P(X=0) - P(X=1)\\ \text{Solve for } P(X=0):\\ P(X=0) = \binom{24}{0}(0.05)^0(0.95)^{24} \approx 0.29199\\ P(X=1) = \binom{24}{1}(0.05^1(0.95^{23} \approx 0.3688\\ \text{Plug in to solve for } P(X\geq2):\\ P(X\geq2) = 1 - 0.29199 - 0.3688 \approx 0.339\\ \text{Solve for } P(X<2):\\ P(X<2) = 1 - P(X\geq2) = 1 - 0.339 \approx 0.661\\ \text{So,}\\ P(X=2) \approx 0.223\\ P(X\geq2) \approx 0.339\\ P(X<2) \approx 0.661\\ \text{Solve for expected value:}\\ E[X] = n\cdot p = 24 \cdot 0.05 = 1.2\\ \text{Solve for standard deviation:}\\ \sigma = \sqrt{n \cdot p \cdot (1-p)} = \sqrt{24 \cdot 0.05 \cdot 0.95} = 1.14\\ \]

Exercise 3

(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?

# P(X = 3)
dpois(3,10)
## [1] 0.007566655

What is the probability that more than 10 arrive in one hour?

# P(X>10) = 1 - P(X<=9)
1 - dpois(0,10) - dpois(1,10) - dpois(2,10) - dpois(3,10) - dpois(4,10) - dpois(5,10) - dpois(6,10) -dpois(7,10) - dpois(8,10) - dpois(9,10)
## [1] 0.5420703

How many would you expect to arrive in 8 hours?

# Expected value in 8 hours
8 * 10
## [1] 80

What is the standard deviation of the appropriate probability distribution?

# standard deviation for the poisson distribution x = 8 and lambda = 10:
sqrt(10*8)
## [1] 8.944272

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?

# n = number of patients observed
n = 8
# capacity = 3 family practices * 24 patients = 72
capacity = 3 * 24
# percent utilization
percent_utlization = n / capacity
print(percent_utlization)
## [1] 0.1111111

Given that the percent utilization is at 111.11%, this indicates that there is an overcapacity situation. To manage patient flow, a suggestion would be to increase the number of family practice providers.

Exercise 4

(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?

# nurse
N1 = 15
# non-nurse
N2 = 15
# sample size
sample = 6
# total population
T = N1 + N2

# acted innocently P(N1 = 5 & N2 = 1)
choose(N1,5) * choose(N2,1) / choose(T,6)
## [1] 0.07586207

How many nurses would we have expected your subordinate to send?

# expected value of nurses
sample * N1 / T
## [1] 3

How many non-nurses would we have expected your subordinate to send?

# expected value of non-nurses
sample * N2 / T
## [1] 3

Exercise 5

(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?

# probability of being injured in a car crash
p = 0.001

# number of trials
n1 = 1200

# calculate probability of being injured over the course of a year P(at least one success) = 1 - P(no success)
prob1 = 1 - (1-p)^n1
print(prob1)
## [1] 0.6989866

In the course of 15 months?

# 15 months
n2 = 1200/12*15

# calculate prob
prob2 = 1 - (1-p)^n2

print(prob2)
## [1] 0.7770372

What is the expected number of hours that a driver will drive before being seriously injured?

# expected value
expected_value = 1/p
print(expected_value)
## [1] 1000

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(success in next 100 hours | no success in first 1200 hours) 
n3 = 1300
prob3 = 1 - (1-p)^n3
prob3 - prob1
## [1] 0.02865884

Exercise 6

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?

hours <- 1000
# fails once in 1000 hours
p6 <- 1/hours

# P(X>2) = 1- P(X leq 2)
# P(X leq 2)
p_x_leq_2 <- pgeom(0,p6) + pgeom(1, p6) + pgeom(2,p6)

# P(X>2)
1- p_x_leq_2
## [1] 0.994004
# expected value
expected_value <- 1/p6
print(expected_value)
## [1] 1000

Exercise 7

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?

a <- 0 # min waiting time
b <- 30 # max waiting time

# P(X>10) = 1 - P(X leq 10)
p10 <- 1 - punif(10, a, b)
print(p10)
## [1] 0.6666667

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?

# P(X > 5 more minutes | X>10) = P(X>15)/P(X>10)

#P(X>15)
p15 <- 1 - punif(15,a,b)

# solution
p15/p10
## [1] 0.75

What is the expected waiting time?

# E[X] = a+b /2
a+b/2
## [1] 15

Exercise 8

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?

lambda8 <- 1/10
# expected failure time
expected_val <- 1/lambda8
# standard deviation
sd <- 1/lambda8

The expected failure time is 10 years. The standard deviation is also 10 because the mean is equal to the standard deviation in an exponential distribution.

What is the probability that your MRI will fail after 8 years?

# fail after 8 years P(X>8) = 1-P(X<=8)
p_x_l_8 = pexp(8,lambda8)
p_x_g_8 <- 1 - p_x_l_8
print(p_x_g_8)
## [1] 0.449329

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?

#P(X<=10|X<=8) = P(X<=10 n X>8)/P(X>8) = (P(X<=10) - P(X<=8)) / P(X>8)
#P(X<=10)
p_x_l_10 = pexp(10,lambda8)
(p_x_l_10 - p_x_l_8)/p_x_g_8
## [1] 0.1812692