sensuc {rms} | R Documentation |
Sensitivity to Unmeasured Covariables
Description
Performs an analysis of the sensitivity of a binary treatment ()
effect to an unmeasured binary confounder (
) 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
variables added to the original model. The sequence of models is formed
by simultaneously varying
and
, where
measures
the association between
and
and
measures the
association between
and
, where
is the outcome of
interest. For Cox models, an approximate solution is used by letting
represent some binary classification of the event/censoring time
and the event indicator. For example,
could be just be the
event indicator, ignoring time of the event or censoring, or it could be
if a subject failed before one year and
otherwise. When
for each combination of
and
the vector of binary values
is generated, one of two methods is used to constrain the
properties of
. With either method, the overall prevalence of
is constrained to be
prev.u
. With the default method
(or.method="x:u y:u"
), is sampled so that the
odds ratio is
and the
odds ratio is
. With the
second method,
is sampled according to the model
, where
and
and
is determined so that the
prevalence of
is
prev.u
. This second method results in
the adjusted odds ratio for given
being
whereas the default method forces the unconditional (marginal)
odds ratio to be
. Rosenbaum uses the default method.
There is a plot
method for plotting objects created by
sensuc
. Values of are placed on the x-axis and observed
marginal odds or hazards ratios for
(unadjusted ratios) appear
on the y-axis. For Cox models, the hazard ratios will not agree exactly
with
: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
combination the effect of
adjusted for
(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
effect ratio at the
,
combination
along with its
statistic underneath in smaller letters, and an
option to draw the effect ratio in one of four colors depending on the
significance of the
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 class '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',
ylab=if(x$type=='lrm')'Odds Ratio for Y:U' else
'Hazard Ratio for Y:U',
digits=2, cex.effect=.75, cex.z=.6*cex.effect,
delta=diff(par('usr')[3:4])/40,
type=c('symbols','numbers','colors'),
pch=c(15,18,5,0), col=c(2,3,1,4), alpha=.05,
impressive.effect=function(x)x > 1,...)
Arguments
fit |
result of |
x |
result of |
or.xu |
vector of possible odds ratios measuring the |
or.u |
vector of possible odds ratios measuring the |
prev.u |
desired prevalence of |
constrain.binary.sample |
By default, the binary |
or.method |
see above |
event |
a function classifying the response variable into a binary event for the
purposes of constraining the association between |
ylim |
y-axis limits for |
xlab |
x-axis label |
ylab |
y-axis label |
digits |
number of digits to the right of the decimal point for drawing numbers
on the plot, for
|
cex.effect |
character size for drawing effect ratios |
cex.z |
character size for drawing |
delta |
decrement in |
type |
specify |
pch |
4 plotting characters corresponding to positive and significant
effects for |
col |
4 colors as for |
alpha |
significance level |
impressive.effect |
a function of the odds or hazard ratio for |
... |
optional arguments passed to |
Value
sensuc
returns an object of class "sensuc"
with the following elements: OR.xu
(vector of desired odds ratios or
values),
OOR.xu
(observed marginal odds ratios),
OR.u
(desired odds
ratios or
values),
effect.x
(adjusted odds or hazards ratio for
in a model adjusted for
and all of the other predictors),
effect.u
(unadjusted odds or hazards ratios),
effect.u.adj
(adjusted odds or hazards ratios),
(Z-statistics),
prev.u
(input to sensuc
), cond.prev.u
(matrix with one row per ,
combination, specifying prevalences of
conditional on
and
combinations), and
type
("lrm"
or "cph"
).
Author(s)
Frank Harrell
Mark Conaway
Department of Biostatistics
Vanderbilt University School of Medicine
fh@fharrell.com, mconaway@virginia.edu
References
Rosenbaum, Paul R (1995): Observational Studies. New York: Springer-Verlag.
Rosenbaum P, Rubin D (1983): Assessing sensitivity to an unobserved binary covariate in an observational study with binary outcome. J Roy Statist Soc B 45:212–218.
Lee WC (2011): Bounding the bias of unmeasured factors with confounding and effect-modifying potentials. Stat in Med 30:1007-1017.
See Also
Examples
set.seed(17)
x <- sample(0:1, 500,TRUE)
y <- sample(0:1, 500,TRUE)
y[1:100] <- x[1:100] # induce an association between x and y
x2 <- rnorm(500)
f <- lrm(y ~ x + x2, x=TRUE, y=TRUE)
#Note: in absence of U odds ratio for x is exp(2nd coefficient)
g <- sensuc(f, c(1,3))
# Note: If the generated sample of U was typical, the odds ratio for
# x dropped had U been known, where U had an odds ratio
# with x of 3 and an odds ratio with y of 3
plot(g)
# Fit a Cox model and check sensitivity to an unmeasured confounder
# require(survival)
# f <- cph(Surv(d.time,death) ~ treatment + pol(age,2)*sex, x=TRUE, y=TRUE)
# sensuc(f, event=function(y) y[,2] & y[,1] < 365.25 )
# Event = failed, with event time before 1 year
# Note: Analysis uses f$y which is a 2-column Surv object