DATA 605 Homework5

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 per positive case total and the test itself costs $1000 per administration, what is the total first-year cost for treating 100,000 individuals?

Let’s assume Event B as Positive result Event A1 as Actual HIV positive Event A2 is Actual negative result

P (B | A1) = 0.96 (Probability of correctly reported positive result from the HIV test performed) P (B | A2) = 1 - 0.98= 0.02 (Probability of being tested false positive for HIV ) P (A1) = 0.1% = 0.001 P (A2) = 1 - P(A1) = 0.999

P (A1 | B) = P(B | A1)P(A1) / { P(B | A1)P(A1) + P(B | A2)P(A2) } = (0.96 * 0.001) / ((0.96 * 0.001) + (0.02 * 0.999)) = 0.045

Best estimated cost is $100,000 per positive case. Each test administration cost is $1,000.

What is the Total first-year cost for treating 100,000 #individuals?

Total_Admin_cost <- 100000 * 1000
Positive_treatment_cost <- 100000 * 0.001

Grand_Total_Cost <- Total_Admin_cost + Positive_treatment_cost
Grand_Total_Cost
## [1] 100000100

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?

Probability of receiving inspection = 0.05 Probability of exactly 2 inspections is

dbinom(2, 24, 0.05)
## [1] 0.2232381

Probability of 2 or more inspection P(2 or more) = 1 - P(1) - P(0)

P_2_or_more <- 1 - (dbinom(1, 24, 0.05) + dbinom(0, 24, 0.05))
P_2_or_more
## [1] 0.3391827

Probability of fewer than 2 inspections = P(0) + P(1)

P_less_than_2 <- dbinom(0,24,.05) + dbinom(1,24,.05)
P_less_than_2
## [1] 0.6608173

Expected number of inspections

n <- 24        # number of months
p <- 0.05      # inspection probability
q <- 1 - 0.05  # probability of inspection not done
exp_num_inspections <- n * p * q
exp_num_inspections 
## [1] 1.14

Standard deviation

sd <- (n * p * q)^0.5
sd
## [1] 1.067708

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?

Probability of exactly 3 arriving P(3)

(P_3 <- dpois(3,10))
## [1] 0.007566655

Probability of more than 10 arriving P(>10)

(P_more10 <- 1 - dpois(0:10,10))
##  [1] 0.9999546 0.9995460 0.9977300 0.9924333 0.9810834 0.9621667 0.9369445
##  [8] 0.9099208 0.8874010 0.8748900 0.8748900

Standard deviation of the appropriate probability distribution

(sd <- 10^0.5)
## [1] 3.162278

Percent utilization with 3 providers seeing 24 patients

# Assuming 8 hour workday
num_patients_day <- 8*10
(utilization <- (num_patients_day / (3*24)) *100)
## [1] 111.1111

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?

Probability of sending 5 nurses in a trip P(5)

total_non_nurse <-15 total_nurse <- 15 num_person_trip <- 6

(P_5 <- dhyper(5,15,15,6, log=FALSE))
## [1] 0.07586207

Non-nurses expected to be send

(expected_nurses <- 6*(15/30))
## [1] 3

Expected number of #non-nurses

(expected_non_nurses <- 6 - expected_nurses)
## [1] 3

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

Probability of atleast 1 injury

(P_1 <- 1 - pgeom(1200, 0.001))
## [1] 0.3007124

Probability in 15 months

(P_15mon <- 1 - pgeom(1500, 0.001))
## [1] 0.2227398

Probability of being injured next 100 hours|not injured 1200

# Probability using geometric distribution
(P_geom <- ((pgeom(1300,.001)-pgeom(1200,.001))*(1-pgeom(1200,.001)))/(1-pgeom(1200,.001)))
## [1] 0.02863018

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?

Generator fails once every 1000 hours Probability of failing more than twice

(P_more2 <- 1 - ppois(2,1))
## [1] 0.0803014

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?

Probability of more than 10 min wait

(P_more10 <- 1 - punif(10, 0, 30))
## [1] 0.6666667

Conditional probability of wait 5 mins, after the first 10 mins P(A|B)/P(B)

P_AB <- 1 - punif(15,10,30)
P_B  <- 1 - punif(10,10,30)

(cond_prob <- P_AB/P_B)
## [1] 0.75

Expected wait time

(exp_wait <- 0.5*30)
## [1] 15

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?

MRI machine expected lifetime is 10 yrs

lambda = 1/10

Probability will fail after 8 years

(P_fail8 <- 1 - pexp(8, 0.1))
## [1] 0.449329

Probability it will fail in 2 years | not fail in 8 years

(P_fail2 <-  ((pexp(10,.1)-pexp(8,.1))*(1-pexp(8,.1)))/(1-pexp(8,.1)) )
## [1] 0.08144952