Home > chronux > locfit > m > lf_censor.m

lf_censor

PURPOSE ^

SYNOPSIS ^

function fit = lf_censor(x,y,cens,varargin)

DESCRIPTION ^

 Censored local regression using normal assumption.
 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fit = lf_censor(x,y,cens,varargin)
0002 %
0003 % Censored local regression using normal assumption.
0004 % Must provide x, y and cens.
0005 % All other arguments to locfit() can be provided, with the
0006 % exception of weights.
0007 %
0008 % NEED: Kaplan Meier Estimate. Iterations are fixed.
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;

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005