annotate rDiff/src/locfit/m/gcvplot.m @ 3:29a698dc5c7e default tip

Merge multiple heads.
author Dave Bouvier <dave@bx.psu.edu>
date Mon, 27 Jan 2014 14:15:36 -0500
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 g=gcvplot(alpha,varargin)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 % Computes and plots the Generalized Cross-Validation score (GCV)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 % for local fits with different smoothing parameters.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 % The first argument to gcvplot(), alpha, should be a matrix with one
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 % or two columns (first column = nearest neighbor component, second
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 % column = constant component). Each row of this matrix is, in turn,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 % passed as the 'alpha' argument to gcv() (and locfit()). The results
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 % are stored in a matrix, and GCV score ploted against the degrees of
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 % freedom.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 k = size(alpha,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 z = zeros(k,4);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 for i=1:k
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 z(i,:) = gcv(varargin{:},'alpha',alpha(i,:));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 plot(z(:,3),z(:,4));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 xlabel('Fitted DF');
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 ylabel('GCV');
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 g = [alpha z];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 return;