rms (version 5.1-3.1)

# sensuc: Sensitivity to Unmeasured Covariables

## Description

Performs an analysis of the sensitivity of a binary treatment ($$X$$) effect to an unmeasured binary confounder ($$U$$) for a fitted binary logistic or an unstratified non-time-dependent Cox survival model (the function works well for the former, not so well for the latter). This is done by fitting a sequence of models with separately created $$U$$ variables added to the original model. The sequence of models is formed by simultaneously varying $$a$$ and $$b$$, where $$a$$ measures the association between $$U$$ and $$X$$ and $$b$$ measures the association between $$U$$ and $$Y$$, where $$Y$$ is the outcome of interest. For Cox models, an approximate solution is used by letting $$Y$$ represent some binary classification of the event/censoring time and the event indicator. For example, $$Y$$ could be just be the event indicator, ignoring time of the event or censoring, or it could be $$1$$ if a subject failed before one year and $$0$$ otherwise. When for each combination of $$a$$ and $$b$$ the vector of binary values $$U$$ is generated, one of two methods is used to constrain the properties of $$U$$. With either method, the overall prevalence of $$U$$ is constrained to be prev.u. With the default method (or.method="x:u y:u"), $$U$$ is sampled so that the $$X:U$$ odds ratio is $$a$$ and the $$Y:U$$ odds ratio is $$b$$. With the second method, $$U$$ is sampled according to the model $$logit(U=1 | X, Y) = \alpha + \beta*Y + \gamma*X$$, where $$\beta=\log(b)$$ and $$\gamma=\log(a)$$ and $$\alpha$$ is determined so that the prevalence of $$U=1$$ is prev.u. This second method results in the adjusted odds ratio for $$Y:U$$ given $$X$$ being $$b$$ whereas the default method forces the unconditional (marginal) $$Y:U$$ odds ratio to be $$b$$. Rosenbaum uses the default method.

There is a plot method for plotting objects created by sensuc. Values of $$a$$ are placed on the x-axis and observed marginal odds or hazards ratios for $$U$$ (unadjusted ratios) appear on the y-axis. For Cox models, the hazard ratios will not agree exactly with $$X$$:event indicator odds ratios but they sometimes be made close through judicious choice of the event function. The default plot uses four symbols which differentiate whether for the $$a,b$$ combination the effect of $$X$$ adjusted for $$U$$ (and for any other covariables that were in the original model fit) is positive (usually meaning an effect ratio greater than 1) and "significant", merely positive, not positive and non significant, or not positive but significant. There is also an option to draw the numeric value of the $$X$$ effect ratio at the $$a$$,$$b$$ combination along with its $$Z$$ statistic underneath in smaller letters, and an option to draw the effect ratio in one of four colors depending on the significance of the $$Z$$ statistic.

## Usage

# fit <- lrm(formula=y ~ x + other.predictors, x=TRUE, y=TRUE)  #or
# fit <- cph(formula=Surv(event.time,event.indicator) ~ x + other.predictors,
#            x=TRUE, y=TRUE)sensuc(fit,
or.xu=seq(1, 6, by = 0.5), or.u=or.xu,
prev.u=0.5, constrain.binary.sample=TRUE,
or.method=c("x:u y:u","u|x,y"),
event=function(y) if(is.matrix(y))y[,ncol(y)] else 1*y)# S3 method for sensuc
plot(x,  ylim=c((1+trunc(min(x$effect.u)-.01))/ ifelse(type=='numbers',2,1), 1+trunc(max(x$effect.u)-.01)),
xlab='Odds Ratio for X:U',
# }