EVOLUTION-MANAGER
Edit File: survSplit.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Split a survival data set at specified times</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for survSplit {survival}"><tr><td>survSplit {survival}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Split a survival data set at specified times </h2> <h3>Description</h3> <p>Given a survival data set and a set of specified cut times, split each record into multiple subrecords at each cut time. The new data set will be in ‘counting process’ format, with a start time, stop time, and event status for each record. </p> <h3>Usage</h3> <pre> survSplit(formula, data, subset, na.action=na.pass, cut, start="tstart", id, zero=0, episode, end="tstop", event="event") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>formula</code></td> <td> <p>a model formula</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p>a data frame</p> </td></tr> <tr valign="top"><td><code>subset, na.action</code></td> <td> <p>rows of the data to be retained</p> </td></tr> <tr valign="top"><td><code>cut</code></td> <td> <p>the vector of timepoints to cut at</p> </td></tr> <tr valign="top"><td><code>start</code></td> <td> <p>character string with the name of a start time variable (will be created if needed) </p> </td></tr> <tr valign="top"><td><code>id</code></td> <td> <p>character string with the name of new id variable to create (optional). This can be useful if the data set does not already contain an identifier.</p> </td></tr> <tr valign="top"><td><code>zero</code></td> <td> <p>If <code>start</code> doesn't already exist, this is the time that the original records start.</p> </td></tr> <tr valign="top"><td><code>episode</code></td> <td> <p>character string with the name of new episode variable (optional)</p> </td></tr> <tr valign="top"><td><code>end</code></td> <td> <p>character string with the name of event time variable </p> </td></tr> <tr valign="top"><td><code>event</code></td> <td> <p>character string with the name of censoring indicator </p> </td></tr> </table> <h3>Details</h3> <p>Each interval in the original data is cut at the given points; if an original row were (15, 60] with a cut vector of (10,30, 40) the resulting data set would have intervals of (15,30], (30,40] and (40, 60]. </p> <p>Each row in the final data set will lie completely within one of the cut intervals. Which interval for each row of the output is shown by the <code>episode</code> variable, where 1= less than the first cutpoint, 2= between the first and the second, etc. For the example above the values would be 2, 3, and 4. </p> <p>The routine is called with a formula as the first argument. The right hand side of the formula can be used to delimit variables that should be retained; normally one will use <code> ~ .</code> as a shorthand to retain them all. The routine will try to retain variable names, e.g. <code>Surv(adam, joe, fred)~.</code> will result in a data set with those same variable names for <code>tstart</code>, <code>end</code>, and <code>event</code> options rather than the defaults. Any user specified values for these options will be used if they are present, of course. However, the routine is not sophisticated; it only does this substitution for simple names. A call of <code>Surv(time, stat==2)</code> for instance will not retain "stat" as the name of the event variable. </p> <p>Rows of data with a missing time or status are copied across unchanged, unless the na.action argument is changed from its default value of <code>na.pass</code>. But in the latter case any row that is missing for any variable will be removed, which is rarely what is desired. </p> <h3>Value</h3> <p>New, longer, data frame. </p> <h3>See Also</h3> <p><code><a href="Surv.html">Surv</a></code>, <code><a href="../../base/html/cut.html">cut</a></code>, <code><a href="../../stats/html/reshape.html">reshape</a></code> </p> <h3>Examples</h3> <pre> fit1 <- coxph(Surv(time, status) ~ karno + age + trt, veteran) plot(cox.zph(fit1)[1]) # a cox.zph plot of the data suggests that the effect of Karnofsky score # begins to diminish by 60 days and has faded away by 120 days. # Fit a model with separate coefficients for the three intervals. # vet2 <- survSplit(Surv(time, status) ~., veteran, cut=c(60, 120), episode ="timegroup") fit2 <- coxph(Surv(tstart, time, status) ~ karno* strata(timegroup) + age + trt, data= vet2) c(overall= coef(fit1)[1], t0_60 = coef(fit2)[1], t60_120= sum(coef(fit2)[c(1,4)]), t120 = sum(coef(fit2)[c(1,5)])) </pre> <hr /><div style="text-align: center;">[Package <em>survival</em> version 2.44-1.1 <a href="00Index.html">Index</a>]</div> </body></html>