0001 function fit = lf_censor(x,y,cens,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 lfc_y = y;
0012 unc = find(~cens);
0013
0014 for i = 0:3
0015 fit = locfit(x,lfc_y,varargin{:});
0016 fh = fitted(fit);
0017
0018 rs = rsum(fit);
0019 df0 = rs(1);
0020 df1 = rs(2);
0021
0022 rdf = sum(1-cens) - 2*df0 + df1;
0023 sigma = sqrt(sum( (y-fh).*(lfc_y-fh) / rdf));
0024 sr = (y-fh)/sigma;
0025 lfc_y = fh + sigma*normpdf(sr)./normcdf(-sr);
0026 lfc_y(unc) = y(unc);
0027 end;
0028
0029 return;