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 we have 100000 people, the matrix below applies.
matrix1 <- matrix(c('', 'Has HIV', 'No HIV', 'Total', 'Positive', '96', '1998', '2094', 'Negative', '4', '97902', '97906', '', '100', '99900', '100000'), nrow = 4, ncol = 4, byrow = TRUE)
matrix1
## [,1] [,2] [,3] [,4]
## [1,] "" "Has HIV" "No HIV" "Total"
## [2,] "Positive" "96" "1998" "2094"
## [3,] "Negative" "4" "97902" "97906"
## [4,] "" "100" "99900" "100000"
# The number of people who are positive:
matrix1[2,4]
## [1] "2094"
# The number of positive people who have the disease:
matrix1[2,2]
## [1] "96"
# Probability:
as.integer(matrix1[2,2]) / as.integer(matrix1[2,4])
## [1] 0.04584527
# P(A | B) = P(B|A)P(A) / SUM(P(B|A)P(A))
# A = Has HIV
# B = Positive
# Bayesian Formula:
(0.96 * 0.001) / ((0.96 * 0.001) + (0.02 * 0.999))
## [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?
# If we assume that out of 100,000 individuals, only 2094 of them will be positive, then we have to account for the cost of the tests and the treatment for each person.
totalPeople <- 100000
costPerTest <- 1000
positivePeople <- 2094
costPerTreatment <- 100000
(totalPeople * costPerTest) + (positivePeople * costPerTreatment)
## [1] 309400000
# However, if we assume that all 100,000 people will need to have treatment, then we will multiply the number of people by the cost of both the test and treatment.
totalPeople * (costPerTest + costPerTreatment)
## [1] 1.01e+10
What is the probability that, after 24 months, you received exactly 2 inspections?
library(pracma)
## Warning: package 'pracma' was built under R version 4.3.2
nchoosek(24, 2) * (0.05 ** 2) * (0.95 ** (24 - 2))
## [1] 0.2232381
What is the probability that, after 24 months, you received 2 or more inspections?
1 - pbinom(1, 24, 0.05)
## [1] 0.3391827
What is the probability that you received fewer than 2 inspections?
pbinom(1, 24, 0.05)
## [1] 0.6608173
What is the expected number of inspections you should have received?
24 * 0.05
## [1] 1.2
What is the standard deviation?
sqrt(24 * 0.05 * (1 - 0.05))
## [1] 1.067708
What is the probability that exactly 3 arrive in one hour?
dpois(3, 10)
## [1] 0.007566655
What is the probability that more than 10 arrive in one hour?
1 - sum(dpois(0:10, 10))
## [1] 0.4169602
How many would you expect to arrive in 8 hours?
10 * 8
## [1] 80
What is the standard deviation of the appropriate probability distribution?
sqrt(10)
## [1] 3.162278
sqrt(10 * 8)
## [1] 8.944272
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?
# In 8 hours, we expect 80 people. If we have 3 providers who can see 24 patients per day, that means... they will see 72 patients.
3 * 24
## [1] 72
# Utilization is 80 / 72
80 / 72
## [1] 1.111111
# 111%
If your subordinate acted innocently, what was the probability he/she would have selected five nurses for the trips?
#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?
6 * (15/30)
## [1] 3
How many non-nurses would we have expected your subordinate to send?
6 * 15/30
## [1] 3
What is the probability that the driver will be seriously injured during the course of the year?
(1 - (1 - 0.001)^1200)
## [1] 0.6989866
In the course of 15 months?
fifteenMonths <- 1200*1.25
(1 - (1 - 0.001)^fifteenMonths)
## [1] 0.7770372
What is the expected number of hours that a driver will drive before being seriously injured?
1 / 0.001
## [1] 1000
Given that a driver has driven 1200 hours, what is the probability that he or she will be injured in the next 100 hours?
(1 - (1 - 0.001)^100)
## [1] 0.09520785
What is the probability that the generator will fail more than twice in 1000 hours?
1 - sum((1 - (1/1000))^(0:2 - 1) * (1/1000))
## [1] 0.997
What is the expected value?
1 / (1/1000)
## [1] 1000
What is the probability that this patient will wait more than 10 minutes?
1 - punif(10, 0, 30)
## [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?
1 - punif(15, 0, 30)
## [1] 0.5
What is the expected waiting time?
(0 + 30) / 2
## [1] 15
What is the expected failure time?
1 / (1/10)
## [1] 10
What is the standard deviation?
1 / (1/10)
## [1] 10
What is the probability that your MRI will fail after 8 years?
1 - exp((-1/10) * 8)
## [1] 0.550671
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?
1 - exp((-1/10) * 2)
## [1] 0.1812692