Bayesian

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

sensitivity=0.96
specificity=0.98
prevalence=0.001
actually_positive=(sensitivity * prevalence) / ((sensitivity * prevalence) + ((1 - specificity) * (1 - prevalence)))

print(actually_positive)
## [1] 0.04584527

About 4.58% of individuals.

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?

num_individuals=100000
true_positives=actually_positive * num_individuals
positive_cost=100000
test_cost=1000
tot_cost=(positive_cost * actually_positive)+(test_cost * num_individuals)

print(tot_cost)
## [1] 100004585

The cost for treating 100,000 individuals is $100,004,585.

t # Binomial

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

prob_inspec=0.05
num_mon=24
k=2
two_inspections=dbinom(k, size = num_mon, prob = prob_inspec)
print(two_inspections)
## [1] 0.2232381

There is a 22.32% chance of receiving two inspections after 24 months.

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

two_plus_inspections=sum(dbinom(k:num_mon, size = num_mon, prob = prob_inspec))
print(two_plus_inspections)
## [1] 0.3391827

There is a 33.92% chance of receiving at least 2 or more inspections after 24 months.

What is the probability that your received fewer than 2 inspections?

less_than_two_inspections=sum(dbinom(0:(k-1), size = num_mon, prob = prob_inspec))
print(less_than_two_inspections)
## [1] 0.6608173

There is a 66.08% chance of having less than 2 inspections.

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

expected=num_mon * prob_inspec
print(expected)
## [1] 1.2

One inspection is the expected amount.

What is the standard deviation?

sd=sqrt(num_mon * prob_inspec * (1 - prob_inspec))
print(sd)
## [1] 1.067708

Standard deviation is about 1.07.

#Poisson

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

pph=10 #patients per hour
k=3
prob_3_patients=dpois(k, pph)
print(prob_3_patients)
## [1] 0.007566655

There is a .76% chance of the clinic receiving just 3 patients in one hour.

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

ten_plus=11:100
prob_ten_plus=sum(dpois(ten_plus, pph))
print(prob_ten_plus)
## [1] 0.4169602

There is a 41.70% chance of more than 10 patients arriving at the clinic.

How many would you expect to arrive in 8 hours?

h=8
eight_hours_expected=pph * h
print(eight_hours_expected)
## [1] 80

Eighty patients are expected in eight hours.

What is the standard deviation of the appropriate probability distribution?

sd=sqrt(pph)
print(sd)
## [1] 3.162278

The standard deviation is about 3.16.

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?

Since we expect to receive 80 patients daily, I would say that these family practices are not performing as well with their turnout. I would need to know more about their work hours to determine their percent utilization, but I would most likely recommend a fourth clinic or increasing availability for patients.

Hypergeometric

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

tot=30
nurses=15
non_nurses=15
disney_nurses=5
disney_prob_5_nurses <- dhyper(disney_nurses, m = nurses, n = non_nurses, k = disney_nurses)

print(disney_prob_5_nurses)
## [1] 0.0210728

There is a 2.11% chance that those selected for the trip were done so in an unbiased way.

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

exp_disney_nurses=(nurses/tot) * 6
exp_disney_non_nurses=(non_nurses/tot) * 6

print(exp_disney_nurses)
## [1] 3
print(exp_disney_non_nurses)
## [1] 3

I would have expected three nurses and three non-nurses to have been selected for this trip. This is because they make up a 1:1 ratio of the staff, so it makes sense for the trip to be half nurses and half non-nurses.

Geometric

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

iph=0.001  # .1% probability of injury per hour
tot_hours=1200
prob_injured_year=1 - dpois(0,tot_hours * iph)

print(prob_injured_year)
## [1] 0.6988058

There is a 69.88% chance.

In the course of 15 months?

tot_hours_15_mon= tot_hours + (3 * (1200/12))
prob_inj_15_mon=1 - dpois(0,tot_hours_15_mon * iph)

print(prob_inj_15_mon)
## [1] 0.7768698

There is a 77.69% chance of this happening.

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

exp_hour_before_injury=1/iph
print(exp_hour_before_injury)
## [1] 1000

1000 hours.

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

h_driven=1200
next_100=100
prob_inj_next_100=1 - dpois(0,(h_driven + next_100) * iph)

print(prob_inj_next_100)
## [1] 0.7274682

There is a 72.74% of this happening.

  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?
frph=1/1000 #fail rate per hour
tot_hours=1000

fail_twice=dpois(2,(tot_hours * frph))

two_plus_fails <- 1 - (fail_twice + dpois(1, lambda = tot_hours * frph) + dpois(0, lambda = tot_hours * frph))
print(two_plus_fails)
## [1] 0.0803014

There is about 8.03% chance that the generator fails more thn twice in 1000 hours.

What is the expected value?

exp_fail <- tot_hours * frph
print(exp_fail)
## [1] 1

I expect it to fail once.

  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?

wait_time1=0
wait_time2=30
p_more_than_10=1 - punif(10, wait_time1, wait_time2)

print(p_more_than_10)
## [1] 0.6666667

There is about 66.67% chance that the patient will wait at least 10 minutes before being seen.

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?

wait_time_left=wait_time2-10
wait_5_more_min=1 - punif(5,0,wait_time_left)

print(wait_5_more_min)
## [1] 0.75

There is a 75% chance that the patient will have to wait at least 5 more minutes.

What is the expected waiting time?

exp_wait_time=(wait_time1+wait_time2)/2
print(exp_wait_time)
## [1] 15

I would expect a patient to wait 15 minutes. This is between the 0 and 30 minutes of wait time.

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?

lifetime=10
exp_failure_time=lifetime
print(exp_failure_time)
## [1] 10

I would expect the failure time to be 10 years. This is the given expected value.

What is the standard deviation?

sd=lifetime
print(sd)
## [1] 10

The standard deviation is 10.

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

fail_after=8
fail_after_8_yrs=pexp(fail_after, rate = 1 / lifetime, lower.tail = FALSE)
print(fail_after_8_yrs)
## [1] 0.449329

There is a 44.93% chance.

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?

two_more_yrs=2
fail_after_2_more=1-pexp(two_more_yrs, rate = 1 / lifetime)

print(fail_after_2_more)
## [1] 0.8187308

There is an 81.87% chance of this happening.