Gene_Mean_CenIPWE: A low-level function for the generic optimization step in...

Description Usage Arguments Examples

Description

This function supports the IPWE_mean_IndCen function. It does the genetic algorithm based method with inverse probability weighting for censored data. In the future, if more complicated applications/scenarios is sought after for mean optimality, users may create their own wrapper function based on Gene_Mean_CenIPWE.

Usage

1
2
Gene_Mean_CenIPWE(data_aug, ph, p_level, regimeClass, Domains = NULL,
  cluster = FALSE, s.tol = 1e-04, it.num = 8, pop.size = 3000)

Arguments

data_aug

a data.frame of the observed data after preprocessing. It should include be augmented with two new columns: ph for the enstimated propensity scores and ghat for the estimated conditional survival probabilities.

ph

propensity score estimates. For example, if the treatment is denoted by A, then ph should be P(A=1|X)

p_level

printing level

regimeClass

a formula indicating the form of treatment regimes

Domains

default is NULL. Otherwise, the object should be a nvars *2 matrix used as the space of parameters, which will be supplied to rgenoud::genoud.

cluster

default is FALSE. This can also be an object of the 'cluster' class returned by one of the makeCluster commands in the parallel package or a vector of machine names so rgenoud::genoud can setup the cluster automatically.

s.tol

tolerance level for the GA algorithm. This is input for parameter solution.tolerance in function rgenoud::genoud.

it.num

the maximum GA iteration number

pop.size

an integer with the default set to be 3000. This is roughly the number individuals for the first generation in the genetic algorithm (rgenoud::genoud).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
GenerateData <- function(n)
{
  x1 <- runif(n, min=-0.5,max=0.5)
  x2 <- runif(n, min=-0.5,max=0.5)
  error <- rnorm(n, sd= 1)
  ph <- rep(0.5,n)
  a <- rbinom(n = n, size = 1, prob=ph)
  c <- 1.5 +  + runif(n = n, min=0, max=2)
  cmplt_y <-  pmin(2+x1+x2 +  a*(1 - x1 - x2) +  (0.2 + a*(1+x1+x2)) * error, 4.4)
  censor_y <- pmin(cmplt_y, c)
  delta <- as.numeric(c > cmplt_y)
  return(data.frame(x1=x1,x2=x2,a=a, censor_y = censor_y, delta=delta))
}
n <- 100
data <- GenerateData(n)

# preprocessing
data_aug <- data
data_aug$ph <- rep(mean(data$a), n)
data_aug$deltaC <- 1 - data_aug$delta
library(survival)
survfit_all <- survfit(Surv(censor_y, event = deltaC)~1, data=data_aug)
survest <- stepfun(survfit_all$time, c(1, survfit_all$surv))
data_aug$ghat <- survest(data_aug$censor_y)

# estimate the mean-optimal treatment regime
meanopt_fit <- Gene_Mean_CenIPWE(data=data_aug, ph = data_aug$ph, p_level=1, regimeClass=a~x1*x2) 

QTOCen documentation built on June 4, 2019, 5:03 p.m.