Description Usage Arguments Details Value See Also Examples

View source: R/aggregate.survfit.R

For a survfit object containing multiple curves, create average curves over a grouping.

1 2 |

`x` |
a |

`by` |
an optional list or vector of grouping elements, each as
long as |

`FUN` |
a function to compute the summary statistic of interest. |

`...` |
optional further arguments to FUN. |

The primary use of this is to take an average over multiple survival curves that were created from a modeling function. That is, a marginal estimate of the survival. It is primarily used to average over multiple predicted curves from a Cox model.

a `survfit`

object of lower dimension.

1 2 3 4 5 6 7 8 | ```
cfit <- coxph(Surv(futime, death) ~ sex + age*hgb, data=mgus2)
# marginal effect of sex, after adjusting for the others
dummy <- rbind(mgus2, mgus2)
dummy$sex <- rep(c("F", "M"), each=nrow(mgus2)) # population data set
dummy <- na.omit(dummy) # don't count missing hgb in our "population
csurv <- survfit(cfit, newdata=dummy)
dim(csurv) # 2 * 1384 survival curves
csurv2 <- aggregate(csurv, dummy$sex)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.