Skip to content

Feature request: survFit() with weights #121

Description

@hfrick

Could we get survFit() to accept a weighted fit? The "yet" in the error message suggests you might be open to this? 🙏

Context: we would like to support case weights for mboost in the tidymodels framework but if only model fitting but not prediction (what we use survFit() for), we get surprised users like in tidymodels/censored#363. I think that's a fair assumption from that user so I've disabled case weights for mboost for the moment but I'd love to bring it back!

library(mboost)
#> Warning: package 'mboost' was built under R version 4.6.1
#> Loading required package: parallel
#> Loading required package: stabs
library(survival)
#> Warning: package 'survival' was built under R version 4.6.1

lung2 <- na.omit(lung[, c("time", "status", "age", "ph.ecog")])
set.seed(1)
wts <- runif(nrow(lung2))

# A weighted boosted Cox model fits without complaint:
fit <- blackboost(
  Surv(time, status) ~ age + ph.ecog,
  data = lung2,
  family = CoxPH(),
  weights = wts
)

# ... but survFit() rejects it:
survFit(fit, newdata = lung2[1:3, ])
#> Error in `survFit.mboost()`:
#> ! survFit cannot (yet) deal with weights

Created on 2026-07-23 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions