I am using coxed R package to simulate survival data with covariates. I tried the example given in their package (show below)

simdata <- sim.survdata(N=1000, T=100, num.data.frames=2)
data <- simdata[[1]]$data

and found that the true coefficient values for the simulation is

simdata[[1]]$betas ## "true" coefficients

-0.218112255, 0.009066555, and -0.107173014, but the estimated values using coxph package

model <- coxph(Surv(y, failed) ~ X1 + X2 + X3, data=data)
model$coefficients ## model-estimated coefficients

are -0.24228669, -0.09744258, and -0.1241258. The corresponding standard errors are 0.06827, 0.06967, 0.06832

Even consider the standard error, the second estimated value is quite far away from their true values. I wonder anyone who has experience working on both the coxph and coxed R packages could give me a hint? Many thanks.

  • 3
    $\begingroup$ You won’t get it exactly right on every simulation, just on average (assuming your estimator is unbiased). This holds for all estimators, not just Cox. Run 10,000 simulations and plot a histogram for each coefficient and take their means. $\endgroup$
    – Jonathan
    Jul 4, 2021 at 7:09
  • 2
    $\begingroup$ Have a look at the standard errors and confidence intervals associated with the estimates. Are they in line with the true values? Or also very much off? $\endgroup$
    – Michael M
    Jul 4, 2021 at 7:31
  • $\begingroup$ Please edit the question to include the standard errors for the coefficient estimates. $\endgroup$
    – EdM
    Jul 5, 2021 at 14:04
  • $\begingroup$ I have added the S.E.s. $\endgroup$
    – Po Ning
    Jul 13, 2021 at 11:30

1 Answer 1


Although I don't have experience with coxed (and thus might be missing something specific to that package), the estimated coefficient values seem to be well within what one might expect in random sampling.

With Cox models it can be helpful to think about differences between coefficient values in terms of the number of standard errors the difference represents. That is, divide the difference between the "true" and "estimated" values by the standard error of the estimate. For the 3 coefficients estimated from your data sample, the absolute values of the differences are 0.35, 1.35, and 0.25 standard errors, respectively.

Yes, the second difference seems big at first sight. But remember that repeated random sampling will lead, 5% of the time, to a coefficient estimate being more than 1.96 standard errors away from the true value. (That's the 95% confidence interval for a normally distributed coefficient estimate.) Even your second difference is well within that. In about 18% of samples you should expect to do worse than 1.35 standard errors between your estimate and the "true" value, just by chance, based on the normal distribution.

That type of variability between "true" and "estimated" values is inherent in statistical analysis. To try to get a more intuitive feeling for what's going on, follow the suggestion from @Jonathan in a comment. Make a very large simulated data set to start, to draw from. Then do multiple Cox model fits on samples from that simulated data set. See how the estimated coefficient values vary from the "true" values among multiple samples of the same size. See how the distribution of coefficient estimates changes as you take progressively smaller or larger samples from the simulated data set. That might help you get a better feel for the type of random variability that's inevitable in this type of work.

  • $\begingroup$ Thank you for the detailed explanation. You are right. I just did a simulation - generating 1000 datasets - the average value of the estimated coefficients are close to their true values. Many thanks. $\endgroup$
    – Po Ning
    Jul 20, 2021 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.