annotate rDiff/src/locfit/m/locfit.m @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
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 fit=locfit(varargin)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 % Smoothing noisy data using Local Regression and Likelihood.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 % arguments still to add: dc maxit
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 % Usage: fit = locfit(x,y) % local regression fit of x and y.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 % fit = locfit(x) % density estimation of x.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 % Smoothing with locfit is a two-step procedure. The locfit()
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 % function evaluates the local regression smooth at a set of points
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 % (can be specified through an evaluation structure). Then, use
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 % the predict() function to interpolate this fit to other points.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 % Additional arguments to locfit() are specified as 'name',value pairs, e.g.:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 % locfit( x, 'alpha',[0.7,1.5] , 'family','rate' , 'ev','grid' , 'mg',100 );
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 % Data-related inputs:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 % x is a vector or matrix of the independent (or predictor) variables.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 % Rows of x represent subjects, columns represent variables.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 % Generally, local regression would be used with 1-4 independent
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 % variables. In higher dimensions, the curse-of-dimensionality,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 % as well as the difficulty of visualizing higher dimensional
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 % surfaces, may limit usefulness.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 % y is the column vector of the dependent (or response) variable.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 % For density families, 'y' is omitted.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 % NOTE: x and y are the first two arguments. All other arguments require
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 % the 'name',value notation.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 % 'weights' Prior weights for observations (reciprocal of variance, or
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 % sample size).
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 % 'cens' Censoring indicators for hazard rate or censored regression.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 % The coding is '1' (or 'TRUE') for a censored observation, and
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 % '0' (or 'FALSE') for uncensored observations.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 % 'base' Baseline parameter estimate. If a baseline is provided,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 % the local regression model is fitted as
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 % Y_i = b_i + m(x_i) + epsilon_i,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 % with Locfit estimating the m(x) term. For regression models,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 % this effectively subtracts b_i from Y_i. The advantage of the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 % 'base' formulation is that it extends to likelihood
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 % regression models.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 % 'scale' A scale to apply to each variable. This is especially
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 % important for multivariate fitting, where variables may be
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 % measured in non-comparable units. It is also used to specify
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48 % the frequency for variables with the 'a' (angular) style.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 % 'sty' Character string (length d) of styles for each predictor variable.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 % n denotes `normal'; a denotes angular (or periodic); l and r
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 % denotes one-sided left and right; c is conditionally parametric.
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 % Smoothing Parameters and Bandwidths:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 % The bandwidth (or more accurately, half-width) of the smoothing window
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 % controls the amount of smoothing. Locfit allows specification of constant
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 % (fixed), nearest neighbor, certain locally adaptive variable bandwidths,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 % and combinations of these. Also related to the smoothing parameter
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 % are the local polynmial degree and weight function.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 % 'nn' 'Nearest neighbor' smoothing parameter. Specifying 'nn',0.5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 % means that the width of each smoothing neighborhood is chosen
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 % to cover 50% of the data.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 % 'h' A constant (or fixed) bandwidth parameter. For example, 'h',2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 % means that the smoothing windows have constant half-width
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 % (or radius) 2. Note that h is applied after scaling.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 % 'pen' penalty parameter for adaptive smoothing. Needs to be used
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 % with care.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 % 'alpha' The old way of specifying smoothing parameters, as used in
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 % my book. alpha is equivalent to the vector [nn,h,pen].
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 % If multiple componenents are non-zero, the largest corresponding
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75 % bandwidth is used. The default (if none of alpha,nn,h,pen
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 % are provided) is [0.7 0 0].
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 % 'deg' Degree of local polynomial. Default: 2 (local quadratic).
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79 % Degrees 0 to 3 are supported by almost all parts of the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 % Locfit code. Higher degrees may work in some cases.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82 % 'kern' Weight function, default = 'tcub'. Other choices are
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
83 % 'rect', 'trwt', 'tria', 'epan', 'bisq' and 'gauss'.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
84 % Choices may be restricted when derivatives are
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
85 % required; e.g. for confidence bands and some bandwidth
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
86 % selectors.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
87 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
88 % 'kt' Kernel type, 'sph' (default); 'prod'. In multivariate
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
89 % problems, 'prod' uses a simplified product model which
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
90 % speeds up computations.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
91 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
92 % 'acri' Criterion for adaptive bandwidth selection.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
93 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
94 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
95 % Derivative Estimation.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
96 % Generally I recommend caution when using derivative estimation
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
97 % (and especially higher order derivative estimation) -- can you
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
98 % really estimate derivatives from noisy data? Any derivative
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
99 % estimate is inherently more dependent on an assumed smoothness
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
100 % (expressed through the bandwidth) than the data. Warnings aside...
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
101 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
102 % 'deriv' Derivative estimation. 'deriv',1 specifies the first derivative
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
103 % (or more correctly, an estimate of the local slope is returned.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
104 % 'deriv',[1 1] specifies the second derivative. For bivariate fits
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
105 % 'deriv',2 specifies the first partial derivative wrt x2.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
106 % 'deriv',[1 2] is mixed second-order derivative.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
107 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
108 % Fitting family.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
109 % 'family' is used to specify the local likelihood family.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
110 % Regression-type families are 'gaussian', 'binomial',
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
111 % 'poisson', 'gamma' and 'geom'. If the family is preceded
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
112 % by a q (e.g. 'qgauss', or 'qpois') then quasi-likelihood is
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
113 % used; in particular, a dispersion estimate is computed.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
114 % Preceding by an 'r' makes an attempt at robust (outlier-resistant)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
115 % estimation. Combining q and r (e.g. 'family','qrpois') may
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
116 % work, if you're lucky.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
117 % Density estimation-type families are 'dens', 'rate' and 'hazard'
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
118 % (hazard or failure rate). Note that `dens' scales the output
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
119 % to be a statistical density estimate (i.e. scaled to integrate
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
120 % to 1). 'rate' estimates the rate or intensity function (events
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
121 % per unit time, or events per unit area), which may be called
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
122 % density in some fields.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
123 % The default family is 'qgauss' if a response (y argument) has been
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
124 % provided, and 'dens' if no response is given.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
125 % 'link' Link function for local likelihood fitting. Depending on the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
126 % family, choices may be 'ident', 'log', 'logit',
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
127 % 'inverse', 'sqrt' and 'arcsin'.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
128 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
129 % Evaluation structures.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
130 % By default, locfit chooses a set of points, depending on the data
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
131 % and smoothing parameters, to evaluate at. This is controlled by
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
132 % the evaluation structure.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
133 % 'ev' Specify the evaluation structure. Default is 'tree'.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
134 % Other choices include 'phull' (triangulation), 'grid' (a grid
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
135 % of points), 'data' (each data point), 'crossval' (data,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
136 % but use leave-one-out cross validation), 'none' (no evaluation
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
137 % points, effectively producing the global parametric fit).
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
138 % Alternatively, a vector/matrix of evaluation points may be
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
139 % provided.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
140 % (kd trees not currently supported in mlocfit)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
141 % 'll' and 'ur' -- row vectors specifying the upper and lower limits
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
142 % for the bounding box used by the evaluation structure.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
143 % They default to the data range.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
144 % 'mg' For the 'grid' evaluation structure, 'mg' specifies the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
145 % number of points on each margin. Default 10. Can be either a
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
146 % single number or vector.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
147 % 'cut' Refinement parameter for adaptive partitions. Default 0.8;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
148 % smaller values result in more refined partitions.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
149 % 'maxk' Controls space assignment for evaluation structures. For the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
150 % adaptive evaluation structures, it is impossible to be sure
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
151 % in advance how many vertices will be generated. If you get
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
152 % warnings about `Insufficient vertex space', Locfit's default
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
153 % assigment can be increased by increasing 'maxk'. The default
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
154 % is 'maxk','100'.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
155 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
156 % 'xlim' For density estimation, Locfit allows the density to be
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
157 % supported on a bounded interval (or rectangle, in more than
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
158 % one dimension). The format should be [ll;ul] (ie, matrix with
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
159 % two rows, d columns) where ll is the lower left corner of
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
160 % the rectangle, and ur is the upper right corner.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
161 % One-sided bounds, such as [0,infty), are not supported, but can be
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
162 % effectively specified by specifying a very large upper
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
163 % bound.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
164 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
165 % 'module' either 'name' or {'name','/path/to/module',parameters}.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
166 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
167 % Density Estimation
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
168 % 'renorm',1 will attempt to renormalize the local likelihood
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
169 % density estimate so that it integrates to 1. The llde
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
170 % (specified by 'family','dens') is scaled to estimate the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
171 % density, but since the estimation is pointwise, there is
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
172 % no guarantee that the resulting density integrates exactly
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
173 % to 1. Renormalization attempts to achieve this.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
174 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
175 % The output of locfit() is a Matlab structure:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
176 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
177 % fit.data.x (n*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
178 % fit.data.y (n*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
179 % fit.data.weights (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
180 % fit.data.censor (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
181 % fit.data.baseline (n*1 or 1*1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
182 % fit.data.style (string length d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
183 % fit.data.scales (1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
184 % fit.data.xlim (2*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
185 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
186 % fit.evaluation_structure.type (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
187 % fit.evaluation_structure.module.name (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
188 % fit.evaluation_structure.module.directory (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
189 % fit.evaluation_structure.module.parameters (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
190 % fit.evaluation_structure.lower_left (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
191 % fit.evaluation_structure.upper_right (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
192 % fit.evaluation_structure.grid (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
193 % fit.evaluation_structure.cut (numeric 1*d)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
194 % fit.evaluation_structure.maxk
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
195 % fit.evaluation_structure.derivative
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
196 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
197 % fit.smoothing_parameters.alpha = (nn h pen) vector
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
198 % fit.smoothing_parameters.adaptive_criterion (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
199 % fit.smoothing_parameters.degree (numeric)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
200 % fit.smoothing_parameters.family (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
201 % fit.smoothing_parameters.link (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
202 % fit.smoothing_parameters.kernel (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
203 % fit.smoothing_parameters.kernel_type (string)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
204 % fit.smoothing_parameters.deren
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
205 % fit.smoothing_parameters.deit
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
206 % fit.smoothing_parameters.demint
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
207 % fit.smoothing_parameters.debug
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
208 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
209 % fit.fit_points.evaluation_points (d*nv matrix)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
210 % fit.fit_points.fitted_values (matrix, nv rows, many columns)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
211 % fit.fit_points.evaluation_vectors.cell
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
212 % fit.fit_points.evaluation_vectors.splitvar
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
213 % fit.fit_points.evaluation_vectors.lo
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
214 % fit.fit_points.evaluation_vectors.hi
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
215 % fit.fit_points.fit_limits (d*2 matrix)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
216 % fit.fit_points.family_link (numeric values)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
217 % fit.fit_points.kappa (likelihood, degrees of freedom, etc)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
218 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
219 % fit.parametric_component
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
220 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
221 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
222 % The OLD format:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
223 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
224 % fit{1} = data.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
225 % fit{2} = evaluation structure.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
226 % fit{3} = smoothing parameter structure.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
227 % fit{4}{1} = fit points matrix.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
228 % fit{4}{2} = matrix of fitted values etc.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
229 % Note that these are not back-transformed, and may have the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
230 % parametric component removed.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
231 % (exact content varies according to module).
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
232 % fit{4}{3} = various details of the evaluation points.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
233 % fit{4}{4} = fit limits.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
234 % fit{4}{5} = family,link.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
235 % fit{5} = parametric component values.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
236 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
237
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
238
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
239
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
240 % Minimal input validation
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
241 if nargin < 1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
242 error( 'At least one input argument required' );
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
243 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
244
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
245 xdata = double(varargin{1});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
246 d = size(xdata,2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
247 n = size(xdata,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
248 if ((nargin>1) && (~ischar(varargin{2})))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
249 ydata = double(varargin{2});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
250 if (any(size(ydata) ~= [n 1])); error('y must be n*1 column vector'); end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
251 family = 'qgauss';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
252 na = 3;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
253 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
254 ydata = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
255 family = 'density';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
256 na = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
257 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
258 if mod(nargin-na,2)==0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
259 error( 'All arguments other than x, y must be name,value pairs' );
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
260 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
261
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
262
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
263 wdata = ones(n,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
264 cdata = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
265 base = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
266 style = 'n';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
267 scale = 1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
268 xl = zeros(2,d);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
269
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
270 alpha = [0 0 0];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
271 deg = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
272 link = 'default';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
273 acri = 'none';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
274 kern = 'tcub';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
275 kt = 'sph';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
276 deren = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
277 deit = 'default';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
278 demint= 20;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
279 debug = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
280
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
281 ev = 'tree';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
282 ll = zeros(1,d);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
283 ur = zeros(1,d);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
284 mg = 10;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
285 maxk = 100;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
286 deriv=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
287 cut = 0.8;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
288 mdl = struct('name','std', 'directory','', 'parameters',0 );
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
289
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
290 while na < length(varargin)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
291 inc = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
292 if (varargin{na}=='y')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
293 ydata = double(varargin{na+1});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
294 family = 'qgauss';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
295 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
296 if (any(size(ydata) ~= [n 1])); error('y must be n*1 column vector'); end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
297 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
298 if (strcmp(varargin{na},'weights'))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
299 wdata = double(varargin{na+1});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
300 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
301 if (any(size(wdata) ~= [n 1])); error('weights must be n*1 column vector'); end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
302 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
303 if (strcmp(varargin{na},'cens'))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
304 cdata = double(varargin{na+1});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
305 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
306 if (any(size(cdata) ~= [n 1])); error('cens must be n*1 column vector'); end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
307 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
308 if (strcmp(varargin{na},'base')) % numeric vector, n*1 or 1*1.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
309 base = double(varargin{na+1});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
310 if (length(base)==1); base = base*ones(n,1); end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
311 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
312 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
313 if (strcmp(varargin{na},'style')) % character string of length d.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
314 style = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
315 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
316 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
317 if (strcmp(varargin{na},'scale')) % row vector, length 1 or d.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
318 scale = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
319 if (scale==0)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
320 scale = zeros(1,d);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
321 for i=1:d
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
322 scale(i) = sqrt(var(xdata(:,i)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
323 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
324 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
325 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
326 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
327 if (strcmp(varargin{na},'xlim')) % 2*d numeric matrix.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
328 xl = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
329 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
330 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
331 if (strcmp(varargin{na},'alpha')) % row vector of length 1, 2 or 3.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
332 alpha = [varargin{na+1} 0 0 0];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
333 alpha = alpha(1:3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
334 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
335 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
336 if (strcmp(varargin{na},'nn')) % scalar
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
337 alpha(1) = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
338 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
339 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
340 if (strcmp(varargin{na},'h')) % scalar
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
341 alpha(2) = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
342 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
343 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
344 if (strcmp(varargin{na},'pen')) % scalar
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
345 alpha(3) = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
346 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
347 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
348 if (strcmp(varargin{na},'acri')) % string
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
349 acri = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
350 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
351 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
352 if (strcmp(varargin{na},'deg')) % positive integer.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
353 deg = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
354 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
355 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
356 if (strcmp(varargin{na},'family')) % character string.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
357 family = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
358 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
359 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
360 if (strcmp(varargin{na},'link')) % character string.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
361 link = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
362 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
363 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
364 if (strcmp(varargin{na},'kern')) % character string.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
365 kern = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
366 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
367 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
368 if (strcmp(varargin{na},'kt')) % character string.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
369 kt = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
370 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
371 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
372 if (strcmp(varargin{na},'ev')) % char. string, or matrix with d columns.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
373 ev = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
374 if (isnumeric(ev)); ev = ev'; end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
375 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
376 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
377 if (strcmp(varargin{na},'ll')) % row vector of length d.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
378 ll = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
379 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
380 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
381 if (strcmp(varargin{na},'ur')) % row vector of length d.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
382 ur = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
383 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
384 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
385 if (strcmp(varargin{na},'mg')) % row vector of length d.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
386 mg = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
387 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
388 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
389 if (strcmp(varargin{na},'cut')) % positive scalar.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
390 cut = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
391 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
392 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
393 if (strcmp(varargin{na},'module')) % string.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
394 mdl = struct('name',varargin{na+1}, 'directory','', 'parameters',0 );
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
395 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
396 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
397 if (strcmp(varargin{na},'maxk')) % positive integer.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
398 maxk = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
399 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
400 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
401 if (strcmp(varargin{na},'deriv')) % numeric row vector, up to deg elements.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
402 deriv = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
403 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
404 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
405 if (strcmp(varargin{na},'renorm')) % density renormalization.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
406 deren = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
407 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
408 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
409 if (strcmp(varargin{na},'itype')) % density - integration type.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
410 deit = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
411 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
412 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
413 if (strcmp(varargin{na},'mint')) % density - # of integration points.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
414 demint = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
415 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
416 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
417 if (strcmp(varargin{na},'debug')) % debug level.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
418 debug = varargin{na+1};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
419 inc = 2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
420 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
421 if (inc==0)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
422 disp(varargin{na});
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
423 error('Unknown Input Argument.');
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
424 end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
425 na=na+inc;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
426 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
427
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
428
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
429 fit.data.x = xdata;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
430 fit.data.y = ydata;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
431 fit.data.weights = wdata;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
432 fit.data.censor = cdata;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
433 fit.data.baseline = base;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
434 fit.data.style = style;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
435 fit.data.scales = scale;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
436 fit.data.xlim = xl;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
437
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
438 fit.evaluation_structure.type = ev;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
439 fit.evaluation_structure.module = mdl;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
440 fit.evaluation_structure.lower_left = ll;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
441 fit.evaluation_structure.upper_right = ur;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
442 fit.evaluation_structure.grid = mg;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
443 fit.evaluation_structure.cut = cut;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
444 fit.evaluation_structure.maxk = maxk;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
445 fit.evaluation_structure.derivative = deriv;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
446
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
447 if (alpha==0); alpha = [0.7 0 0]; end;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
448
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
449 fit.smoothing_parameters.alpha = alpha;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
450 fit.smoothing_parameters.adaptive_criterion = acri;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
451 fit.smoothing_parameters.degree = deg;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
452 fit.smoothing_parameters.family = family;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
453 fit.smoothing_parameters.link = link;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
454 fit.smoothing_parameters.kernel = kern;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
455 fit.smoothing_parameters.kernel_type = kt;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
456 fit.smoothing_parameters.deren = deren;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
457 fit.smoothing_parameters.deit = deit;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
458 fit.smoothing_parameters.demint = demint;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
459 fit.smoothing_parameters.debug = debug;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
460
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
461 [fpc pcomp] = mexlf(fit.data,fit.evaluation_structure,fit.smoothing_parameters);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
462 fit.fit_points = fpc;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
463 fit.parametric_component = pcomp;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
464
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
465 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
466
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
467
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
468