Skip to content

question about estimated variance #45

@sgruber65

Description

@sgruber65

I ran the first example in the R package on CRAN (v1.1.1) 1000 times, and kept track of the estimates and variances returned each time. The empirical variance of each treatment-specific mean was (.0037, .0040), respectively, while the mean of the variance esimates was (0.0029, 0.0012), (elements [1,1] and [2,2] in the covariance matrix). The first one is maybe not off by too much, but the second one is so wrong that I'm wondering if there is a bug. Can you please look into this, and let me know what you find out? Thanks.

--Susan

set.seed(1234)
n <- 200
niter <- 1000
est <- matrix(NA, nrow = niter, ncol = 4)
colnames(est) <- c("est.01", "est.11", "var.11", "var.22")
for (i in 1:niter){
  trt <- rbinom(n, 1, 0.5)
  adjustVars <- data.frame(W1 = round(runif(n)), W2 = round(runif(n, 0, 2)))

  ftime <- round(1 + runif(n, 1, 4) - trt + adjustVars$W1 + adjustVars$W2)
  ftype <- round(runif(n, 0, 1))

  # Fit 1
  # fit a survtmle object with glm estimators for treatment, censoring, and
  # failure using the "mean" method
  fit1 <- survtmle(ftime = ftime, ftype = ftype,
                 trt = trt, adjustVars = adjustVars,
                 glm.trt = "W1 + W2",
                 glm.ftime = "trt + W1 + W2",
                 glm.ctime = "trt + W1 + W2",
                 method = "mean", t0 = 6)
  est[i,] <- c(fit1$est[,1], fit1$var[1,1], fit1$var[2,2])
}
colMeans(est)
apply(est[,1:2], 2, var)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions