crs4hce¶
Nonlinear regression – least-squares estimation of parameters
The minimization is performed by the CRS algorithm with four competing local heuristics and adaptive stopping condition.
Syntax¶
[b_star, rss_star] = crs4hce(fun, y_obs, X, a, b)
[b_star, rss_star, my_eps] = crs4hce(fun, y_obs, X, a, b, my_eps0, gamma)
[b_star, rss_star, my_eps, ne, nrst] = ...
crs4hce(fun, y_obs, X, a, b, my_eps0, gamma, N, max_evals, delta, w0)
Description¶
This function estimates the regression coefficients (returned as b_star
) of a nonlinear regression
function using least squares. The minimal sum of residual squares found by the search is in rss_star
,
ne
is the number of objective function evaluation and nrst
is the number of of probability
resets, my_eps
is the value found by adaptation of stopping condition,
(see description of algorithms).
fun : | (obligatory) is either the string with the name of fun or @fun |
---|---|
y_obs : | (obligatory) is a column vector of response (dependent variable) values. |
X : | (obligatory) is a design matrix of independent variables (regressors), with one row for each
value in y_obs . |
a , b : | (obligatory) are lower und upper bounds of the search space, row vectors of the same length, their length is equal to the number of estimated parameters |
Remaining six input parameters are facultative, but if you decide to modify their default
setting then you can ether modify my_eps0
and gamma
together or give all six.
my_eps0, gamma : | are used for adaptation of stopping condition (see description of algorithms) |
---|---|
N : | is the size of population |
max_evals : | is used for stopping condition |
delta, w0 : | control the competition of local heuristics (see description of algorithms) |
Examples:¶
Nonlinear regression function is written in boxbod.m
file:
function y_hat = boxbod(b, X)
y_hat = b(1)*(1-exp(-b(2) * X(:,1)));
X
and y_obs
are initialized as follows:
X = .[1; 2; 3; .5; 7; .10]
y_obs = [109; 149; 149; 191; 213; 224]
More about the BoxBOD data see http://www.itl.nist.gov/div898/strd/nls/data/boxbod.shtml
Remark: It is convenient to read the regression data from external file – see Matlab, Low-Level File I/O.
sample results:
>> b_star = crs4hce((@boxbod, y_obs, X, [1, 0.1], [1000 2])
b_star = 213.809 0.5472
>> [b_star, rss_star, my_eps] = crs4hce(@boxbod, y_obs, X, [1, 0.1], [1000 2])
b_star = 213.809 0.5472
rss_star = 1.1680e+003
my_eps = 1.0000e-009
>> [b_star, rss_star, my_eps, ne] = ...
crs4hce('boxbod', y_obs, X, [1, 0.1], [1000 2], 1e-2,1e3)
b_star = 213.821 0.5467
rss_star = 1.1680e+003
my_eps = 1.0000e-003
ne = 329
>> [b_star, rss_star, my_eps, ne, nrts] = ...
crs4hce('boxbod', y_obs, X, a, b, 1e-5, 1e5, 30, 1000, 0.03, 0.5)
b_star = 213.8241 0.5470
rss_star = 1.1680e+003
my_eps = 1.0000e-005
ne = 801
nrts = 14
You can use the estimates b_star
found by this algorithm as starting values in nlinfit
function of Statistical Toolbox and produce more detailed output useful for statistical analysis.