% This file calculates the result of the merging process and
% calculates the model output for the training data and the
% evaluation data

% merge clusters
amerge1

% calculate membership functions
makemf

% estimate local linear models
local

% calculate model output on training data
dof=dofprod(rls,mfs,d(:,1));
[ym yl ylm] = sugval(p,[d(:,1) ones(size(d,1),1)],dof);
figure(1); plot(d(:,1),[d(:,2) ym ylm],'o');

% calculate model output on evaluation data
dofe=dofprod(rls,mfs,xe);
[yme yle ylme] = sugval(p,[xe ones(size(xe),1)],dofe);
figure(2); plot(d(:,1),[d(:,2)],xe,[yme ylme]);
