# [R] survit function and cox model with frailty

Thomas W Blackwell tblackw at umich.edu
Tue May 20 02:40:01 CEST 2003

```Giacomo  -

Here's just a guess, since I have no experience with this.
Try adding a sixth variable to the data frame "temp", a
variable named "id" with value c(1,1,1,1,1).  Maybe that
will do it ?   This is consistent with your intention in
setting individual=TRUE, and it will give the frailty()
term that's already in the model something to work with.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Mon, 19 May 2003 gc4 at duke.edu wrote:

> Hi:
>
> I have a question about the use of the survfit function after the
> estimation of a cox proportional hazard model with a frailty term. My goal
> is to estimate expected survival probabilities while controlling for the
> group-specific frailty term.
>
> First, I estimate a model of the following form:
>
> model1 <- coxph(Surv(t0, t, d) ~ x1 + x2 + frailty(id), na.action=na.exclude,
>                 data=My.data)
>
> Then, I prepare a data frame:
>
> temp <- data.frame(t0=c(0,365,730,1095,1460),
>                    t=c(365,730,1095,1460,3000),
>                    d=c(0,0,0,0,0),
>                    x1=c(0,0,0,0,0),
>                    x2=c(1.5,1.5,1.5,1.5,1.5))
>
> I think I would need to enter a statement with respect to the frailty
> term, but I don't know how.
>
> Indeed, when I use the survit function with temp data frame, I get an
> error message:
>
> > fit2 <- survfit(model1, newdata=temp, individual=TRUE)
> Error in model.frame(formula, rownames, variables, varnames, extras,
> extranames,  :
>         variable lengths differ
>
> Thank you very much,
> giacomo
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>

```