Skip to content

Commit 863ebf7

Browse files
committed
fix(outcome_phreg): time,status variables must be in the data.frame and not only in env.
1 parent 54715ec commit 863ebf7

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

R/outcome_models.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,15 @@ outcome_phreg <- function(data,
367367
timemod <- proc_phreg(model)
368368
model <- timemod$model
369369
if (is.null(cens.model)) {
370-
if (is.null(model)) stop(
370+
if (is.null(model)) {
371+
stop(
371372
"Need 'phreg' object (argument 'model') or specify parametric model"
372-
)
373-
fcens <- with(model, Surv(time, !status) ~ 1)
374-
cens.model <- mets::phreg(fcens, data = model.frame(model))
375-
cens.lp <- ~fcens
373+
)
374+
}
375+
fcens <- Surv(time, !status) ~ 1
376+
newd <- with(model, data.frame(time, status))
377+
cens.model <- mets::phreg(fcens, data = newd)
378+
cens.lp <- fcens
376379
}
377380
censmod <- proc_phreg(cens.model)
378381
cens.model <- censmod$model

0 commit comments

Comments
 (0)