comparison rDiff/src/locfit/README @ 0:0f80a5141704

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