Package 'CSTE'

Title: Covariate Specific Treatment Effect (CSTE) Curve
Description: A uniform statistical inferential tool in making individualized treatment decisions, which implements the methods of Ma et al. (2017)<DOI:10.1177/0962280214541724> and Guo et al. (2021)<DOI:10.1080/01621459.2020.1865167>. It uses a flexible semiparametric modeling strategy for heterogeneous treatment effect estimation in high-dimensional settings and can gave valid confidence bands. Based on it, one can find the subgroups of patients that benefit from each treatment, thereby making individualized treatment selection.
Authors: Peng Wu [aut], Wenjie Hu [aut, cre], Yuhao Deng [aut], Haoxiang Wang [aut], Xiaohua Zhou [aut]
Maintainer: Wenjie Hu <[email protected]>
License: GPL (>= 2)
Version: 3.0.0
Built: 2025-02-18 05:26:58 UTC
Source: https://github.com/cran/CSTE

Help Index


Estimate the CSTE curve for binary outcome.

Description

Estimate covariate-specific treatment effect (CSTE) curve. Input data contains covariates XX, treatment assignment ZZ and binary outcome YY. The working model is

logit(μ(X,Z))=g1(Xβ1)Z+g2(Xβ2),logit(\mu(X, Z)) = g_1(X\beta_1)Z + g_2(X\beta_2),

where μ(X,Z)=E(YX,Z)\mu(X, Z) = E(Y|X, Z). The model implies that CSTE(x)=g1(xβ1)CSTE(x) = g_1(x\beta_1).

Usage

cste_bin(
  x,
  y,
  z,
  beta_ini = NULL,
  lam = 0,
  nknots = 1,
  max.iter = 200,
  eps = 0.001
)

Arguments

x

samples of covariates which is a npn*p matrix.

y

samples of binary outcome which is a n1n*1 vector.

z

samples of treatment indicator which is a n1n*1 vector.

beta_ini

initial values for (β1,β2)(\beta_1', \beta_2')', default value is NULL.

lam

value of the lasso penalty parameter λ\lambda for β1\beta_1 and β2\beta_2, default value is 0.

nknots

number of knots for the B-spline for estimating g1g_1 and g2g_2.

max.iter

maximum iteration for the algorithm.

eps

numeric scalar \geq 0, the tolerance for the estimation of β1\beta_1 and β2\beta_2.

Value

A S3 class of cste, which includes:

  • beta1: estimate of β1\beta_1.

  • beta2: estimate of β2\beta_2.

  • B1: the B-spline basis for estimating g1g_1.

  • B2: the B-spline basis for estimating g2g_2.

  • delta1: the coefficient of B-spline for estimating g1g_1.

  • delta2: the coefficient for B-spline for estimating g2g_2.

  • iter: number of iteration.

  • g1: the estimate of g1(Xβ1)g_1(X\beta_1).

  • g2: the estimate of g2(Xβ2)g_2(X\beta_2).

References

Guo W., Zhou X. and Ma S. (2021). Estimation of Optimal Individualized Treatment Rules Using a Covariate-Specific Treatment Effect Curve with High-dimensional Covariates, Journal of the American Statistical Association, 116(533), 309-321

See Also

cste_bin_SCB, predict_cste_bin, select_cste_bin

Examples

## Quick example for the cste

library(mvtnorm)
library(sigmoid)

# --------  Example 1: p = 20 ---------  #  
## generate data 
n <- 2000
p <- 20
set.seed(100)

# generate X
sigma <- outer(1:p, 1:p, function(i, j){ 2^(-abs(i-j)) } )
X <- rmvnorm(n, mean = rep(0,p), sigma = sigma)
X <- relu(X + 2) - 2
X <- 2 - relu(2 - X)

# generate Z
Z <- rbinom(n, 1, 0.5)

# generate Y
beta1 <- rep(0, p)
beta1[1:3] <- rep(1/sqrt(3), 3)
beta2 <- rep(0, p)
beta2[1:2] <- c(1, -2)/sqrt(5)
mu1 <- X %*% beta1
mu2 <- X %*% beta2
g1 <- mu1*(1 - mu1)
g2 <- exp(mu2)      
prob <- sigmoid(g1*Z + g2)
Y <- rbinom(n, 1, prob)

## estimate the CSTE curve
fit <- cste_bin(X, Y, Z)

## plot 
plot(mu1, g1, cex = 0.5, xlim = c(-2,2), ylim = c(-8, 3), 
     xlab = expression(X*beta), ylab = expression(g1(X*beta)))
     ord <- order(mu1)
     points(mu1[ord], fit$g1[ord], col = 'blue', cex = 0.5)
     
## compute 95% simultaneous confidence band (SCB)
res <- cste_bin_SCB(X, fit, alpha = 0.05)

## plot 
plot(res$or_x, res$fit_x, col = 'red', 
     type="l", lwd=2, lty = 3, ylim = c(-10,8),
     ylab=expression(g1(X*beta)), xlab = expression(X*beta), 
     main="Confidence Band")
lines(res$or_x, res$lower_bound, lwd=2.5, col = 'purple', lty=2)
lines(res$or_x, res$upper_bound, lwd=2.5, col = 'purple', lty=2)
abline(h=0, cex = 0.2, lty = 2)
legend("topleft", legend=c("Estimates", "SCB"), 
        lwd=c(2, 2.5), lty=c(3,2), col=c('red', 'purple'))
        
        
# --------  Example 2: p = 1 ---------  #  

## generate data 
set.seed(15)
p <- 1
n <- 2000
X <- runif(n)
Z <- rbinom(n, 1, 0.5)
g1 <- 2 * sin(5*X) 
g2 <- exp(X-3) * 2
prob <- sigmoid( Z*g1 + g2)
Y <- rbinom(n, 1, prob)

## estimate the CSTE curve
fit <- cste_bin(X, Y, Z)  

## simultaneous confidence band (SCB)
X <- as.matrix(X)
res <- cste_bin_SCB(X, fit)  

## plot 
plot(res$or_x, res$fit_x, col = 'red', type="l", lwd=2, 
     lty = 3, xlim = c(0, 1), ylim = c(-4, 4), 
     ylab=expression(g1(X)), xlab = expression(X), 
     main="Confidence Band")
lines(res$or_x, res$lower_bound, lwd=2.5, col = 'purple', lty=2)
lines(res$or_x, res$upper_bound, lwd=2.5, col = 'purple', lty=2)
abline(h=0, cex = 0.2)
lines(X[order(X)], g1[order(X)], col = 'blue', lwd = 1.5)
legend("topright", legend=c("Estimates", "SCB",'True CSTE Curve'), 
lwd=c(2, 2.5, 1.5), lty=c(3,2,1), col=c('red', 'purple','blue'))

Calculate simultaneous confidence bands of CSTE curve for binary outcome.

Description

This function calculates simultaneous confidence bands of CSTE curve for binary outcome.

Usage

cste_bin_SCB(x, fit, h = NULL, alpha = 0.05)

Arguments

x

samples of predictor, which is a mpm*p matrix.

fit

a S3 class of cste.

h

kernel bandwidth.

alpha

the simultaneous confidence bands are of 1α1-\alpha confidence level.

Value

A list which includes:

  • or_x: the ordered value of Xβ1X\beta_1.

  • fit_x: the fitted value of CSTE curve corresponding to or_x.

  • lower_bound: the lower bound of CSTE's simultaneous confidence band.

  • upper_bound: the upper bound of CSTE's simultaneous confidence band.

References

Guo W., Zhou X. and Ma S. (2021). Estimation of Optimal Individualized Treatment Rules Using a Covariate-Specific Treatment Effect Curve with High-dimensional Covariates, Journal of the American Statistical Association, 116(533), 309-321

See Also

cste_bin


Estimate the CSTE curve for time to event outcome with right censoring.

Description

Estimate the CSTE curve for time to event outcome with right censoring. The working model is

λ(tX,Z)=λ0(t)exp(βT(X)Z+g(X)),\lambda(t| X, Z) = \lambda_0(t) \exp(\beta^T(X)Z + g(X)),

which implies that CSTE(x)=β(x)CSTE(x) = \beta(x).

Usage

cste_surv(x, y, z, s, h)

Arguments

x

samples of biomarker (or covariate) which is a n1n*1 vector and should be scaled between 0 and 1.

y

samples of time to event which is a n1n*1 vector.

z

samples of treatment indicator which is a nKn*K matrix.

s

samples of censoring indicator which is a n1n*1 vector.

h

kernel bandwidth.

Value

A nKn*K matrix, estimation of β(x)\beta(x).

References

Ma Y. and Zhou X. (2017). Treatment selection in a randomized clinical trial via covariate-specific treatment effect curves, Statistical Methods in Medical Research, 26(1), 124-141.

See Also

cste_surv_SCB


Calculate simultaneous confidence bands (SCB) of CSTE curve for time to event outcome with right censoring.

Description

This function calculates simultaneous confidence bands of CSTE curve for time to event outcome with right censoring.

Usage

cste_surv_SCB(l, x, y, z, s, h, m, alpha = 0.05)

Arguments

l

contraction vector with dimension KK.

x

samples of biomarker (or covariate) which is a n1n*1 vector and should be scaled between 0 and 1.

y

samples of time to event which is a n1n*1 vector.

z

samples of treatment indicator which is a nKn*K matrix.

s

samples of censoring indicator which is a n1n*1 vector.

h

kernel bandwidth.

m

number of turns of resampling.

alpha

the (1α)(1-\alpha)-confidence level of SCB.

Value

A n3n*3 matrix, estimation of lTβ(x)l^T \beta(x) and its simultaneous confidence bands.

References

Ma Y. and Zhou X. (2017). Treatment selection in a randomized clinical trial via covariate-specific treatment effect curves, Statistical Methods in Medical Research, 26(1), 124-141.

See Also

cste_surv


Solve the penalized logistic regression.

Description

Solve the penalized logistic regression.

Usage

penC(x, y, off, beta, lam, pen)

Arguments

x

samples of covariates which is a npn*p matrix.

y

samples of binary outcome which is a n1n*1 vector.

off

offset in logistic regression.

beta

initial estimates.

lam

value of the lasso penalty parameter λ\lambda for β1\beta_1 and β2\beta_2.

pen

1: MCP estimator; 2: SCAD estimator.

Value

A numeric vector, estimate of beta


Predict the CSTE curve of new data for binary outcome.

Description

Predict the CSTE curve of new data for binary outcome.

Usage

predict_cste_bin(obj, newx)

Arguments

obj

a S3 class of cste.

newx

samples of covariates which is a mpm*p matrix.

Value

A S3 class of cste which includes

  • g1: predicted g1(Xβ1)g_1(X\beta_1).

  • g2: predicted g2(Xβ2)g_2(X\beta_2).

  • B1: the B-spline basis for estimating g1g_1.

  • B2: the B-spline basis for estimating g2g_2.

References

Guo W., Zhou X. and Ma S. (2021). Estimation of Optimal Individualized Treatment Rules Using a Covariate-Specific Treatment Effect Curve with High-dimensional Covariates, Journal of the American Statistical Association, 116(533), 309-321

See Also

cste_bin


Select the optimal tuning parameters in CSTE estimation for binary outcome.

Description

select lasso penalty parameter λ\lambda for β1\beta_1 and β2\beta_2 in CSTE estimation.

Usage

select_cste_bin(
  x,
  y,
  z,
  lam_seq,
  beta_ini = NULL,
  nknots = 1,
  max.iter = 2000,
  eps = 0.001
)

Arguments

x

samples of covariates which is a npn*p matrix.

y

samples of binary outcome which is a n1n*1 vector.

z

samples of treatment indicator which is a n1n*1 vector.

lam_seq

a sequence for the choice of λ\lambda.

beta_ini

initial values for (β1,β2)(\beta_1', \beta_2')', default value is NULL.

nknots

number of knots for the B-spline for estimating g1g_1 and g2g_2.

max.iter

maximum iteration for the algorithm.

eps

numeric scalar \geq 0, the tolerance for the estimation of β1\beta_1 and β2\beta_2.

Value

A list which includes

  • optimal: optimal cste within the given the sequence of λ\lambda.

  • bic: BIC for the sequence of λ\lambda.

  • lam_seq: the sequence of λ\lambda that is used.

References

Guo W., Zhou X. and Ma S. (2021). Estimation of Optimal Individualized Treatment Rules Using a Covariate-Specific Treatment Effect Curve with High-dimensional Covariates, Journal of the American Statistical Association, 116(533), 309-321

See Also

cste_bin