search_delta: Search Box-Cox transformation parameter

Description Usage Arguments Value Author(s) References Examples

View source: R/misc.R

Description

Search Box-Cox transformation parameter.

Usage

1
search_delta(s, y, type = "ML", dmin = -2, dmax = 2)

Arguments

s

Integer vector. Parsonnet Score values within a range of 0 to 100 representing the preoperative patient risk.

y

Double. Binary (0/1) outcome values of each operation.

type

Character. If type = "ML" Maximum Likelihood used to search the Box-Cox transformation parameter, type = "Pearson" uses a Pearson measure.

dmin

Double. Minimum value for the grid search.

dmax

Double. Maximum value for the grid search.

Value

Returns a single value for the Box-Cox transformation parameter.

Author(s)

Philipp Wittenberg

References

Knoth S, Wittenberg P and Gan FF (2019). Risk-adjusted CUSUM charts under model error. Statistics in Medicine, 38(12), pp. 2206–2218..

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
## load data
data("cardiacsurgery", package = "spcadjust")

## preprocess data to 30 day mortality and subset data to
## phase I (In-control) and phase II (monitoring)
SALL <- cardiacsurgery %>% rename(s = Parsonnet) %>%
  mutate(y = ifelse(status == 1 & time <= 30, 1, 0),
         phase = factor(ifelse(date < 2*365, "I", "II")))

## subset phase I (In-control)
SI <- filter(SALL, phase == "I") %>% select(s, y)

## search delta
dML <- search_delta(SI$s, SI$y, type = "ML")
dQQ <- search_delta(SI$s, SI$y, type = "Pearson")

## show Log-likelihood (ell()) and Pearson measure (QQ()) for each delta
delta <- c(-2, -1, 0, dML, dQQ, 0.5, 1, 2)
r <- sapply(delta, function(i) rbind(i, ell(SI$s, SI$y, i), QQ(SI$s, SI$y, i)))
rownames(r) <- c("d", "l", "S")
t(r)
data.frame(t(r)) %>% filter(l == max(l) | S == min(S))

## End(Not run)

vlad documentation built on Feb. 15, 2021, 5:12 p.m.