N Selina Assignment 5 - Data 605

Noori Selina

  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?

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_A <- 0.001  # Prevalence rate
P_B_given_A <- 0.96  # Sensitivity
P_notB_given_notA <- 0.98  # Specificity

# Calculating P(A|B) using Bayes' theorem
P_B_given_notA <- 1 - P_notB_given_notA
P_notA <- 1 - P_A

P_A_given_B <- (P_B_given_A * P_A) / (P_B_given_A * P_A + P_B_given_notA * P_notA)

print(P_A_given_B)
## [1] 0.04584527

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?

total_people <- 100000
test_cost <- 1000
positive_people <- 2094
treatment_cost <- 100000

total_cost <- (total_people * test_cost) + (positive_people * treatment_cost)
total_cost
## [1] 309400000
total_people * (test_cost + treatment_cost)
## [1] 1.01e+10

The total cost will be $309,400,000 under the conditions of the prevalence, sensitivity, and specificity. Furthermore, if all 100,000 people test positive, the cost will amount to $10,100,000,000.

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

What is the probability that, after 24 months, you received exactly 2 inspections? - After 24 months, the possibility of exactly 2 inspections is 22.32%

months <- 24
probability <- 0.05
inspect <- 2
dbinom(inspect,months,probability)
## [1] 0.2232381

What is the probability that, after 24 months, you received 2 or more inspections? - The probability is 39.92%

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

What is the probability that your received fewer than 2 inspections? - The possibility is 66.08%

(dbinom(0,months,probability)+dbinom(1,months,probability))
## [1] 0.6608173

What is the expected number of inspections you should have received? - 1.2 inspections

expect <- months*probability
expect
## [1] 1.2

What is the standard deviation? - 1.068 is the standard deviation.

std <- sqrt(probability*months*(1-probability))
std
## [1] 1.067708
  1. (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?

What is the probability that exactly 3 arrive in one hour? - 0.757%

dpois(3, 10)
## [1] 0.007566655

What is the probability that more than 10 arrive in one hour? - The probability is 41.69%

1-ppois(10, 10)
## [1] 0.4169602

How many would you expect to arrive in 8 hours? - 80 people

10 * 8
## [1] 80

What is the standard deviation of the appropriate probability distribution? - 3.162 is the standard deviation

std <- sqrt(10)
std
## [1] 3.162278

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?

(80/72*100%=111.11%). The percent utilization is 111%. This means that there are not enough providers for the expected number of patients, as the utilization exceeds 100%. To address this, they should have more doctors, or could refrain from accepting new patients.

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

If your subordinate acted innocently, what was the probability he/she would have selected five nurses for the trips? - 7.59%

#dhyper(k, K, N - K, n)
dhyper(5, 15, 15, 6)
## [1] 0.07586207

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

6 * (15/30)
## [1] 3
  1. (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?

What is the probability that the driver will be seriously injured during the course of the year? - 69.93%

injured_1200 <- pgeom(q=1200 ,prob=0.001)
injured_1500 <- pgeom(q=1500 ,prob=0.001)
injured_1200
## [1] 0.6992876

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

injured_1500
## [1] 0.7772602

Given that a driver has driven 1200 hours, what is the probability that he or she will be injured in the next 100 hours?

injured_1300 <- pgeom(q=1300 ,prob=0.001)
injured_1300 - injured_1200
## [1] 0.02863018
  1. 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?

The likelihood of the generator failing more than twice within a span of 1000 hours is 8%, while the expected value is 1.

p_fail_once <- 1 / 1000 
lambda <- 1000 * p_fail_once
prob_more_than_twice <- 1 - ppois(2, lambda)
prob_more_than_twice
## [1] 0.0803014
expected_value <- lambda
expected_value
## [1] 1
  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?

What is the probability that this patient will wait more than 10 minutes? The probablity is 66.67%

min=0
max=30
1-punif(10, min, max)
## [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? - 0.5

1 - punif(15, 0, 30)
## [1] 0.5

What is the expected waiting time? - The expected wait time is 15 minutes

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

What is the expected failure time? - 10 years

lifetime <- 10

expected_failure_time <- lifetime
expected_failure_time
## [1] 10

What is the standard deviation? - 10

standard_deviation <- lifetime
standard_deviation
## [1] 10

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

time_passed <- 8 
probability_failure_after_8_years <- pexp(time_passed, rate = 1/lifetime, lower.tail = FALSE)
probability_failure_after_8_years
## [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? - 18%

time_remaining <- 2
probability_failure_next_two_years <- pexp(time_remaining, rate = 1/lifetime, lower.tail = TRUE)
probability_failure_next_two_years
## [1] 0.1812692