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 data
prevalence <- 0.001 # Prevalence rate
sensitivity <- 0.96 # Sensitivity of the test
specificity <- 0.98 # Specificity of the test
total_individuals <- 100000 # Total number of individuals
cost_per_positive_case <- 100000 # Cost per positive case
test_cost_per_individual <- 1000 # Cost of the test per administration
# Calculate the probability of having the disease and testing positive (True Positives)
P_Disease_Positive <- prevalence * sensitivity
# Calculate the probability of not having the disease but testing positive (False Positives)
P_NoDisease_Positive <- (1 - prevalence) * (1 - specificity)
# Calculate the total probability of testing positive
P_Positive <- P_Disease_Positive + P_NoDisease_Positive
# Calculate the conditional probability of having the disease given a positive test (Posterior Probability)
P_Disease_given_Positive <- P_Disease_Positive / P_Positive
# Calculate the total cost for treating 100,000 individuals
total_cost <- total_individuals * (P_Disease_given_Positive * cost_per_positive_case + (1 - P_Disease_given_Positive) * test_cost_per_individual)
# Display the results
cat("Probability that an individual who is reported as positive by the new test actually has the disease:", P_Disease_given_Positive, "\n")
## Probability that an individual who is reported as positive by the new test actually has the disease: 0.04584527
cat("Total first-year cost for treating 100,000 individuals:", total_cost, "\n")
## Total first-year cost for treating 100,000 individuals: 553868195
2- 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?
# Given data
p_inspection <- 0.05
n_months <- 24
# 1. Probability of receiving exactly 2 inspections in 24 months
k <- 2
probability_2_inspections <- dbinom(k, n_months, p_inspection)
# 2. Probability of receiving 2 or more inspections in 24 months
probability_2_or_more_inspections <- 1 - pbinom(1, n_months, p_inspection)
# 3. Probability of receiving fewer than 2 inspections in 24 months
probability_less_than_2_inspections <- pbinom(1, n_months, p_inspection)
# 4. Expected number of inspections
expected_inspections <- n_months * p_inspection
# 5. Standard deviation
sd_inspections <- sqrt(n_months * p_inspection * (1 - p_inspection))
# Display the results
cat("1. Probability of receiving exactly 2 inspections:", probability_2_inspections, "\n")
## 1. Probability of receiving exactly 2 inspections: 0.2232381
cat("2. Probability of receiving 2 or more inspections:", probability_2_or_more_inspections, "\n")
## 2. Probability of receiving 2 or more inspections: 0.3391827
cat("3. Probability of receiving fewer than 2 inspections:", probability_less_than_2_inspections, "\n")
## 3. Probability of receiving fewer than 2 inspections: 0.6608173
cat("4. Expected number of inspections:", expected_inspections, "\n")
## 4. Expected number of inspections: 1.2
cat("5. Standard deviation of inspections:", sd_inspections, "\n")
## 5. Standard deviation of inspections: 1.067708
3-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?
# Given data
arrival_rate_per_hour <- 10
number_of_arrivals_3 <- 3
hours_in_a_day <- 24
providers <- 3
patients_per_provider_per_day <- 24
# 1. Probability that exactly 3 patients arrive in one hour
probability_3_patients <- dpois(number_of_arrivals_3, lambda = arrival_rate_per_hour)
# 2. Probability that more than 10 patients arrive in one hour
probability_more_than_10_patients <- 1 - ppois(10, lambda = arrival_rate_per_hour)
# 3. Expected number of patients to arrive in 8 hours
expected_arrivals_in_8_hours <- hours_in_a_day * arrival_rate_per_hour
# 4. Standard deviation of the Poisson distribution
sd_poisson <- sqrt(arrival_rate_per_hour)
# 5. Calculate total patients the providers can see in one day
total_patients_per_day <- providers * patients_per_provider_per_day
# 6. Calculate percent utilization
percent_utilization <- (expected_arrivals_in_8_hours / total_patients_per_day) * 100
# Display the results
cat("1. Probability that exactly 3 patients arrive in one hour:", probability_3_patients, "\n")
## 1. Probability that exactly 3 patients arrive in one hour: 0.007566655
cat("2. Probability that more than 10 patients arrive in one hour:", probability_more_than_10_patients, "\n")
## 2. Probability that more than 10 patients arrive in one hour: 0.4169602
cat("3. Expected number of patients to arrive in 8 hours:", expected_arrivals_in_8_hours, "\n")
## 3. Expected number of patients to arrive in 8 hours: 240
cat("4. Standard deviation of the Poisson distribution:", sd_poisson, "\n")
## 4. Standard deviation of the Poisson distribution: 3.162278
cat("5. Percent utilization of the three family practice providers:", percent_utilization, "%\n")
## 5. Percent utilization of the three family practice providers: 333.3333 %
# Recommendations
if (percent_utilization > 100) {
cat("Recommendation: The providers are overbooked. Consider hiring additional providers.")
} else {
cat("Recommendation: The providers are underutilized. You may optimize the schedule or reduce staff.")
}
## Recommendation: The providers are overbooked. Consider hiring additional providers.
4- 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?
# Given data
total_workers <- 30
total_nurses <- 15
total_non_nurses <- 15
total_trips <- 6
nurses_selected <- 5
non_nurses_selected <- 1
# 1. Probability of selecting 5 nurses for the trips
probability_5_nurses <- dhyper(nurses_selected, total_nurses, total_non_nurses, total_trips)
# 2. Expected number of nurses selected
expected_nurses_selected <- total_trips * (total_nurses / total_workers)
# 3. Expected number of non-nurses selected
expected_non_nurses_selected <- total_trips * (total_non_nurses / total_workers)
# Display the results
cat("1. Probability of selecting 5 nurses for the trips:", probability_5_nurses, "\n")
## 1. Probability of selecting 5 nurses for the trips: 0.07586207
cat("2. Expected number of nurses selected:", expected_nurses_selected, "\n")
## 2. Expected number of nurses selected: 3
cat("3. Expected number of non-nurses selected:", expected_non_nurses_selected, "\n")
## 3. Expected number of non-nurses selected: 3
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?
# Given data
probability_per_hour <- 0.001 # 0.1% per hour
total_hours_per_year <- 1200
total_hours_per_15_months <- 1800 # 15 months * 30 days * 24 hours
# 1. Probability of being seriously injured during the course of the year
probability_injured_in_a_year <- 1 - pgeom(total_hours_per_year - 1, probability_per_hour)
# 2. Probability of being seriously injured during the course of 15 months
probability_injured_in_15_months <- 1 - pgeom(total_hours_per_15_months - 1, probability_per_hour)
# 3. Expected number of hours before being seriously injured
expected_hours_before_injured <- 1 / probability_per_hour
# 4. Probability of being injured in the next 100 hours, given 1200 hours have already been driven
probability_injured_in_next_100_hours <- pgeom(1200 + 100, probability_per_hour) - pgeom(1200, probability_per_hour)
# Display the results
cat("1. Probability of being seriously injured during the course of the year:", probability_injured_in_a_year, "\n")
## 1. Probability of being seriously injured during the course of the year: 0.3010134
cat("2. Probability of being seriously injured during the course of 15 months:", probability_injured_in_15_months, "\n")
## 2. Probability of being seriously injured during the course of 15 months: 0.1651501
cat("3. Expected number of hours before being seriously injured:", expected_hours_before_injured, "\n")
## 3. Expected number of hours before being seriously injured: 1000
cat("4. Probability of being injured in the next 100 hours, given 1200 hours have already been driven:", probability_injured_in_next_100_hours, "\n")
## 4. Probability of being injured in the next 100 hours, given 1200 hours have already been driven: 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?
# Given data
failure_rate_per_hour <- 1 / 1000 # Generator fails once in 1000 hours
# 1. Probability that the generator will fail more than twice in 1000 hours
# We'll calculate the complement probability of failing 0, 1, and 2 times, and subtract from 1.
probability_more_than_2_failures <- 1 - (ppois(0, lambda = failure_rate_per_hour * 1000) +
ppois(1, lambda = failure_rate_per_hour * 1000) +
ppois(2, lambda = failure_rate_per_hour * 1000))
# 2. Expected number of failures in 1000 hours
expected_failures <- failure_rate_per_hour * 1000
# Display the results
cat("1. Probability that the generator will fail more than twice in 1000 hours:", probability_more_than_2_failures, "\n")
## 1. Probability that the generator will fail more than twice in 1000 hours: -1.023337
cat("2. Expected number of failures in 1000 hours:", expected_failures, "\n")
## 2. Expected number of failures in 1000 hours: 1
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?
# Given data
min_waiting_time <- 0
max_waiting_time <- 30
waited_time <- 10
additional_waiting_time <- 5
# 1. Probability that the patient will wait more than 10 minutes
probability_more_than_10_minutes <- 1 - punif(waited_time, min_waiting_time, max_waiting_time)
# 2. Probability that the patient will wait at least another 5 minutes after already waiting for 10 minutes
probability_at_least_5_minutes_more <- 1 - punif(waited_time + additional_waiting_time, min_waiting_time, max_waiting_time)
# 3. Expected waiting time
expected_waiting_time <- (min_waiting_time + max_waiting_time) / 2
# Display the results
cat("1. Probability that the patient will wait more than 10 minutes:", probability_more_than_10_minutes, "\n")
## 1. Probability that the patient will wait more than 10 minutes: 0.6666667
cat("2. Probability that the patient will wait at least another 5 minutes after waiting 10 minutes:", probability_at_least_5_minutes_more, "\n")
## 2. Probability that the patient will wait at least another 5 minutes after waiting 10 minutes: 0.5
cat("3. Expected waiting time:", expected_waiting_time, "minutes\n")
## 3. Expected waiting time: 15 minutes
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?
# Given data
lifetime_expected_value <- 10 # years
owned_years <- 8
# 1. Expected failure time
# Expected failure time for an exponential distribution
expected_failure_time <- lifetime_expected_value
# 2. Standard deviation
# Standard deviation for an exponential distribution
lambda <- 1 / expected_failure_time
sd_failure_time <- sqrt(1 / (lambda^2))
# 3. Probability that the MRI will fail after 8 years
# Probability that the MRI will fail after 8 years
probability_fail_after_8_years <- pexp(owned_years, rate = lambda, lower.tail = FALSE)
# 4. Probability that the MRI will fail in the next two years, given it has been owned for 8 years
# Probability that the MRI will fail in the next two years, given 8 years have already passed
probability_fail_in_next_2_years <- pexp(2, rate = lambda) - pexp(owned_years, rate = lambda)
# Display the results
cat("1. Expected failure time:", expected_failure_time, "years\n")
## 1. Expected failure time: 10 years
cat("2. Standard deviation of failure time:", sd_failure_time, "years\n")
## 2. Standard deviation of failure time: 10 years
cat("3. Probability that the MRI will fail after 8 years:", probability_fail_after_8_years, "\n")
## 3. Probability that the MRI will fail after 8 years: 0.449329
cat("4. Probability that the MRI will fail in the next two years, given it has been owned for 8 years:", probability_fail_in_next_2_years, "\n")
## 4. Probability that the MRI will fail in the next two years, given it has been owned for 8 years: -0.3694018