Problem 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? If the median cost (consider this the best point estimate) is about 100,000 dollars per positive case total and the test itself costs $1000 per administration, what is the total first-year cost for treating 100,000 individuals?

Solution 1
1(a) Probability that an individual reported positive has the disease. i.e. a true positive
Let event B = Positive test, A1 = Actual HIV pt, A2 = Actual non-HIV

P(A1) = 0.001; P(A2) = 0.999; P(B|A1) = 0.96
P(B|A2) = 1 - 0.98 = 0.02
Using Bayes formula
P(A1|B) = P(B|A1)P(A1) / P(B|A1)P(A1) + P(B|A2)P(A2)

p_true_positive = round((.96*.001)/((.96*.001)+(.02*.999)), 4)
p_true_positive
## [1] 0.0458

1(b) Total first-year cost for treating 100,000 individuals

# $100,000 per positive case total and the test costs $1000 per administration

positive_cases_prevalence = 100000 * 0.001 # about 0.1% prevalence rate
cost_to_administer_test = 1000 * 100000 # it costs $1000 to administer each test
cost_to_treat_positive = positive_cases_prevalence * 100000 # cost to treat positive cases
total_cost = cost_to_administer_test + cost_to_treat_positive
total_cost
## [1] 1.1e+08


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

Solution 2
Let p= probability of receiving a joint commission inspection in any given month and q=1-p represent the probability of not receiving the a joint inspection in any given month.

2(a) Probability of exactly 2 inspection after 24 months.
\(P(X = x) = \binom{n}{x}p^{x}(1-p)^{n-x}\)
\(P(X=2) = \binom{24}{2}(0.05^{2})(1-0.05)^{24-2} = 0.2232\)
Therefore, the probability of getting exactly 2 inspections after 24 months is 0.2232

# P(X=2) = 
p = round(dbinom(2, 24, 0.05), 4)
p
## [1] 0.2232


2(b) Probability of 2 or more inspections
P(X = 2 or more) = 1 - P(fewer than 2) = 1 - P(x = 0 or 1).
P(X = 2 or more) = 1 - P(X = 0) + P(X = 1)
P(X = 2 or more \(= 1- [\binom{24}{0}(0.05^{0})(1-0.05)^{24-0} + \binom{24}{1}(0.05^{1})(1-0.05)^{24-1}]= 1-(0.291989+0.368828)\)
= \(1-0.660817 = 0.339183 = 0.33918\)
Therefore, the probability of 2 or more inspections is about 0.3392

# P(X = 2 or more) = 
p_2_or_more = round(1 - (dbinom(0, 24, 0.05) + dbinom(1, 24, 0.05)), 4)
p_2_or_more
## [1] 0.3392


2(c) Probability of fewer than 2 inspections
P(X< 2) = P(X = 0) + P(X = 1) = \(\binom{24}{0}(0.05^{0})(1-0.05)^{24-0} + \binom{24}{1}(0.05^{1})(1-0.05)^{24-1}\)
\(P(X < 2) = 0.291989 + 0.368828 = 0.660817 = 0.6608\)
Therefore the probability of fewer than 2 inspections is about 0.6608

# P(X < 2) = 
p_less_than_2 = round(dbinom(0, 24, 0.05) + dbinom(1, 24, 0.05), 4)
p_less_than_2
## [1] 0.6608


2(d) Expected number of inspections
The expected number of inspections will be given by the expected value of a binomial probability distribution with the given parameters. E(x) = np
\(E(x) = 24 * 0.05 = 1.2\)


2(e) Standard Deviation of the distribution
The standard deviation of the binomial distribution is given by:
\(\sigma = \sqrt{npq}\)
\(=> \sqrt{24 * 0.05 * (1-0.05)} = 1.0677\)

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

Solution 3
The poison distribution formula is given by:
\(f(x) = \frac{\lambda ^{x}}{x!}e^{-\lambda}\)
\(\lambda = 10/hour\)
3(a) Probability of exactly 3 in one hour
\(P(x=3) = \frac{10^{3}}{3!}e^{-10} = 0.0076\)
Therefore the probability of exactly 3 per hour is about 0.0076

# P(X=3) = 
p = round(dpois(3, 10), 4)
p
## [1] 0.0076



3(b) Probability that more than 10 arrive in an hour
P(X = more than 10) = 1 - P(X < 10) = 1 - P(X <= 9)

# The ppois function in R calculates the probability of a random variable that will be equal to or less than a number.
p_less_than_equal_9 = ppois(9, 10)
p_10_or_more = round((1 - p_less_than_equal_9), 4)
p_10_or_more
## [1] 0.5421



3(b) How many would you expect to arrive in 8 hours
The expected value of a poison distribution is \(\lambda\). Therefore, we will expect 10 to arrive in an hour and expect 10 x 8 = 80 to arrive in 8 hours.



3(c) Standard deviation
\(\sigma = \sqrt{\lambda}\)
\(=> \sqrt{10} = 3.1623\)
3(d) Percent Utilization if there are 3 family practice providers who can see 24 patients daily

number_patients_seen_daily = 3 * 24
number_expected_to_arrive_8hours = 80
percent_utilization = (number_patients_seen_daily/number_expected_to_arrive_8hours) * 100
percent_utilization
## [1] 90
Based on the arrival rate and how many patients can be attended to, I will recommend having another family practice provider who is willing to work part time hours so that all patients can be seen before close of work or recommend extending office hours but extending office hours would mean additional patients would arrive or extending hours to see the additional 10% while they will stop accepting new patients after the close of business.

Problem 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? How many nurses would we have expected your subordinate to send? How many non-nurses would we have expected your subordinate to send?

Solution 4
The hyper geometric distribution is given by:
\(P(X = x) = \frac{\binom{m}{x}\binom{M-m}{k-x}}{\binom{M}{k}}\)
Where M = population size, m = number of success states in the population,
k= quantity drawn in each trial and x = number of observed successes.

M = Total number of workers supervised: 30
m = Number of nurses among those workers: 15
M- m = Number of non-nurses among those workers: 15
k = Total number of workers selected for the trips: 6
x = Number of nurses to be selected for the trips: 5
k - x = Number of non-nurses to be selected for the trips: 1

4(a) Probability the subordinate would have selected exactly five nurses
\(P(X = 5) = \frac{\binom{15}{5}\binom{30-15}{6-1}}{\binom{30}{6}} = \frac{\binom{15}{5}\binom{15}{1}}{\binom{30}{6}}\)
\(=> P(X=5) = \frac{3003 *15}{593775}=0.0759\)

#P(5), x=5,m=15,n=15,k=6
p_5_nurses_1_non_nurse = round(dhyper(5,15,15,6,log=FALSE), 4)
p_5_nurses_1_non_nurse
## [1] 0.0759


4(b) Expected number of nurses to send
Probability of sending nurses = 15/30 = 0.5; Number of trips = 6
Expected number of nurses to send = 6 * 0.5 = 3
Therefore, we would expect about 3 nurses to be sent on the trips.

4(c) Expected number of non-nurses to send
Probability of sending non-nurses = 15/30 = 0.5; Number of trips = 6
Expected number of non-nurses to send = 6 * 0.5 = 3
Therefore, we would expect about 3 non-nurses to be sent on the trips.

Problem 5.

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?

Solution 5
The geometric distribution is given by:
\(P(X=x) = p(1-p)^{x-1}\)
Where p = the probability of success and x = the number of trials up to the first success. Basically this means the number of trials made upon achieving the first success.
In this case, let us take the event of success as being seriously injured in a car crash (Nobody sure wants this event as a success) but we will use it in this case.
p = .1% = 0.001


5(a) Probability of getting seriously injured during the course of the year (i.e 1200 hours of traverse)
x = 1200. This assumes that the driver will traverse 1200 hours before being injured. \(P(X= 1200) = (0.001)(1-0.001)^{1200-1} = 0.000301\)

p_injured_1200 = round(dgeom(1200, 0.001), 6)
p_injured_1200
## [1] 0.000301


5(b) Probability of getting seriously injured during the course of 15 months (i.e 1500 hours of traverse)
x = 1200. This assumes that the driver will traverse 1200 hours before being injured. \(P(X= 1200) = (0.001)(1-0.001)^{1500-1} = 0.000223\)

p_injured_1500 = round(dgeom(1500, 0.001), 6)
p_injured_1500
## [1] 0.000223


5(c) What is the expected number of hours the driver will drive before being seriously injured.
The expected values of a geometric distribution is the inverse of the probability of success.
\(E(X) = 1/p = 1/0.001 = 1000 hours\)

5(d) Given that a driver has driven 1200 hours,what is the probability that he or she will be injured in the next 100 hours
This means that we want to get the probability that the driver will be injured after 1200 hours but before 1300 hours.
p(X=injured in the next 100 hours)= P(1300) - P(1200)

p_injured_next_100 = round((dgeom(1300, 0.001) - dgeom(1200, 0.001)), 6)
p_injured_next_100
## [1] -2.9e-05

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

Solution 6
We will model this using the poison distribution.
rate = \(\lambda\) = 1 in 1000
6(a) Probability that the generator will fail more than twice in 1000 hours P(X = more than 2) = 1 - P(X <= 2)

p_less_than_equal_2 = ppois(2, 1)
p_more_than_2 = round((1 - p_less_than_equal_2), 4)
p_more_than_2
## [1] 0.0803


6(b) Expected Value
The expected value is 1 in 1000.

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

Solution 7
This assumes a uniform distribution 7(a) Probability that the patient will wait more than 10 minutes

# P(X > 10) = 1 - P(X<=10)
p_10mins_or_less = punif(10,0,30)
p_more_than_10mins = round((1 - p_10mins_or_less), 4)
p_more_than_10mins
## [1] 0.6667



7(b) If the patient has already waited 10mins, what is the probability that the patient will wait at least another 5 minutes

p_15mins = 1 - punif(15,10,30)
P_10mins =  1-punif(10,10,30)
p_atleast_another_5mins = round((p_15mins/P_10mins), 4)
p_atleast_another_5mins
## [1] 0.75


7(c) Expected waiting time

expected_wait_time = (0 + 30)/2
expected_wait_time
## [1] 15
Problem 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? 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?


Solution 8
The exponential distribution is given by \(f(x) = \lambda e^{-\lambda x}\)
Expected value, E(x) = 10
8(a) What is the expected failure time
\(E(X) = \frac{1}{\lambda}\)
\(\lambda = 1/10 = 0.1/year\)
So, the parameter \(\lambda=0.1\); Therefore the expected failure time is 10 years.

8(b) What is the Standard Deviation?
\(\sigma = \frac{1}{\lambda}\)
\(sigma = \frac{1}{0.1} = 10\)
Therefore, the standard deviation is 10 years as well.


8(c) Probability MRI will fail after 8 years
P(X > 8) = 1 - P(X<=8)

p_fail_after_8years = round((1 - pexp(8, 0.1)), 4)
p_fail_after_8years
## [1] 0.4493


8(d) Probability that the MRI machine will fail in the next two years after owning it for 8 years.

p_fail_after_2years_given8 = round(((pexp(10,.1)-pexp(8,.1))*(1-pexp(8,.1)))/(1-pexp(8,.1)), 4)
p_fail_after_2years_given8
## [1] 0.0814