


Censored local regression using normal assumption. Usage: fit = lf_censor(x,y,cens,varargin) Must provide x, y and cens. All other arguments to locfit() can be provided, with the exception of weights. NEED: Kaplan Meier Estimate. Iterations are fixed.


0001 function fit = lf_censor(x,y,cens,varargin) 0002 % Censored local regression using normal assumption. 0003 % 0004 % Usage: fit = lf_censor(x,y,cens,varargin) 0005 % 0006 % Must provide x, y and cens. 0007 % All other arguments to locfit() can be provided, with the 0008 % exception of weights. 0009 % 0010 % NEED: Kaplan Meier Estimate. Iterations are fixed. 0011 % 0012 0013 lfc_y = y; 0014 unc = find(~cens); 0015 0016 for i = 0:3 0017 fit = locfit(x,lfc_y,varargin{:}); 0018 fh = fitted(fit); 0019 0020 rs = rsum(fit); 0021 df0 = rs(1); 0022 df1 = rs(2); 0023 0024 rdf = sum(1-cens) - 2*df0 + df1; 0025 sigma = sqrt(sum( (y-fh).*(lfc_y-fh) / rdf)); 0026 sr = (y-fh)/sigma; 0027 lfc_y = fh + sigma*normpdf(sr)./normcdf(-sr); 0028 lfc_y(unc) = y(unc); 0029 end; 0030 0031 return;