\(~\)
\(~\)
\(A_1\) = Actual Positive
\(A_2\) = Actual Negative
B = Positive Test
P(\(A_1\)) = 0.001
P(B | \(A_1\)) = 0.96
P(B | \(A_2\)) = 0.02 (1 - 0.98)
P(\(A_2\)) = 0.999
# 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?
# With the Bayes method try to find P(A1 | B):
paste("The probability that an individual who is reported as positive by the new test actually has the disease is",
round(0.96 * 0.001/(0.96 * 0.001 + 0.02 * 0.999), 4) * 100,
"%")
## [1] "The probability that an individual who is reported as positive by the new test actually has the disease is 4.58 %"
\(~\)
Median cost per positive case (CPPC) = 100,000
Cost per Administration (CPA) = 1,000
Individuals (n) = 100,000
Prevalence Rate (pr) = .001
\(~\)
# 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?
# Key
<- 1e+05
CPPC <- 1000
CPA <- 1e+05
n <- 0.001
pr
# finding cost per case
<- CPPC + CPA
cost_per_case cost_per_case
## [1] 101000
# Of the 100000 individuals, the prevalence rate of 0.1%,
# you will have 100 individuals that will get a positive
# result.
<- n * pr
positive_case positive_case
## [1] 100
# With the 96% of actual positive cases from the 100
# individuals, only 96 will actually be positive and 4 will
# be false positive.
# Finding true negative and false negative cases.
<- (n - 100)
true_negative <- true_negative * 0.98 # multiplying by negative cases percent
true_neg true_neg
## [1] 97902
<- true_negative - true_neg
false_negative false_negative
## [1] 1998
# Find first year cost for positive cases
<- (96 + false_negative) * cost_per_case # using the 96 of actual positive cases and adding false negative cases and multiplying it to the cost per case.
first_year_cost paste("The total first year cost for treating 100,000 individuals is",
first_year_cost)
## [1] "The total first year cost for treating 100,000 individuals is 211494000"
\(~\)
n = size
P = probability
x = inspections
# Setting variables
<- 24
n <- 0.05
P <- 2
x
# What is the probability that, after 24 months, you
# received exactly 2 inspections?
paste("The probability that after 24 months you receive exactly 2 inspections is",
round(dbinom(x, n, P), 4) * 100, "%.")
## [1] "The probability that after 24 months you receive exactly 2 inspections is 22.32 %."
# What is the probability that, after 24 months, you
# received 2 or more inspections? P(two or more) = 1 -
# P(1) - P(0)
paste("The probability that after 24 month you received 2 or more inspections is",
round(1 - (dbinom(1, n, P) + dbinom(0, n, P)), 4) * 100,
"%.")
## [1] "The probability that after 24 month you received 2 or more inspections is 33.92 %."
# What is the probability that your received fewer than 2
# inspections?
paste("The probability that you received fewer than 2 inspections is",
round(dbinom(1, n, P) + dbinom(0, n, P), 4) * 100, "%.")
## [1] "The probability that you received fewer than 2 inspections is 66.08 %."
# What is the expected number of inspections you should
# have received?
paste("The expected number of inspections you should have received is",
* P), ".") (n
## [1] "The expected number of inspections you should have received is 1.2 ."
# What is the standard deviation?
paste("The standard deviation is", round(sqrt(n * P * (1 - P)),
3), ".")
## [1] "The standard deviation is 1.068 ."
\(~\)
Key:
r = rate = 10
<- 10
r
# What is the probability that exactly 3 arrive in one
# hour?
paste("The probability that exactly 3 arrive in one hour is",
round(dpois(3, r), 4) * 100, "%.")
## [1] "The probability that exactly 3 arrive in one hour is 0.76 %."
# What is the probability that more than 10 arrive in one
# hour?
paste("The probability that exactly 3 arrive in one hour is",
round(1 - ppois(10, r), 4) * 100, "%.")
## [1] "The probability that exactly 3 arrive in one hour is 41.7 %."
# How many would you expect to arrive in 8 hours?
<- 10
per_hour paste("The amount you would expect to arrive in 8 hours is",
8 * per_hour), "patients.") (
## [1] "The amount you would expect to arrive in 8 hours is 80 patients."
# What is the standard deviation of the appropriate
# probability distribution?
paste("The standard deviation os the appropriate probability distribution is",
round(sqrt(r)), ".")
## [1] "The standard deviation os the appropriate probability distribution is 3 ."
# 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?
paste("The percent utilization for three family practice providers that can see 24 templated patients each day is",
round(80/72 * 100))
## [1] "The percent utilization for three family practice providers that can see 24 templated patients each day is 111"
paste("The recommendations based on the amount expected versus the amount that can be served is to extend the hours of operation or hire more staff to cover the 8 additional patients.")
## [1] "The recommendations based on the amount expected versus the amount that can be served is to extend the hours of operation or hire more staff to cover the 8 additional patients."
\(~\)
# Key
<- 5
x <- 15
m <- 15
n <- 6
k
# What was the probability he/she would have selected five
# nurses for the trips?
paste("The probability he/she would have selected five nurses for the trips is",
round(dhyper(x, m, n, k, log = FALSE), 4) * 100, "%.")
## [1] "The probability he/she would have selected five nurses for the trips is 7.59 %."
# How many nurses would we have expected your subordinate
# to send?
paste("The subordinate will need to send", 15 * 6/(15 + 15),
"nurses.")
## [1] "The subordinate will need to send 3 nurses."
# How many non-nurses would we have expected your
# subordinate to send?
paste("The subordinate will need to send", (6 - 3), "non-nurses.")
## [1] "The subordinate will need to send 3 non-nurses."
\(~\)
# Key
<- 0.001
p <- 1 - p
q <- 1200
h_12 <- 1500
h_15
# What is the probability that the driver will be seriously
# injured during the course of the year?
paste("The probability that the driver will be seriously injured during the course of the year is",
round((pgeom(h_12, p)), 4) * 100, "%.")
## [1] "The probability that the driver will be seriously injured during the course of the year is 69.93 %."
# In the course of 15 months?
paste("The probabilty that the driver will be seriously injured during the course of 15 months is",
round((pgeom(h_12 * (15/12), p)), 4) * 100, "%.")
## [1] "The probabilty that the driver will be seriously injured during the course of 15 months is 77.73 %."
# What is the expected number of hours that a driver will
# drive before being seriously injured?
paste("The expected number of hours a driver will driver before being seriously injured is",
1/0.001), "hours.") (
## [1] "The expected number of hours a driver will driver before being seriously injured is 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?
paste("The probability that he or she will be injured in the next 10 hours after driving 1200 hours is",
round(pgeom(100, p), 4) * 100, "%.")
## [1] "The probability that he or she will be injured in the next 10 hours after driving 1200 hours is 9.61 %."
\(~\)
# What is the probability that the generator will fail more
# than twice in 1000 hours?
paste("The probability that the generator will fail more than twice in 1000 hours is",
round(1 - ppois(2, 1), 4) * 100, "%.")
## [1] "The probability that the generator will fail more than twice in 1000 hours is 8.03 %."
# What is the expected value?
paste("The expected value is", "lambda = 1")
## [1] "The expected value is lambda = 1"
\(~\)
# Key
<- 10
w <- 0
min <- 30
max
# What is the probability that this patient will wait more
# than 10 minutes?
paste("The probability that this patient will wait for more than 10 minutes is",
round(1 - punif(w, min, max), 4) * 100, "%.")
## [1] "The probability that this patient will wait for more than 10 minutes is 66.67 %."
# 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, 10, 30)
PA <- 1 - punif(10, 10, 30)
PB paste("The probability that he / she will wait at least anohter 5 minutes prior to being seen is",
/PB) * 100, "%.") (PA
## [1] "The probability that he / she will wait at least anohter 5 minutes prior to being seen is 75 %."
# What is the expected waiting time?
paste("The expected waiting time is", 1/2 * (0 + 30), "minutes.")
## [1] "The expected waiting time is 15 minutes."
\(~\)
<- 1/10
lambda
# What is the expected failure time?
paste("The expected failure time is 10.")
## [1] "The expected failure time is 10."
# What is the standard deviation?
paste("The standard deviation is also 10.")
## [1] "The standard deviation is also 10."
# What is the probability that your MRI will fail after 8
# years?
paste("The probability that your MRI will fail after 8 years is",
round(1 - pexp(8, lambda), 4) * 100, "%.")
## [1] "The probability that your MRI will fail after 8 years is 44.93 %."
# 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?
paste("The probability that it will fail in the next two years is",
round(pexp((10 - 8), lambda), 4) * 100, "%.")
## [1] "The probability that it will fail in the next two years is 18.13 %."