Title: | Sensitivity Analysis for Observational Studies |
---|---|
Description: | Observational studies are limited in that there could be an unmeasured variable related to both the response variable and the primary predictor. If this unmeasured variable were included in the analysis it would change the relationship (possibly changing the conclusions). Sensitivity analysis is a way to see how much of a relationship needs to exist with the unmeasured variable before the conclusions change. This package provides tools for doing a sensitivity analysis for regression (linear, logistic, and cox) style models. |
Authors: | Greg Snow <[email protected]> |
Maintainer: | Greg Snow <[email protected]> |
License: | GPL-2 |
Version: | 1.4 |
Built: | 2025-02-16 04:00:12 UTC |
Source: | https://github.com/cran/obsSens |
This package provides functions for doing sensitivity analysis on coefficients of regression type models (regression, logistic regression, cox proportional hazards). These assume a true model of the form: g(y)=beta*x+gamma*u+theta*z where u is an unmeasured potential lurking variable, x is the main variable of interest (treatment) and z represents other potential variables in the model. The response variable (y) can be continuous, binary, or a survival object. These functions examine the effect of u on beta for different values of gamma and the relationship between u and y.
Package: | obsSens |
Type: | Package |
Version: | 1.0 |
Date: | 2007-12-21 |
License: | Artistic-2.0 |
The key functions are all of the form obsSensYXU where Y specifies the type of variable used as the response variable (y), X specifies the type of variable used as the main predictor variable to be tested (x), and U specifies the type of unmeasured variable to use. They can take on the following values: S - survival analysis (Y only), C - Categorical (logistic regression, currently only handles 2 levels), or N - normal (or continuous variables).
All the functions take either a fitted model object (lm, glm, or coxph) or a coefficient value and its confidence interval. You then specify values (vector) for the possible relationship between Y and U and X and U. The return value is a list with a matrix or array with the adjusted coefficients and upper and lower confidence limits.
Greg Snow [email protected]
Lin, DY and Psaty, BM and Kronmal, RA. (1998): Assessing the Sensitivity of Regression Results to Unmeasured Confounders in Observational Studies. Biometrics, 54 (3), Sep, pp. 948-963.
Baer, VL et. als (2007): Do Platelet Transfusions in the NICU Adversely Affect Survival? Analysis of 1600 Thrombocytopenic neonates in a mulihospital healthcare system. Journal of Perinatology, 27, pp. 790-796.
# Recreate tables from above references obsSensCCC( log(23.1), log(c(6.9, 77.7)), g0=c(2,6,10), p0=seq(0,.5,.1), p1=seq(0,1,.2) ) obsSensSCC( log(1.21), log(c(1.09,1.25)), p0=seq(0,.5,.1), p1=seq(0,1,.1), g0=3 ) obsSensCNN( log(1.14), log(c(1.10,1.18)), rho=c(0,.5, .75, .85, .9, .95, .98, .99), gamma=seq(0,1,.2), sdx=4.5 )
# Recreate tables from above references obsSensCCC( log(23.1), log(c(6.9, 77.7)), g0=c(2,6,10), p0=seq(0,.5,.1), p1=seq(0,1,.2) ) obsSensSCC( log(1.21), log(c(1.09,1.25)), p0=seq(0,.5,.1), p1=seq(0,1,.1), g0=3 ) obsSensCNN( log(1.14), log(c(1.10,1.18)), rho=c(0,.5, .75, .85, .9, .95, .98, .99), gamma=seq(0,1,.2), sdx=4.5 )
Computes a Sensitivity analysis for a coefficient from a regression model (linear, logistic, Cox) on Observational data. Computes new coefficient estimate and confidence interval for various relationships between the response, predictor of interest, and an unmeasured variable. The last 3 letters of each function refer to the type of the variables in the order Y, X, U with C meaning categorical, N meaning normal (continuous), and S being a survival object.
obsSensCCC(model, which = 2, g0 = c(2, 6, 10), g1, p0 = seq(0, 1, 0.2), p1 = p0, logOdds = FALSE, method = c("approx", "sim")) obsSensCCN(model, which = 2, gamma = round(seq(0, 2 * bstar, length = 6), 4), delta = seq(0, 3, 0.5), logOdds = FALSE, method = c("approx", "sim")) obsSensCNN(model, which = 2, gamma = round(seq(0, 2 * bstar, length = 6), 4), rho = c(0, 0.5, 0.75, 0.85, 0.9, 0.95, 0.98, 0.99), sdx, logOdds = FALSE, method = c("approx", "sim")) obsSensNCC(model, which = 2, g0 = c(2, 6, 10), g1, p0 = seq(0, 1, 0.2), p1 = p0, log = TRUE, method = c("approx", "sim")) obsSensNCN(model, which = 2, gamma = round(seq(0, 3, length = 6), 4), delta = seq(0, 3, 0.5), log = TRUE, method = c("approx", "sim")) obsSensNNN(model, which = 2, gamma = round(seq(0, 2 * bstar, length = 6), 4), rho = c(0, 0.5, 0.75, 0.85, 0.9, 0.95, 0.98, 0.99), sdx, log = TRUE, method = c("approx", "sim")) obsSensSCC(model, which = 2, g0 = c(2, 6, 10), g1, p0 = seq(0, 1, 0.2), p1 = p0, logHaz = FALSE, method = c("approx", "sim")) obsSensSCN(model, which = 2, gamma = round(seq(0, 3, length = 6), 4), delta = seq(0, 3, 0.5), logHaz = FALSE, method = c("approx", "sim")) obsSensSNN(model, which = 2, gamma = round(seq(0, 3, length = 6), 4), rho = c(0, 0.5, 0.75, 0.85, 0.9, 0.95, 0.98, 0.99), sdx, logHaz = FALSE, method = c("approx", "sim"))
obsSensCCC(model, which = 2, g0 = c(2, 6, 10), g1, p0 = seq(0, 1, 0.2), p1 = p0, logOdds = FALSE, method = c("approx", "sim")) obsSensCCN(model, which = 2, gamma = round(seq(0, 2 * bstar, length = 6), 4), delta = seq(0, 3, 0.5), logOdds = FALSE, method = c("approx", "sim")) obsSensCNN(model, which = 2, gamma = round(seq(0, 2 * bstar, length = 6), 4), rho = c(0, 0.5, 0.75, 0.85, 0.9, 0.95, 0.98, 0.99), sdx, logOdds = FALSE, method = c("approx", "sim")) obsSensNCC(model, which = 2, g0 = c(2, 6, 10), g1, p0 = seq(0, 1, 0.2), p1 = p0, log = TRUE, method = c("approx", "sim")) obsSensNCN(model, which = 2, gamma = round(seq(0, 3, length = 6), 4), delta = seq(0, 3, 0.5), log = TRUE, method = c("approx", "sim")) obsSensNNN(model, which = 2, gamma = round(seq(0, 2 * bstar, length = 6), 4), rho = c(0, 0.5, 0.75, 0.85, 0.9, 0.95, 0.98, 0.99), sdx, log = TRUE, method = c("approx", "sim")) obsSensSCC(model, which = 2, g0 = c(2, 6, 10), g1, p0 = seq(0, 1, 0.2), p1 = p0, logHaz = FALSE, method = c("approx", "sim")) obsSensSCN(model, which = 2, gamma = round(seq(0, 3, length = 6), 4), delta = seq(0, 3, 0.5), logHaz = FALSE, method = c("approx", "sim")) obsSensSNN(model, which = 2, gamma = round(seq(0, 3, length = 6), 4), rho = c(0, 0.5, 0.75, 0.85, 0.9, 0.95, 0.98, 0.99), sdx, logHaz = FALSE, method = c("approx", "sim"))
model |
A regression model object (result of |
which |
Which coefficient (in the results from
|
g0 |
The slopes on the unmeasured variable when x=0 (on the log scale, not response). |
g1 |
The slopes on the unmeasured variable when x=1, if missing then g1=g0=gamma is assumed. |
p0 |
Probability that U=1 given x=0. |
p1 |
Probability that U=1 given x=1. |
logOdds |
Should the resulting table be on the log scale or response scale. |
log |
Should the resulting table be on the log scale or not. |
logHaz |
Should the resulting table be on the log Hazard ratio scale or Hazard ratio scale. |
method |
Either "approx" or "sim", only approx is currently implemented. |
gamma |
Slopes for U (unmeasured variable). |
delta |
The difference between the mean of U|x=0 and mean of U|x=1. |
rho |
Correlation coefficient between x and U. |
sdx |
Standard Deviation of x (default will try to extract this
from |
These functions are all used to do sensitivity analysis on regression
models for observational data. Currently it works with linear
regression, logistic regression (using glm
), and survival
regressions (using coxph
). All models are of the general form:
y = b1*x + gamma*U + Beta*Z
Where y is the response (or function of the response). The first letter in the triplet at the end of each function name corresponds to the type of response variable, N-normal/numeric (continuous), C-Categorical (binary, logistic regression), and S-Survival (coxph models).
The x variable is the coefficient of interest (usually the treatment variable, or primary predictor of interest). The 2nd letter in the triplet can be C-Categorical (x is 0 or 1, usually control vs. treatment) or N-Numeric, a continuous variable.
The U variable is an unmeasured potential confounder that we believe may be related to y and x. The final letter in the final triplet refers to the type of unmeasured variable that we want to correct for: C-Categorical/binary (0-1, present-absent) or N-Numerical/continuous (in this case it is assumed to be normal with mean 0 and sd 1).
The Z represents additional covariates in the model that are not of primary interest in the sensitivity analysis. It is assumed that Z and U are independent of each other.
For all the functions you specify the potential relationships between
U and y (gamma
, g0
, and g1
) and potential
relationships between x and U (p0
, p1
, delta
, and
rho
). Then the functions compute a new estimate of b1 (the
slope for x, the variable of interest) and its confidence interval
given each combination of the relationships between U, y, and x.
Currently only the approximation method by Lin et. al. is available. In the future a simulation method will also be implemented.
An obsSens object (S3) stored as a list with the following elements:
beta |
A matrix/array with the adjusted slopes for the different conditions. |
lcl |
A matrix/array with the lower confidence intervals for the slopes. |
ucl |
A matrix/array with the upper confidence intervals for the slopes. |
log |
A logical indicating if the values are on the log scale. |
xname |
The 'name' of the x variable of interest |
type |
Character field with the type of y variable, can be 'cat', 'surv', or 'num'. |
Note: Currently there are no checks on whether the conditions will be appropriate for the approximation to be close. See the first paper below for the conditions when the approximation is good.
Greg Snow [email protected]
Lin, DY and Psaty, BM and Kronmal, RA. (1998): Assessing the Sensitivity of Regression Results to Unmeasured Confounders in Observational Studies. Biometrics, 54 (3), Sep, pp. 948-963.
Baer, VL et. als (2007): Do Platelet Transfusions in the NICU Adversely Affect Survival? Analysis of 1600 Thrombocytopenic neonates in a mulihospital healthcare system. Journal of Perinatology, 27, pp. 790-796.
print.obsSens
, summary.obsSens
# Recreate tables from above references obsSensCCC( log(23.1), log(c(6.9, 77.7)), g0=c(2,6,10), p0=seq(0,.5,.1), p1=seq(0,1,.2) ) obsSensSCC( log(1.21), log(c(1.09,1.25)), p0=seq(0,.5,.1), p1=seq(0,1,.1), g0=3 ) obsSensCNN( log(1.14), log(c(1.10,1.18)), rho=c(0,.5, .75, .85, .9, .95, .98, .99), gamma=seq(0,1,.2), sdx=4.5 )
# Recreate tables from above references obsSensCCC( log(23.1), log(c(6.9, 77.7)), g0=c(2,6,10), p0=seq(0,.5,.1), p1=seq(0,1,.2) ) obsSensSCC( log(1.21), log(c(1.09,1.25)), p0=seq(0,.5,.1), p1=seq(0,1,.1), g0=3 ) obsSensCNN( log(1.14), log(c(1.10,1.18)), rho=c(0,.5, .75, .85, .9, .95, .98, .99), gamma=seq(0,1,.2), sdx=4.5 )
Print a nice table of the results from a sensitivity analysis on observational data.
## S3 method for class 'obsSens' print(x, ...) ## S3 method for class 'obsSens' summary(object, digits=3, ...) ## S3 method for class 'summary.obsSens' print(x, ...)
## S3 method for class 'obsSens' print(x, ...) ## S3 method for class 'obsSens' summary(object, digits=3, ...) ## S3 method for class 'summary.obsSens' print(x, ...)
x |
An obsSens object or summary.obsSens object. |
object |
An obsSens object. |
digits |
Passed to |
... |
Additional arguments passed on to print methods for matrix/array. |
These functions print and summarize the results of the obsSens
functions. The only difference in the print and summary methods is
the return value (the information printed to the screen is the same).
The print
function returns a copy of the original object. The summary
function returns a matrix/array of character strings corresponding to
what is printed that can hopefully be used along with other functions
(latex, xtable, odfTable, ...) for typesetting results in other formats.
The print
method returns a copy of the original object. The
summary
method returns a character array/matrix with the
coefficients and confidence intervals to be passed to other
typesetting/printing functions.
Greg Snow [email protected]
# Recreate tables from above references obsSensCCC( log(23.1), log(c(6.9, 77.7)), g0=c(2,6,10), p0=seq(0,.5,.1), p1=seq(0,1,.2) ) obsSensSCC( log(1.21), log(c(1.09,1.25)), p0=seq(0,.5,.1), p1=seq(0,1,.1), g0=3 ) obsSensCNN( log(1.14), log(c(1.10,1.18)), rho=c(0,.5, .75, .85, .9, .95, .98, .99), gamma=seq(0,1,.2), sdx=4.5 )
# Recreate tables from above references obsSensCCC( log(23.1), log(c(6.9, 77.7)), g0=c(2,6,10), p0=seq(0,.5,.1), p1=seq(0,1,.2) ) obsSensSCC( log(1.21), log(c(1.09,1.25)), p0=seq(0,.5,.1), p1=seq(0,1,.1), g0=3 ) obsSensCNN( log(1.14), log(c(1.10,1.18)), rho=c(0,.5, .75, .85, .9, .95, .98, .99), gamma=seq(0,1,.2), sdx=4.5 )