Title: | Regression Standardization |
---|---|
Description: | Contains functionality for regression standardization. Four general classes of models are allowed; generalized linear models, conditional generalized estimating equation models, Cox proportional hazards models and shared frailty gamma-Weibull models. Sjolander, A. (2016) <doi:10.1007/s10654-016-0157-3>. |
Authors: | Arvid Sjolander and Elisabeth Dahlqwist |
Maintainer: | Arvid Sjolander <[email protected]> |
License: | LGPL (>= 3) |
Version: | 3.4.1 |
Built: | 2024-12-11 06:55:07 UTC |
Source: | CRAN |
This is a confint
method for class "stdCoxph"
.
## S3 method for class 'stdCoxph' confint(object, parm, level = 0.95, fun, type="plain", ...)
## S3 method for class 'stdCoxph' confint(object, parm, level = 0.95, fun, type="plain", ...)
object |
an object of class |
parm |
not used. |
level |
the coverage probability of the confidence intervals. |
fun |
a function of one matrix argument with |
type |
a string specifying the type of confidence interval; |
... |
not used. |
confint.stdCoxph
extracts the est
element from object
, and
inputs this to fun
. It then uses the delta method to compute a confidence
interval for the output of fun
.
a matrix with q
rows and 2 columns, containing the computed confidence interval.
Arvid Sjolander.
This is a confint
method for class "stdGee"
.
## S3 method for class 'stdGee' confint(object, parm, level = 0.95, fun, type="plain", ...)
## S3 method for class 'stdGee' confint(object, parm, level = 0.95, fun, type="plain", ...)
object |
an object of class |
parm |
not used. |
level |
the coverage probability of the confidence intervals. |
fun |
a function of one vector argument of length |
type |
a string specifying the type of confidence interval; |
... |
not used. |
confint.stdGee
extracts the est
element from object
, and
inputs this to fun
. It then uses the delta method to compute a confidence
interval for the output of fun
.
a matrix with 1 row and 2 columns, containing the computed confidence interval.
Arvid Sjolander.
This is a confint
method for class "stdGlm"
.
## S3 method for class 'stdGlm' confint(object, parm, level = 0.95, fun, type="plain", ...)
## S3 method for class 'stdGlm' confint(object, parm, level = 0.95, fun, type="plain", ...)
object |
an object of class |
parm |
not used. |
level |
the coverage probability of the confidence intervals. |
fun |
a function of one vector argument of length |
type |
a string specifying the type of confidence interval; |
... |
not used. |
confint.stdGlm
extracts the est
element from object
, and
inputs this to fun
. It then uses the delta method to compute a confidence
interval for the output of fun
.
a matrix with 1 row and 2 columns, containing the computed confidence interval.
Arvid Sjolander.
This is a confint
method for class "stdParfrailty"
.
## S3 method for class 'stdParfrailty' confint(object, parm, level = 0.95, fun, type="plain", ...)
## S3 method for class 'stdParfrailty' confint(object, parm, level = 0.95, fun, type="plain", ...)
object |
an object of class |
parm |
not used. |
level |
the coverage probability of the confidence intervals. |
fun |
a function of one matrix argument with |
type |
a string specifying the type of confidence interval; |
... |
not used. |
confint.stdParfrailty
extracts the est
element from object
, and
inputs this to fun
. It then uses the delta method to compute a confidence
interval for the output of fun
.
a matrix with q
rows and 2 columns, containing the computed confidence interval.
Arvid Sjolander.
parfrailty
fits shared frailty gamma-Weibull models. It is specifically
designed to work with the function stdParfrailty
, which performs regression
standardization in shared frailty gamma-Weibull models.
parfrailty(formula, data, clusterid, init)
parfrailty(formula, data, clusterid, init)
formula |
an object of class " |
data |
a data frame containing the variables in the model. |
clusterid |
an string containing the name of a cluster identification variable. |
init |
an optional vector of initial values for the model parameters. |
parfrailty
fits the shared frailty gamma-Weibull model
where and
are the survival time and covariate vector
for subject
in cluster
, respectively.
is the
Weibull baseline hazard function
where is the shape parameter and
is the scale parameter.
is the unobserved frailty term for cluster
, which is assumed
to have a gamma distribution with scale = 1/shape =
.
is the regression function as specified by the
formula
argument,
parametrized by a vector . The ML estimates
are obtained by maximizing the marginal (over
) likelihood.
An object of class "parfrailty"
is a list containing:
est |
the ML estimates |
vcov |
the variance-covariance vector of the ML estimates. |
score |
a matrix containing the cluster-specific contributions to the ML score equations. |
If left truncation is present, it is assumed that it is strong left truncation. This means that, even if the truncation time may be subject-specific, the whole cluster is unobserved if at least one subject in the cluster dies before his/her truncation time. If all subjects in the cluster survive beyond their subject-specific truncation times, then the whole cluster is observed (Van den Berg and Drepper, 2016).
Arvid Sjolander and Elisabeth Dahlqwist.
Dahlqwist E., Pawitan Y., Sjolander A. (2019). Regression standardization and attributable fraction estimation with between-within frailty models for clustered survival data. Statistical Methods in Medical Research 28(2), 462-485.
Van den Berg G.J., Drepper B. (2016). Inference for shared frailty survival models with left-truncated data. Econometric Reviews, 35(6), 1075-1098.
## Not run: require(survival) #simulate data n <- 1000 m <- 3 alpha <- 1.5 eta <- 1 phi <- 0.5 beta <- 1 id <- rep(1:n, each=m) U <- rep(rgamma(n, shape=1/phi,scale=phi), each=m) X <- rnorm(n*m) #reparametrize scale as in rweibull function weibull.scale <- alpha/(U*exp(beta*X))^(1/eta) T <- rweibull(n*m, shape=eta, scale=weibull.scale) #right censoring C <- runif(n*m, 0,10) D <- as.numeric(T<C) T <- pmin(T, C) #strong left-truncation L <- runif(n*m, 0, 2) incl <- T>L incl <- ave(x=incl, id, FUN=sum)==m dd <- data.frame(L, T, D, X, id) dd <- dd[incl, ] fit <- parfrailty(formula=Surv(L, T, D)~X, data=dd, clusterid="id") print(summary(fit)) ## End(Not run)
## Not run: require(survival) #simulate data n <- 1000 m <- 3 alpha <- 1.5 eta <- 1 phi <- 0.5 beta <- 1 id <- rep(1:n, each=m) U <- rep(rgamma(n, shape=1/phi,scale=phi), each=m) X <- rnorm(n*m) #reparametrize scale as in rweibull function weibull.scale <- alpha/(U*exp(beta*X))^(1/eta) T <- rweibull(n*m, shape=eta, scale=weibull.scale) #right censoring C <- runif(n*m, 0,10) D <- as.numeric(T<C) T <- pmin(T, C) #strong left-truncation L <- runif(n*m, 0, 2) incl <- T>L incl <- ave(x=incl, id, FUN=sum)==m dd <- data.frame(L, T, D, X, id) dd <- dd[incl, ] fit <- parfrailty(formula=Surv(L, T, D)~X, data=dd, clusterid="id") print(summary(fit)) ## End(Not run)
This is a plot
method for class "stdCoxph"
.
## S3 method for class 'stdCoxph' plot(x, plot.CI = TRUE, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, legendpos="bottomleft", ...)
## S3 method for class 'stdCoxph' plot(x, plot.CI = TRUE, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, legendpos="bottomleft", ...)
x |
an object of class |
plot.CI |
logical, indicating whether confidence intervals should be added to the plot. |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
legendpos |
position of the legend; see help for |
... |
further arguments passed on to plot.default. |
Arvid Sjolander
##See documentation for stdCoxph
##See documentation for stdCoxph
This is a plot
method for class "stdGee"
.
## S3 method for class 'stdGee' plot(x, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
## S3 method for class 'stdGee' plot(x, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
x |
an object of class |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
... |
further arguments passed on to plot.default. |
Arvid Sjolander
##See documentation for stdGee
##See documentation for stdGee
This is a plot
method for class "stdGlm"
.
## S3 method for class 'stdGlm' plot(x, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
## S3 method for class 'stdGlm' plot(x, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
x |
an object of class |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
... |
further arguments passed on to plot.default. |
Arvid Sjolander
##See documentation for stdGlm
##See documentation for stdGlm
This is a plot
method for class "stdParfrailty"
.
## S3 method for class 'stdParfrailty' plot(x, plot.CI = TRUE, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, legendpos="bottomleft", ...)
## S3 method for class 'stdParfrailty' plot(x, plot.CI = TRUE, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, legendpos="bottomleft", ...)
x |
an object of class |
plot.CI |
logical, indicating whether confidence intervals should be added to the plot. |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
legendpos |
position of the legend; see help for |
... |
further arguments passed on to plot.default. |
Arvid Sjolander
##See documentation for stdParfrailty
##See documentation for stdParfrailty
This is a print
method for class "summary.parfrailty"
.
## S3 method for class 'summary.parfrailty' print(x, digits = max(3L, getOption("digits") - 3L), ...)
## S3 method for class 'summary.parfrailty' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
an object of class |
digits |
the number of significant digits to use when printing. |
... |
not used. |
Arvid Sjolander and Elisabeth Dahlqwist
##See documentation for frailty
##See documentation for frailty
This is a print
method for class "summary.stdCoxph"
.
## S3 method for class 'summary.stdCoxph' print(x, ...)
## S3 method for class 'summary.stdCoxph' print(x, ...)
x |
an object of class |
... |
not used. |
Arvid Sjolander
##See documentation for stdCoxph
##See documentation for stdCoxph
This is a print
method for class "summary.stdGee"
.
## S3 method for class 'summary.stdGee' print(x, ...)
## S3 method for class 'summary.stdGee' print(x, ...)
x |
an object of class |
... |
not used. |
Arvid Sjolander
##See documentation for stdGee
##See documentation for stdGee
This is a print
method for class "summary.stdGlm"
.
## S3 method for class 'summary.stdGlm' print(x, ...)
## S3 method for class 'summary.stdGlm' print(x, ...)
x |
an object of class |
... |
not used. |
Arvid Sjolander
##See documentation for stdGlm
##See documentation for stdGlm
This is a print
method for class "summary.stdParfrailty"
.
## S3 method for class 'summary.stdParfrailty' print(x, ...)
## S3 method for class 'summary.stdParfrailty' print(x, ...)
x |
an object of class |
... |
not used. |
Arvid Sjolander
##See documentation for stdParfrailty
##See documentation for stdParfrailty
stdCoxph
performs regression standardization in Cox proportional hazards models,
at specified values of the exposure, over the sample covariate distribution.
Let ,
, and
be the survival outcome, the exposure, and a
vector of covariates, respectively.
stdCoxph
uses a fitted Cox
proportional hazards model to estimate the standardized
survival function , where
is a specific value of
,
is a specific value of
, and the expectation is over the marginal
distribution of
.
stdCoxph(fit, data, X, x, t, clusterid, subsetnew)
stdCoxph(fit, data, X, x, t, clusterid, subsetnew)
fit |
an object of class |
data |
a data frame containing the variables in the model. This should be the same
data frame as was used to fit the model in |
X |
a string containing the name of the exposure variable |
x |
an optional vector containing the specific values of |
t |
an optional vector containing the specific values of |
clusterid |
an optional string containing the name of a cluster identification variable when data are clustered. |
subsetnew |
an optional logical statement specifying a subset of observations to be used in the standardization. This set is assumed to be a subset of the subset (if any) that was used to fit the regression model. |
stdCoxph
assumes that a Cox proportional hazards model
has been fitted. Breslow's
estimator of the cumulative baseline hazard
is used together with the partial likelihood estimate of
to obtain
estimates of the survival function
:
For each in the
t
argument and for each in the
x
argument,
these estimates are averaged across all subjects (i.e. all observed values of )
to produce estimates
where is the value of
for subject
,
.
The variance for
is obtained by the sandwich formula.
An object of class "stdCoxph"
is a list containing
call |
the matched call. |
input |
|
est |
a matrix with |
vcov |
a list with |
Standardized survival functions are sometimes referred to as (direct) adjusted survival functions in the literature.
stdCoxph
does not currently handle time-varying exposures or covariates.
stdCoxph
internally loops over all values in the t
argument. Therefore,
the function will usually be considerably faster if length(t)
is small.
The variance calculation performed by stdCoxph
does not condition on
the observed covariates . To see how this matters,
note that
The usual parameter in a Cox proportional hazards model does not
depend on
. Thus,
is independent of
as well (since
), so that the
term
in the corresponding variance
decomposition for
becomes equal to 0. However,
depends on
through the average over the sample
distribution for
, and thus the term
is not 0, unless one conditions on
. The variance calculation by
Gail and Byar (1986) ignores this term, and thus effectively conditions on
.
Arvid Sjolander
Chang I.M., Gelman G., Pagano M. (1982). Corrected group prognostic curves and summary statistics. Journal of Chronic Diseases 35, 669-674.
Gail M.H. and Byar D.P. (1986). Variance calculations for direct adjusted survival curves, with applications to testing for no treatment effect. Biometrical Journal 28(5), 587-599.
Makuch R.W. (1982). Adjusted survival curve estimation using covariates. Journal of Chronic Diseases 35, 437-443.
Sjolander A. (2016). Regression standardization with the R-package stdReg. European Journal of Epidemiology 31(6), 563-574.
Sjolander A. (2016). Estimation of causal effect measures with the R-package stdReg. European Journal of Epidemiology 33(9), 847-858.
require(survival) n <- 1000 Z <- rnorm(n) X <- rnorm(n, mean=Z) T <- rexp(n, rate=exp(X+Z+X*Z)) #survival time C <- rexp(n, rate=exp(X+Z+X*Z)) #censoring time U <- pmin(T, C) #time at risk D <- as.numeric(T < C) #event indicator dd <- data.frame(Z, X, U, D) fit <- coxph(formula=Surv(U, D)~X+Z+X*Z, data=dd, method="breslow") fit.std <- stdCoxph(fit=fit, data=dd, X="X", x=seq(-1,1,0.5), t=1:5) print(summary(fit.std, t=3)) plot(fit.std)
require(survival) n <- 1000 Z <- rnorm(n) X <- rnorm(n, mean=Z) T <- rexp(n, rate=exp(X+Z+X*Z)) #survival time C <- rexp(n, rate=exp(X+Z+X*Z)) #censoring time U <- pmin(T, C) #time at risk D <- as.numeric(T < C) #event indicator dd <- data.frame(Z, X, U, D) fit <- coxph(formula=Surv(U, D)~X+Z+X*Z, data=dd, method="breslow") fit.std <- stdCoxph(fit=fit, data=dd, X="X", x=seq(-1,1,0.5), t=1:5) print(summary(fit.std, t=3)) plot(fit.std)
stdGee
performs regression standardization in linear and log-linear
fixed effects models, at specified values of the exposure, over the sample
covariate distribution. Let ,
, and
be the outcome,
the exposure, and a vector of covariates, respectively. It is assumed that data
are clustered with a cluster indicator
.
stdGee
uses
fitted fixed effects model, with cluster-specific intercept
(see
details
), to estimate the standardized mean
, where
is a specific value of
,
and the outer expectation is over the marginal distribution of
.
stdGee(fit, data, X, x, clusterid, subsetnew)
stdGee(fit, data, X, x, clusterid, subsetnew)
fit |
an object of class |
data |
a data frame containing the variables in the model. This should be the same
data frame as was used to fit the model in |
X |
a string containing the name of the exposure variable |
x |
an optional vector containing the specific values of |
clusterid |
an mandatory string containing the name of a cluster identification variable. Must be identical to the clusterid variable used in the gee call. |
subsetnew |
an optional logical statement specifying a subset of observations to be used in the standardization. This set is assumed to be a subset of the subset (if any) that was used to fit the regression model. |
stdGee
assumes that a fixed effects model
has been fitted. The link function is assumed to be the identity link
or the log link. The conditional generalized estimating equation (CGGE)
estimate of
is used to obtain estimates of the cluster-specific
means:
where
if is the identity link, and
if is the log link, and
is the value of
for subject
in cluster
,
,
. The CGEE estimate of
and the estimate of
are used to estimate the mean
:
For each in the
x
argument, these estimates are averaged across
all subjects (i.e. all observed values of and all estimated values of
) to produce estimates
where . The variance for
is
obtained by the sandwich formula.
An object of class "stdGee"
is a list containing
call |
the matched call. |
input |
|
est |
a vector with length equal to |
vcov |
a square matrix with |
The variance calculation performed by stdGee
does not condition on
the observed covariates . To see how this
matters, note that
The usual parameter in a generalized linear model does not depend
on
. Thus,
is
independent of
as well (since
),
so that the term
in the corresponding
variance decomposition for
becomes equal to 0. However,
depends on
through the average over the sample
distribution for
, and thus the term
is not 0, unless one conditions on
.
Arvid Sjolander.
Goetgeluk S. and Vansteelandt S. (2008). Conditional generalized estimating equations for the analysis of clustered and longitudinal data. Biometrics 64(3), 772-780.
Martin R.S. (2017). Estimation of average marginal effects in multiplicative unobserved effects panel models. Economics Letters 160, 16-19.
Sjolander A. (2019). Estimation of marginal causal effects in the presence of confounding by cluster. Biostatistics doi: 10.1093/biostatistics/kxz054
require(drgee) n <- 1000 ni <- 2 id <- rep(1:n, each=ni) ai <- rep(rnorm(n), each=ni) Z <- rnorm(n*ni) X <- rnorm(n*ni, mean=ai+Z) Y <- rnorm(n*ni, mean=ai+X+Z+0.1*X^2) dd <- data.frame(id, Z, X, Y) fit <- gee(formula=Y~X+Z+I(X^2), data=dd, clusterid="id", link="identity", cond=TRUE) fit.std <- stdGee(fit=fit, data=dd, X="X", x=seq(-3,3,0.5), clusterid="id") print(summary(fit.std, contrast="difference", reference=2)) plot(fit.std)
require(drgee) n <- 1000 ni <- 2 id <- rep(1:n, each=ni) ai <- rep(rnorm(n), each=ni) Z <- rnorm(n*ni) X <- rnorm(n*ni, mean=ai+Z) Y <- rnorm(n*ni, mean=ai+X+Z+0.1*X^2) dd <- data.frame(id, Z, X, Y) fit <- gee(formula=Y~X+Z+I(X^2), data=dd, clusterid="id", link="identity", cond=TRUE) fit.std <- stdGee(fit=fit, data=dd, X="X", x=seq(-3,3,0.5), clusterid="id") print(summary(fit.std, contrast="difference", reference=2)) plot(fit.std)
stdGlm
performs regression standardization in generalized linear models,
at specified values of the exposure, over the sample covariate distribution.
Let ,
, and
be the outcome, the exposure, and a
vector of covariates, respectively.
stdGlm
uses a fitted generalized linear
model to estimate the standardized
mean , where
is a specific value of
,
and the outer expectation is over the marginal distribution of
.
stdGlm(fit, data, X, x, clusterid, case.control = FALSE, subsetnew)
stdGlm(fit, data, X, x, clusterid, case.control = FALSE, subsetnew)
fit |
an object of class |
data |
a data frame containing the variables in the model. This should be the same
data frame as was used to fit the model in |
X |
a string containing the name of the exposure variable |
x |
an optional vector containing the specific values of |
clusterid |
an optional string containing the name of a cluster identification variable when data are clustered. |
case.control |
logical. Do data come from a case-control study? Defaults to FALSE. |
subsetnew |
an optional logical statement specifying a subset of observations to be used in the standardization. This set is assumed to be a subset of the subset (if any) that was used to fit the regression model. |
stdGlm
assumes that a generalized linear model
has been fitted. The maximum likelihood estimate of is used to obtain
estimates of the mean
:
For each in the
x
argument, these estimates are averaged across
all subjects (i.e. all observed values of ) to produce estimates
where is the value of
for subject
,
.
The variance for
is obtained by the sandwich formula.
An object of class "stdGlm"
is a list containing
call |
the matched call. |
input |
|
est |
a vector with length equal to |
vcov |
a square matrix with |
The variance calculation performed by stdGlm
does not condition on
the observed covariates . To see how this matters, note that
The usual parameter in a generalized linear model does not depend
on
. Thus,
is
independent of
as well (since
), so that the
term
in the corresponding variance decomposition
for
becomes equal to 0. However,
depends
on
through the average over the sample distribution for
,
and thus the term
is not 0, unless one
conditions on
.
Arvid Sjolander.
Rothman K.J., Greenland S., Lash T.L. (2008). Modern Epidemiology, 3rd edition. Lippincott, Williams \& Wilkins.
Sjolander A. (2016). Regression standardization with the R-package stdReg. European Journal of Epidemiology 31(6), 563-574.
Sjolander A. (2016). Estimation of causal effect measures with the R-package stdReg. European Journal of Epidemiology 33(9), 847-858.
##Example 1: continuous outcome n <- 1000 Z <- rnorm(n) X <- rnorm(n, mean=Z) Y <- rnorm(n, mean=X+Z+0.1*X^2) dd <- data.frame(Z, X, Y) fit <- glm(formula=Y~X+Z+I(X^2), data=dd) fit.std <- stdGlm(fit=fit, data=dd, X="X", x=seq(-3,3,0.5)) print(summary(fit.std)) plot(fit.std) ##Example 2: binary outcome n <- 1000 Z <- rnorm(n) X <- rnorm(n, mean=Z) Y <- rbinom(n, 1, prob=(1+exp(X+Z))^(-1)) dd <- data.frame(Z, X, Y) fit <- glm(formula=Y~X+Z+X*Z, family="binomial", data=dd) fit.std <- stdGlm(fit=fit, data=dd, X="X", x=seq(-3,3,0.5)) print(summary(fit.std)) plot(fit.std)
##Example 1: continuous outcome n <- 1000 Z <- rnorm(n) X <- rnorm(n, mean=Z) Y <- rnorm(n, mean=X+Z+0.1*X^2) dd <- data.frame(Z, X, Y) fit <- glm(formula=Y~X+Z+I(X^2), data=dd) fit.std <- stdGlm(fit=fit, data=dd, X="X", x=seq(-3,3,0.5)) print(summary(fit.std)) plot(fit.std) ##Example 2: binary outcome n <- 1000 Z <- rnorm(n) X <- rnorm(n, mean=Z) Y <- rbinom(n, 1, prob=(1+exp(X+Z))^(-1)) dd <- data.frame(Z, X, Y) fit <- glm(formula=Y~X+Z+X*Z, family="binomial", data=dd) fit.std <- stdGlm(fit=fit, data=dd, X="X", x=seq(-3,3,0.5)) print(summary(fit.std)) plot(fit.std)
stdParfrailty
performs regression standardization in shared frailty gamma-Weibull models,
at specified values of the exposure, over the sample covariate distribution.
Let ,
, and
be the survival outcome, the exposure, and a
vector of covariates, respectively.
stdParfrailty
uses a fitted Cox
proportional hazards model to estimate the standardized
survival function , where
is a specific value of
,
is a specific value of
, and the expectation is over the marginal
distribution of
.
stdParfrailty(fit, data, X, x, t, clusterid, subsetnew)
stdParfrailty(fit, data, X, x, t, clusterid, subsetnew)
fit |
an object of class |
data |
a data frame containing the variables in the model. This should be the same
data frame as was used to fit the model in |
X |
a string containing the name of the exposure variable |
x |
an optional vector containing the specific values of |
t |
an optional vector containing the specific values of |
clusterid |
a string containing the name of the cluster identification variable. |
subsetnew |
an optional logical statement specifying a subset of observations to be used in the standardization. This set is assumed to be a subset of the subset (if any) that was used to fit the regression model. |
stdParfrailty
assumes that a shared frailty gamma-Weibull model
has been fitted, with parametrization as descibed in the help section for parfrailty
.
Integrating out the gamma frailty gives the survival function
where is the cumulative baseline hazard
The ML estimates of are used to obtain
estimates of the survival function
:
For each in the
t
argument and for each in the
x
argument,
these estimates are averaged across all subjects (i.e. all observed values of )
to produce estimates
The variance for is obtained by the sandwich formula.
An object of class "stdParfrailty"
is a list containing
call |
the matched call. |
input |
|
est |
a matrix with |
vcov |
a list with |
Standardized survival functions are sometimes referred to as (direct) adjusted survival functions in the literature.
stdParfrailty
does not currently handle time-varying exposures or covariates.
stdParfrailty
internally loops over all values in the t
argument. Therefore,
the function will usually be considerably faster if length(t)
is small.
The variance calculation performed by stdParfrailty
does not condition on
the observed covariates . To see how this matters, note that
The usual parameter in a Cox proportional hazards model does not depend
on
. Thus,
is
independent of
as well (since
), so that the
term
in the corresponding variance decomposition
for
becomes equal to 0. However,
depends
on
through the average over the sample distribution for
,
and thus the term
is not 0, unless one
conditions on
. The variance calculation by Gail and Byar (1986) ignores this term,
and thus effectively conditions on
.
Arvid Sjolander
Chang I.M., Gelman G., Pagano M. (1982). Corrected group prognostic curves and summary statistics. Journal of Chronic Diseases 35, 669-674.
Dahlqwist E., Pawitan Y., Sjolander A. (2019). Regression standardization and attributable fraction estimation with between-within frailty models for clustered survival data. Statistical Methods in Medical Research 28(2), 462-485.
Gail M.H. and Byar D.P. (1986). Variance calculations for direct adjusted survival curves, with applications to testing for no treatement effect. Biometrical Journal 28(5), 587-599.
Makuch R.W. (1982). Adjusted survival curve estimation using covariates. Journal of Chronic Diseases 35, 437-443.
## Not run: require(survival) #simulate data n <- 1000 m <- 3 alpha <- 1.5 eta <- 1 phi <- 0.5 beta <- 1 id <- rep(1:n, each=m) U <- rep(rgamma(n, shape=1/phi, scale=phi), each=m) X <- rnorm(n*m) #reparametrize scale as in rweibull function weibull.scale <- alpha/(U*exp(beta*X))^(1/eta) T <- rweibull(n*m, shape=eta, scale=weibull.scale) #right censoring C <- runif(n*m, 0, 10) D <- as.numeric(T<C) T <- pmin(T, C) #strong left-truncation L <- runif(n*m, 0, 2) incl <- T>L incl <- ave(x=incl, id, FUN=sum)==m dd <- data.frame(L, T, D, X, id) dd <- dd[incl, ] fit <- parfrailty(formula=Surv(L, T, D)~X, data=dd, clusterid="id") fit.std <- stdParfrailty(fit=fit, data=dd, X="X", x=seq(-1,1,0.5), t=1:5, clusterid="id") print(summary(fit.std, t=3)) plot(fit.std) ## End(Not run)
## Not run: require(survival) #simulate data n <- 1000 m <- 3 alpha <- 1.5 eta <- 1 phi <- 0.5 beta <- 1 id <- rep(1:n, each=m) U <- rep(rgamma(n, shape=1/phi, scale=phi), each=m) X <- rnorm(n*m) #reparametrize scale as in rweibull function weibull.scale <- alpha/(U*exp(beta*X))^(1/eta) T <- rweibull(n*m, shape=eta, scale=weibull.scale) #right censoring C <- runif(n*m, 0, 10) D <- as.numeric(T<C) T <- pmin(T, C) #strong left-truncation L <- runif(n*m, 0, 2) incl <- T>L incl <- ave(x=incl, id, FUN=sum)==m dd <- data.frame(L, T, D, X, id) dd <- dd[incl, ] fit <- parfrailty(formula=Surv(L, T, D)~X, data=dd, clusterid="id") fit.std <- stdParfrailty(fit=fit, data=dd, X="X", x=seq(-1,1,0.5), t=1:5, clusterid="id") print(summary(fit.std, t=3)) plot(fit.std) ## End(Not run)
This is a summary
method for class "parfrailty"
.
## S3 method for class 'parfrailty' summary(object, CI.type = "plain", CI.level = 0.95, digits=max(3L, getOption("digits") - 3L), ...)
## S3 method for class 'parfrailty' summary(object, CI.type = "plain", CI.level = 0.95, digits=max(3L, getOption("digits") - 3L), ...)
object |
an object of class |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, in decimal form. |
digits |
the number of significant digits to use when printing.. |
... |
not used. |
Arvid Sjolander and Elisabeth Dahlqwist.
##See documentation for frailty
##See documentation for frailty
This is a summary
method for class "stdCoxph"
.
## S3 method for class 'stdCoxph' summary(object, t, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
## S3 method for class 'stdCoxph' summary(object, t, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
object |
an object of class |
t |
numeric, indicating the times at which to summarize. It defaults to the specified
value(s) of the argument |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
... |
not used. |
Arvid Sjolander
##See documentation for stdCoxph
##See documentation for stdCoxph
This is a summary
method for class "stdGee"
.
## S3 method for class 'stdGee' summary(object, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
## S3 method for class 'stdGee' summary(object, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
object |
an object of class |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
... |
not used. |
Arvid Sjolander
##See documentation for stdGee
##See documentation for stdGee
This is a summary
method for class "stdGlm"
.
## S3 method for class 'stdGlm' summary(object, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
## S3 method for class 'stdGlm' summary(object, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
object |
an object of class |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
... |
not used. |
Arvid Sjolander
##See documentation for stdGlm
##See documentation for stdGlm
This is a summary
method for class "stdParfrailty"
.
## S3 method for class 'stdParfrailty' summary(object, t, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
## S3 method for class 'stdParfrailty' summary(object, t, CI.type = "plain", CI.level = 0.95, transform = NULL, contrast = NULL, reference = NULL, ...)
object |
an object of class |
t |
numeric, indicating the times at which to summarize. It defaults to the specified
value(s) of the argument |
CI.type |
string, indicating the type of confidence intervals. Either "plain", which gives untransformed intervals, or "log", which gives log-transformed intervals. |
CI.level |
desired coverage probability of confidence intervals, on decimal form. |
transform |
a string. If set to |
contrast |
a string. If set to |
reference |
must be specified if |
... |
not used. |
Arvid Sjolander
##See documentation for stdParfrailty
##See documentation for stdParfrailty