annotate rDiff/src/locfit/README @ 1:08d3a6143873

Deleted selected files
author vipints
date Tue, 08 Oct 2013 06:54:25 -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 Locfit, Matlab 2.01
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 http://locfit.herine.net/
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 April 2, 2007
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 Attaching:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 Make sure that you've added this directory recursively (i.e. with
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 all subdirectories) to your matlab search path.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 Basic usage:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 (1) To plot of a smooth curve:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 load ethanol; % load the dataset.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 fit = locfit(E,NOx) % local regression, with x,y vectors.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 lfplot(fit) % plot the fitted curve.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 (2a) To evaluate smooth at a specified set of points:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 load ethanol;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 xev = [0.6 0.7 0.8 0.9]'; % note column vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 fit = locfit(E,NOx,'ev',xev);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 yhat = predict(fit)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 (2b) Fit and interpolate approximation; may be faster for large datasets.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 load ethanol;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 xev = [0.6 0.7 0.8 0.9]'; % note column vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 fit = locfit(E,NOx);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 yhat = predict(fit,xev)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 (3) Surface smoothing - give matrix as first input.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 load ethanol; % load the dataset.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 fit = locfit([E C],NOx) % local regression.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 lfplot(fit)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 Most of the arguments to the S (and R) locfit() function, described
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 in my book, will also work in the Matlab version. E.g,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 fit = locfit(E,NOx,'deg',1,'kern','gauss')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 % local linear fit with the gaussian kernel.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 Smoothing parameters can be set with 'nn' and 'h', instead of the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 alpha vector used in my book. So
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 fit = locfit(E,NOx,'alpha',[0 0.2])
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 fit = locfit(E,NOx,'h',0.2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 are equivalent ways to specify a constant bandwidth h=0.2.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 The Book subdirectory contains functions to reproduce most of the book
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 figures. Run them, and look at the source code (many around 5 lines or less)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 for more examples.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 Some differences with the S/R version (and book documentation).
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 (1) Minor renaming of functions, mainly because matlab doesn't have
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 S-style methods. e.g. lfplot() instead of plot() or plot.locfit().
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 (2) Use lfband() to add confidence bands to a plot.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 (3) Functions such as aicplot(), gcvplot() sensitive to order of
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 arguments. Smoothing parameter matrix must be given first.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 (4) For 2-d predictors, lfplot() defaults to producing a surface, rather
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 than contour, plot.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 (5) The predict() function has an optional 'direct' argument, which
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 causes the fit to be recomputed at each evaluation point, rather
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 than interpolation of existing points.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 (6) A few things aren't implemented yet...
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 Technical stuff. Here's the layout of the structure returned by
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 the locfit() function. The first three components (data, evaluation
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 structure and smoothing parameters) are what you provide, or default
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 values. The last two (fit points, parametric component) are what
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 locfit computes. The expected size or format of the entry is
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 given in parentheses.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 fit.data.x (n*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 fit.data.y (n*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 fit.data.weights (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79 fit.data.censor (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 fit.data.baseline (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 fit.data.style (string length d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82 fit.data.scales (1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
83 fit.data.xlim (2*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
84
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
85 fit.evaluation_structure.type (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
86 fit.evaluation_structure.module (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
87 fit.evaluation_structure.lower_left (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
88 fit.evaluation_structure.upper_right (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
89 fit.evaluation_structure.grid (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
90 fit.evaluation_structure.cut (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
91 fit.evaluation_structure.maxk
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
92 fit.evaluation_structure.derivative
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
93
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
94 fit.smoothing_parameters.alpha = (nn h pen) vector
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
95 fit.smoothing_parameters.adaptive_criterion (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
96 fit.smoothing_parameters.degree (numeric)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
97 fit.smoothing_parameters.family (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
98 fit.smoothing_parameters.link (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
99 fit.smoothing_parameters.kernel (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
100 fit.smoothing_parameters.kernel_type (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
101 fit.smoothing_parameters.deren
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
102 fit.smoothing_parameters.deit
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
103 fit.smoothing_parameters.demint
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
104 fit.smoothing_parameters.debug
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
105
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
106 fit.fit_points.evaluation_points (d*nv matrix)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
107 fit.fit_points.fitted_values (matrix, nv rows, many columns)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
108 fit.fit_points.evaluation_vectors
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
109 fit.fit_points.fit_limits (d*2 matrix)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
110 fit.fit_points.family_link (numeric values)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
111 fit.fit_points.kappa (likelihood, degrees of freedom, etc)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
112
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
113 fit.parametric_component
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
114
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
115
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
116
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
117
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
118
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
119 This was the OLD format:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
120
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
121 +-{1} data
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
122 | +-{1} xdata matrix (n*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
123 | +-{2} ydata column vector (n*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
124 | +-{3} wdata weight vector (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
125 | +-{4} cdata censoring vector (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
126 | +-{5} base baseline vector (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
127 | +-{6} style vector (string length d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
128 | +-{7} scales vector (1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
129 | +-{8} xl xlim vector (2*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
130 |
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
131 +-{2} evaluation structure
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
132 | +-{1} structure type (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
133 | +-{2} module (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
134 | +-{3} ll corner of bounding box (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
135 | +-{4} ur corner of bounding box (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
136 | +-{5} mg vector for grid (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
137 | +-{6} cut parameter for adaptive structures (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
138 | +-{7} maxk memory control parameter
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
139 | +-{8} derivative vector
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
140 |
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
141 +-{3} sp smoothing parameters
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
142 | +-{1} alpha = (nn h pen) vector
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
143 | +-{2} adaptive criterion (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
144 | +-{3} local polynomial degree (numeric)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
145 | +-{4} fitting family (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
146 | +-{5} link (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
147 | +-{6} kernel (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
148 | +-{7} kernel type - product, spherical (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
149 |
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
150 +-{4} fpc fit points
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
151 | +-{1} evaluation points, d*nv matrix.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
152 | +-{2} fitted values etc, (matrix, nv rows, many columns)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
153 | +-{3} cell of vectors generated by evaluation structure.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
154 | | +-{1} ce integer vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
155 | | +-{2} s integer vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
156 | | +-{3} lo integer vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
157 | | +-{4} hi integer vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
158 | |
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
159 | +-{4} fit limits (d*2 matrix)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
160 | +-{5} [family link] (numeric values)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
161 | +-{6} 'kappa' vector. (likelihood, degrees of freedom, etc)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
162 |
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
163 +-{5} parametric component vector.