Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The survival function at time t for a log-normal model can be represented in R with <code>1 - plnorm()</code>, where <code>plnorm()</code> is the log-normal cumulative distribution function. To illustrate, we'll first put your plot into a function for convenience:</p> <pre><code>## Function to plot aft data plot.aft &lt;- function(x, legend = c("ICU Patients", "Non-ICU Patients"), xlab = "Days since Infection", ylab="Percent Surviving", lwd = 2, col = c("red", "black"), at = c(0, 20, 40, 60, 80, 100, 120, 140, 160, 180), ...) { plot(x[, 1], x[, 2], type = "l", ylim = c(0, 1), xaxt = "n", xlab = xlab, ylab = ylab, col = col[2], lwd = 2, ...) axis(1, at = at) lines(x[, 1], x[, 3], col = col[1], lwd=2) legend("topright", legend = legend, lwd = lwd, col = col) } </code></pre> <p>Next, we'll specify the coefficients, variables, and models, and then generate the survival probabilities for the exponential and log-normal models:</p> <pre><code>## Specify coefficients, variables, and linear models beta0 &lt;- 5.00 beta1 &lt;- -0.500 icu &lt;- c(0, 1) t &lt;- seq(0, 180) linmod &lt;- beta0 + (beta1 * icu) names(linmod) &lt;- c("unexposed", "exposed") ## Generate s(t) from exponential AFT model s0.exp &lt;- dexp(exp(-linmod["unexposed"]) * t) s1.exp &lt;- dexp(exp(-linmod["exposed"]) * t) ## Generate s(t) from lognormal AFT model s0.lnorm &lt;- 1 - plnorm(t, meanlog = linmod["unexposed"]) s1.lnorm &lt;- 1 - plnorm(t, meanlog = linmod["exposed"]) </code></pre> <p>Finally, we can plot the survival probabilities:</p> <pre><code>## Plot survival plot.aft(data.frame(t, s0.exp, s1.exp), main = "Exponential model") plot.aft(data.frame(t, s0.lnorm, s1.lnorm), main = "Log-normal model") </code></pre> <p>And the resulting figures:</p> <p><img src="https://i.stack.imgur.com/MlkVA.png" alt="Exponential model"></p> <p><img src="https://i.stack.imgur.com/wL0iO.png" alt="Log-normal model"></p> <p>Note that </p> <pre><code>plnorm(t, meanlog = linmod["exposed"]) </code></pre> <p>is the same as</p> <pre><code>pnorm((log(t) - linmod["exposed"]) / 1) </code></pre> <p>which is the Φ in the canonical equation for the log-normal survival function: S(t) = 1 − Φ((ln(t) − µ) / σ)</p> <p>As I'm sure you know, there are a number of R packages that can handle accelerated failure time models with left, right, or interval censoring, as listed in the <a href="http://cran.r-project.org/web/views/Survival.html" rel="noreferrer">survival task view</a>, in case you happen to develop a preference for R over SAS.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload