annotate rDiff/src/locfit/m/lf_censor.m @ 2:233c30f91d66

updated python based GFF parsing module which will handle GTF/GFF/GFF3 file types
author vipints <vipin@cbio.mskcc.org>
date Tue, 08 Oct 2013 07:15:44 -0400
parents 0f80a5141704
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 function fit = lf_censor(x,y,cens,varargin)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 % Censored local regression using normal assumption.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 % Must provide x, y and cens.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 % All other arguments to locfit() can be provided, with the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 % exception of weights.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 % NEED: Kaplan Meier Estimate. Iterations are fixed.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 lfc_y = y;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 unc = find(~cens);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 for i = 0:3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 fit = locfit(x,lfc_y,varargin{:});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 fh = fitted(fit);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 rs = rsum(fit);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 df0 = rs(1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 df1 = rs(2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 rdf = sum(1-cens) - 2*df0 + df1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 sigma = sqrt(sum( (y-fh).*(lfc_y-fh) / rdf));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 sr = (y-fh)/sigma;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 lfc_y = fh + sigma*normpdf(sr)./normcdf(-sr);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 lfc_y(unc) = y(unc);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 return;