BookmarkSubscribeRSS Feed
acuffza
Calcite | Level 5

(I'm using SAS 9.4)

 

How do I find the mean for the cumulative distribution function I get from PROC ICLIFETEST. Is it equivalent to the median?

 

 


FailurePlot.png
3 REPLIES 3
JacobSimonsen
Barite | Level 11

No, the median does generally not estimate the mean.

Just to clarify, I understand your question such that you want the estimate of the mean of time-to-event, not the mean of the distribution functions. It is not easy to estimate the mean of the time-to-event from the distribution function, but if you really insist it is the integral of survival function (1-F(t)) taken from 0 to infinity, and it will only work if your estimated survival function ends in 0 such that the integral dont go to infinity.

 

An easier approach is probably to make some parametric assumptions so that the mean has a parametric form. A weibull distribution is among the most popular choiches. Then you can estimate the mean with proc lifereg. This procedure works also if you have left, right or interval censored data which I guess you have since you use ICLIFETEST instead of LIFETEST.

JacobSimonsen
Barite | Level 11

Actually, it is not as difficult to calculate the mean as I thought as first sight. As mentioned it can be calculated by intergrating 1-CDF. The CDF can be calculated from ICLIFETEST. In case you have only left censored values I think it is better to reverse the problem by taking inverse, and then use proc lifetest with right censored values. This is because I think the Kaplan Meier estimate is better than the Turnbull estimate.

 

Then the integral should be calculated. If you use ICLIFTETEST you can use this example where I find the mean from left censored values which was simulated from a gamma distribution with mean=10. The estimated mean (which is the integral) is written to the log-window.

 

data mydata;
  do i=1 to 5000;
    y=rand('gamma',10);
	c=rand('gamma',15);
	if y<c then do;
	  y=c;
	  d=1;
	end;
	else d=0;
	if d=1 then do; lower=.; upper=y; end;
	else do; lower=y;upper=y; end;
	output;
  end;
run;

ods listing close;
proc iclifetest data=mydata outsurv=turnbull ;
  time (lower,upper);
run;
ods listing;

data _NULL_;
  set turnbull end=end;
  retain lasttime lastvalue;
  if _N_=1 then do;
    integral=0;
	lastvalue=1;
	lasttime=0;
  end;

  integral+(leftboundary-lasttime)*(survprob+lastvalue)/2;
  integral+(rightboundary-leftboundary)*survprob;
  lasttime=rightboundary;
  lastvalue=survprob;
  if end then put integral;
run;
Rick_SAS
SAS Super FREQ

For an explanation of approximating the CDF by using trapezoidal approximations, see the article "An easy way to approximate a cumulative distribution function"  It might provide additional insights to @JacobSimonsen's computations.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1642 views
  • 3 likes
  • 3 in conversation