Internal function. Calculates Inverse Probability of Censoring Weights (IPCW) and adds them to a data.frame

1 2 3 |

`formula` |
Formula specifying the censoring model |

`data` |
data frame |

`cluster` |
clustering variable |

`same.cens` |
For clustered data, should same censoring be assumed (bivariate probability calculated as mininum of the marginal probabilities) |

`obs.only` |
Return data with uncensored observations only |

`weight.name` |
Name of weight variable in the new data.frame |

`trunc.prob` |
If TRUE truncation probabilities are also calculated and stored in 'weight.name2' (based on Clayton-Oakes gamma frailty model) |

`weight.name2` |
Name of truncation probabilities |

`cens.model` |
Censoring model (default Aalens additive model) |

`pairs` |
For paired data (e.g. twins) only the complete pairs are returned (With pairs=TRUE) |

`theta.formula` |
Model for the dependence parameter in the Clayton-Oakes model (truncation only) |

`...` |
Additional arguments to censoring model |

Klaus K. Holst

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
## Not run:
data(prt)
prtw <- ipw(Surv(time,status==0)~country, data=prt[sample(nrow(prt),5000),],
cluster="id",weight.name="w")
plot(0,type="n",xlim=range(prtw$time),ylim=c(0,1),xlab="Age",ylab="Probability")
count <- 0
for (l in unique(prtw$country)) {
count <- count+1
prtw <- prtw[order(prtw$time),]
with(subset(prtw,country==l),
lines(time,w,col=count,lwd=2))
}
legend("topright",legend=unique(prtw$country),col=1:4,pch=-1,lty=1)
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.