diff --git a/R/Trial.R b/R/Trial.R index 6d4cb07..b49fc33 100644 --- a/R/Trial.R +++ b/R/Trial.R @@ -819,7 +819,7 @@ trial_simulate <- function(self, n, .niter, ...) { } xt <- lapply(xt, data.table) if (count == 0) nsim <- n * length(xt) - for (i in seq_len(length(xt))) { + for (i in seq_along(xt)) { ## Append subject id and period variable xt[[i]][, `:=`(id = ids, num = i - 1)] } diff --git a/R/outcome_models.R b/R/outcome_models.R index 07a546c..04133be 100644 --- a/R/outcome_models.R +++ b/R/outcome_models.R @@ -367,12 +367,15 @@ outcome_phreg <- function(data, timemod <- proc_phreg(model) model <- timemod$model if (is.null(cens.model)) { - if (is.null(model)) stop( + if (is.null(model)) { + stop( "Need 'phreg' object (argument 'model') or specify parametric model" - ) - fcens <- with(model, Surv(time, !status) ~ 1) - cens.model <- mets::phreg(fcens, data = model.frame(model)) - cens.lp <- ~fcens + ) + } + fcens <- Surv(time, !status) ~ 1 + newd <- with(model, data.frame(time, status)) + cens.model <- mets::phreg(fcens, data = newd) + cens.lp <- fcens } censmod <- proc_phreg(cens.model) cens.model <- censmod$model