Learn R Programming

vlad (version 0.2.0)

search_delta: Search Box-Cox transformation parameter

Description

Search Box-Cox transformation parameter.

Usage

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.

Examples

Run this code
# 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))
# }

Run the code above in your browser using DataLab