crs4hc¶
Nonlinear regression – least-squares estimation of parameters
The minimization is performed by the CRS algorithm with four competing local heuristics.
Syntax¶
[b_star, rss_star, ne, nrst] = ...
crs4hc(fun, y_obs, X, a, b, N, my_eps, max_evals, delta, w0)
[b_star, rss_star] = crs4hc(fun, y_obs, X, a, b)
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
(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, 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 five input parameters are facultative, but if you decide to modify their default setting then you must give all five.
N : | is the size of population |
---|---|
my_eps , max_evals : | |
are used for stopping condition (see description of algorithms) | |
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, rss_star, ne, nrst] = crs4hc('boxbod', y_obs, X, [1, 0.1], [1000 2])
b_star = 213.8094 0.5472
rss_star = 1.1680e+003
ne = 1268
nrst = 41
>> b_star = crs4hc(@boxbod, y_obs, X, [1, 0.1], [1000 2])
b_star = 213.8094 0.5472
>> [b_star, rss_star, ne, nrst] = ...
crs4hc('boxbod', y_obs, X, [1, 0.1], [1000 2], 20, 1e-9, 2000, 1/20, 0.5)
b_star = 213.8098 0.5472
rss_star = 1.1680e+003
ne = 802
nrst = 25
>> [b_star, rss_star, ne, nrst] = ...
crs4hc('boxbod', y_obs, X, [1, 0.1], [1000 2], 20, 1e-5, 2000, 1/20, 0.5)
b_star = 213.7907 0.5475
rss_star = 1.1680e+003
ne = 551
nrst = 15
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.