0001 function lfplot(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 fit = varargin{1};
0028 data = fit.data;
0029 xdata = data.x;
0030 n = size(xdata,1);
0031 d = size(xdata,2);
0032 fali = fit.fit_points.family_link;
0033 ydata = data.y;
0034 wdata = data.weights;
0035 cdata = data.censor;
0036 if (length(cdata)==1) cdata = zeros(n,1); end;
0037 showdata = (fit.evaluation_structure.derivative==0);
0038 ppargs = {};
0039 plotargs = {};
0040
0041 type = 's';
0042 na = 2;
0043 while na <= length(varargin)
0044 inc = 0;
0045 if (strcmp(varargin{na},'contour'))
0046 type = 'c';
0047 inc = 1;
0048 end;
0049 if (strcmp(varargin{na},'what'))
0050 ppargs = {ppargs{:}, 'what', varargin{na+1}};
0051 showdata = 0;
0052 inc = 2;
0053 end;
0054 if (strcmp(varargin{na},'nodata'))
0055 showdata = 0;
0056 inc = 1;
0057 end;
0058 if (strcmp(varargin{na},'direct'))
0059 ppargs = {ppargs{:} 'direct'};
0060 inc = 1;
0061 end;
0062 if (inc==0)
0063 plotargs = {plotargs{:} varargin{na}};
0064 inc = 1;
0065 end;
0066 na = na+inc;
0067 end;
0068
0069 xfit = lfmarg(fit);
0070 yfit = predict(fit,xfit,ppargs{:});
0071 yfit = invlink(yfit,fali);
0072 fam = mod(fali(1),64);
0073 if (fam>4)
0074 ydata = ydata ./ wdata;
0075 end;
0076
0077 if (d==1)
0078 plot(xfit{1},yfit,plotargs{:});
0079 if (showdata)
0080 hold on;
0081 if (length(ydata)==1) ydata = zeros(n,1); end;
0082 plotbyfactor(xdata,ydata,cdata);
0083 hold off;
0084 end;
0085 end;
0086
0087 if (d==2)
0088 x1 = xfit{1};
0089 x2 = xfit{2};
0090 yfit = reshape(yfit,length(x1),length(x2));
0091 if (type=='c')
0092 [C h] = contour(x1,x2,yfit',plotargs{:});
0093 clabel(C,h);
0094 if (showdata)
0095 hold on;
0096 plotbyfactor(xdata(:,1),xdata(:,2),cdata);
0097 hold off;
0098 end;
0099 else
0100 surf(x1,x2,yfit',plotargs{:});
0101 end;
0102 end;
0103
0104 return;