View source: R/bernoulli_ARL.R
bernoulli_ARL | R Documentation |
This function allows to estimate the Average Run Length (ARL)
of the risk-adjusted Bernoulli CUSUM (see bernoulli_cusum()
)
through a Markov Chain Approach (Brook & Evans(1972) & Steiner et al. (2000)) or
exploiting the relationship with the Sequential Probability Ratio Test (Kemp (1971)).
The function requires the specification of one of the following combinations of parameters
as arguments to the function:
glmmod
& theta
p0
& theta
p0
& p1
Average run length of lower-sided Bernoulli CUSUM charts can be determined
by specifying theta
< 0.
bernoulli_ARL(h, n_grid, glmmod, theta, theta_true, p0, p1, method = c("MC",
"SPRT"), smooth_prob = FALSE)
h |
Control limit for the Bernoulli CUSUM |
n_grid |
Number of state spaces used to discretize the outcome space (when |
glmmod |
Generalized linear regression model used for risk-adjustment as produced by
the function
|
theta |
The
|
theta_true |
The true log odds ratio |
p0 |
The baseline failure probability at |
p1 |
The alternative hypothesis failure probability at |
method |
The method used to obtain the average run length. Either "MC" for Markov Chain or "SPRT" for SPRT methodology. Default = "MC". |
smooth_prob |
Should the probability distribution of failure under the null distribution be smoothed?
Useful for small samples. Can only be TRUE when |
The average run length of a CUSUM chart S_n
is given by
E[\tau_n],
where \tau_n
is defined as:
\tau_n = \inf\{n \geq 0: S_n \geq h\}.
When method = "MC"
, the average run length will be determined by
the Markov Chain approach described
in Brook & Evans (1972), using the risk-adjustment correction proposed in
Steiner et al. (2000). The idea is to discretize the domain (0, h) into n_{grid} -1
state spaces, with E_0
of width w/2
and E_1, \ldots, E_{n_{grid}-1}
of width w
, such that
E_{n_{grid}}
is an absorbing state. This is done using the following steps:
w
is determined using the relationship \frac{2h}{2t-1}
.
Transition probabilities between the states are determined and
'transition matrix' R
is constructed.
The equation (\bm{I}-\bm{R}) \bm{ARL} = \bm{1}
is
solved to find the ARL starting from each of the states.
When method = "SPRT"
, the average run length will be determined by
the relationship between the SPRT and CUSUM described in Kemp (1971), using the risk-adjustment
correction proposed in Steiner et al. (2000).
If N is the run length of a SPRT, P(0) the probability of
a SPRT terminating on the lower boundary of zero and R the run length of
a CUSUM, then:
E[R] = \frac{E[N]}{1 - P(0)}.
E[N]
and P(0)
are completely determined by
G_n(z) = \int_0^h F(z-w) dG_{n-1}(w)
with F(x)
the cdf of the singletons W_n
. The integral can be
approximated using the generalized trapezoidal quadrature rule:
G_n(z) = \sum_{i=0}^{n_{grid}-1} \frac{F(z-x_{i+1}) + F(z-x_{i})}{2} \left(G_{n-1}(x_{i+1}) - G_{n-1}(x_{i}) \right)
A list containing:
ARL_0
: A numeric value indicating the average run length in
number of outcomes when starting from state E_0.
ARL
: A data.frame
containing the average run length (#outcomes)
depending on the state in which the process starts (E_0, E_1, \ldots, E_{n_{grid}-1})
start_val
:Starting value of the CUSUM, corresponding to the
discretized state spaces E_{i}
;
#outcomes
:ARL for the CUSUM with
initial value start_val
;
R
: A transition probability matrix
containing the transition
probabilities between states E_0, \ldots, E_{t-1}
.
R_{i,j}
is the transition probability from state i to state j.
h
: Value of the control limit.
The value of ARL_0
will be printed to the console.
Daniel Gomon
Brook, D., & Evans, D. A. (1972). An Approach to the Probability Distribution of CUSUM Run Length. Biometrika, 59(3), 539-549. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2334805")}
Steiner, S. H., Cook, R. J., Farewell, V. T., & Treasure, T. (2000). Monitoring surgical performance using risk-adjusted cumulative sum charts. Biostatistics, 1(4), 441-452. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/biostatistics/1.4.441")}
Kemp, K. W. (1971). Formal Expressions which Can Be Applied to Cusum Charts. Journal of the Royal Statistical Society. Series B (Methodological), 33(3), 331-360. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/j.2517-6161.1971.tb01521.x")}
bernoulli_cusum
, bernoulli_control_limit
#Determine a risk-adjustment model using a generalized linear model.
#Outcome (failure within 100 days) is regressed on the available covariates:
glmmodber <- glm((survtime <= 100) & (censorid == 1)~ age + sex + BMI,
data = surgerydat, family = binomial(link = "logit"))
#Determine the Average Run Length in number of outcomes for
#control limit h = 2.5 with (0, h) divided into n_grid = 200 segments
ARL <- bernoulli_ARL(h = 2.5, n_grid = 200, glmmod = glmmodber, theta = log(2))
#Calculate ARL, but now exploiting connection between SPRT and CUSUM:
#n_grid now decides the accuracy of the Trapezoidal rule for integral approximation
ARLSPRT <- bernoulli_ARL(h = 2.5, n_grid = 200, glmmod = glmmodber,
theta = log(2), method = "SPRT")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.