Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerating/plotting a log-normal survival function
    primarykey
    data
    text
    <p>I have an accelerated failure time model in SAS LIFEREG that I'd like to plot. Because SAS is to profoundly bad at graphing, I'd like to actually re-generate the data for the curves in R and plot them there. SAS puts out a scale (in the case of the exponential distribution fixed to 1), an intercept, and a regression coefficient for being in the exposed or unexposed population.</p> <p>There's two curves, one for the exposed and one for the unexposed population. One of the models is an exponential distribution, and I've produced the data and graph like so:</p> <pre><code>intercept &lt;- 5.00 effect&lt;- -0.500 data&lt;- data.frame(time=seq(0:180)-1) data$s_unexposed &lt;- apply(data,1,function(row) exp(-(exp(-intercept))*row[1])) data$s_exposed &lt;- apply(data,1,function(row) exp(-(exp(-(intercept+effect))*row[1]))) plot(data$time,data$s_unexposed, type="l", ylim=c(0,1) ,xaxt='n', xlab="Days since Infection", ylab="Percent Surviving", lwd=2) axis(1, at=c(0, 20, 40, 60, 80, 100, 120, 140, 160, 180)) lines(data$time,data$s_exposed, col="red",lwd=2) legend("topright", c("ICU Patients", "Non-ICU Patients"), lwd=2, col=c("red","black") ) </code></pre> <p>Which gives me this:</p> <p><img src="https://i.stack.imgur.com/IDgHg.png" alt="enter image description here"></p> <p>Not the prettiest graph ever, but I don't really know my way around ggplot2 enough to spruce it up. But more importantly, I have a second set of data that comes from a Log Normal distribution, rather than an exponential, and my attempts to generate the data for that have failed utterly - the incorporation of the cdf for the normal distribution and the like puts it beyond my R skills. </p> <p>Anyone able to point me in the right direction, using the same numbers, and a scale parameter of 1?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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