Bayes’ Theroem P(A|B) = P(B|A)P(A)/P(B)
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(disease|positive) = (P(positive|disease)P(disease))/(P(positive|disease)P(disease) + P(positive|non-disease)P(non-disease))
# sensitivy = P(positive|disease)
pos_sensitivity = .96
neg_specificity = .98
#false_positive = P(positive|non-disease)
false_positive = 1 - neg_specificity
# prevalence = P(disease)
disease_prevalence = .001
# disease_free = P(non-disease)
disease_free = 1 - disease_prevalence
(positive_prob = (pos_sensitivity * disease_prevalence)/((pos_sensitivity * disease_prevalence)+(false_positive * disease_free)))
## [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?
num_individuals = 100000
median_cost = 100000
test_cost = 1000
(positive_prob)
## [1] 0.04584527
(num_positive = num_individuals * positive_prob)
## [1] 4584.527
(cost_to_test = test_cost * num_individuals)
## [1] 1e+08
(tot_treatment_cost_1yr = (num_positive * median_cost) + cost_to_test)
## [1] 558452722
If the probability is that 4.584527% of 100,000 individuals (4,585) will test positive then the total cost of testing and treating those individuals will equal $458,500,000 plus $100,000,000 = $558,500,000.
\[ b\left( n,p,j\right) =\binom{n}{j} p^{i}q^{n-j}\ where\ q=1-p \] What is the probability that after 24 months you received exactly 2 inspections?
n = 24 # number of months
j = 2 # number of inspections
p = .05 # probability of receiving an inspection
(prob_2_inspects = (choose(n,j))*(p^j)*((1-p)^(n-j)))
## [1] 0.2232381
What is the probability that, after 24 months, you received 2 or more inspections?
j <- 1
(one_inspect <- (choose(n,j))*(p)*((1-p)^(n-j)))
## [1] 0.3688282
j <- 0
(zero_inspect <- (choose(n,j))*(p)*((1-p)^(n-j)))
## [1] 0.01459945
(prob_1_or_0 <- one_inspect - zero_inspect)
## [1] 0.3542288
(two_plus_inspect <- 1 - prob_1_or_0)
## [1] 0.6457712
What is the probability that your received fewer than 2 inspections?
(prob_1_or_0)
## [1] 0.3542288
What is the expected number of inspections you should have received? \[ E(X)=n\times p \] or \[ {}_{E\left[ X\right] =(np)(p+(1-p))^{n-1}} \]
# Two ways to calculate the expected value of binomial distribution.
(expected_value <- n * p)
## [1] 1.2
(exp_value <- (n*p)*(p+(1-p))^(n-1))
## [1] 1.2
What is the standard deviation? standard deviation formula for a binomial distribution is \[ \sigma =\sqrt{npq} \ where\ q=1-p \]
(std_dev <- sqrt(n*p*(1-p)))
## [1] 1.067708
Poisson formula \[ p_{x}=\frac{e^{-m}m^{x}}{x!} \] What is the probability that exactly 3 arrive in one hour?
m <- 10 # average number of events given a time interval
x <- 3 # probability that the number of people arrive in an hour
((exp(1)^(-m)*m^(x))/factorial(x))
## [1] 0.007566655
What is the probability that more than 10 arrive in one hour?
m_range <- c(0:10)
poisson_values <- c()
for (i in m_range){
x <- (exp(1)^(-m)*m^(i))/factorial(i)
poisson_values <- append(poisson_values, x)
}
(1 - sum(poisson_values))
## [1] 0.4169602
How many would you expect to arrive in 8 hours? #### Anser: If the average rate is 10 per hour, I would expect 80 people to arrive in 8 hours.
What is the standard deviation of the appropriate probability distribution?
print(sqrt(m))
## [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?
Hypergeometric Formula \[ h(N,k,n,x)=\frac{\binom{k}{x} \binom{N-k}{n-x} }{\binom{N}{n} } \]
h(n,a,k) = ((choose(k,x))*(choose((n-k), (a-x))))/(choose(n,a))
N = population k = number of nurses N - k = number of other than nurses n = sample size x = selects nurses a = number of company paid trips
If your subordinate acted innocently, what was the probability he/she would have selected five nurses for the trips?
N = 30
k = 15
a = 6
x = 5
(((h_prob <- choose(k,x))*(choose((N-k), (a-x))))/(choose(N,a)))
## [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?
Geometric formula:
\[ P(T=j)=q^{j-1}p \] What is the
probability that the driver will be seriously injured during the course
of the year?
p <- .001
j <- 1200
(((1-p)^(j-1))*p)
## [1] 0.0003013147
In the course of 15 months?
j <- 1500
(((1-p)^(j-1))*p)
## [1] 0.0002231859
What is the expected number of hours that a driver will drive before being seriously injured?
(mean <- (1-p)/p)
## [1] 999
Given that a driver has driven 1200 hours, what is the probability that he or she will be injured in the next 100 hours?
p <- .001
j <- 1200
(1-((1-p)^(j-1))*p)
## [1] 0.9996987
(exp(1)^(-l)*l^(x))/factorial(x)
What is the probability that the generator will fail more than twice in 1000 hours?
m <- 1
# solution will be to find the values when x =0, 1, 2. Then subtract the values from 1.
m_range <- c(0:2)
poisson_values <- c()
for (i in m_range){
x <- (exp(1)^(-m)*m^(i))/factorial(i)
poisson_values <- append(poisson_values, x)
}
(1 - sum(poisson_values))
## [1] 0.0803014
What is the expected value?
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?
Exponential distribution m = 1 / mu pdf = m*(exp(1)^(-mx))
What is the expected failure time? #### Answer: The expected failure time is the stated expected value of 10 years.
What is the standard deviation?
(sqrt(1/(10^2)))
## [1] 0.1
What is the probability that your MRI will fail after 8 years?
m = .1
x = 8
(m*(exp(1)^((-m)*x)))
## [1] 0.0449329
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?