Contents | Previous | Next | Subchapters |

Syntax |
`relative(function ` y`, function ` F`, function ` dF`, ...` M`, ` xin`, ` xlow`, ` xup`, ` eps`, ` maxstp`, ` mitr`, ...` xout`, ` vout`, ` Rout`, ` gout`, ` lamout`, ` Cout`)` |

See Also | nlsq , dnlsq |

Uses a modified version of the Gauss-Newton method to solve the extended least squares problem

*M* 2

----- | *y*(*i*) - *F*(*i*, *x*) |

minimize > *N* *log*(*v* ) + ------------------ with respect to (*v*, *x*)

----- *i* *i* *v*

*i* = 1 *i*

such that *xlow* __<__ *x* __<__ *xup*

*j* *j* *j*

This is the maximum likelihood estimator for `(`*v*, *x*)

if there is a true, but unknown, value for `(`*v*, *x*)

such that for each *i*

the elements of the data vector *y*(*i*)

are independent
normally distributed with mean *F*(*i*, *x*)

and variance
*v*(*i*)

.
This estimator and the algorithm used by `relative`

are
discussed in the paper

The return value of `relative`

is true if convergence is achieved
and false otherwise.

`(`

`)`

Returns the value *y*(*i*)

as a column vector with the
same type as

`(`

`, `

`)`

Returns the value *F*(*i*, *x*)

as a column vector with the
same type and dimension as *y*(*i*)

,
where

`(`

`, `

`)`

The derivatives of *F*(*i*, *x*)

with respect to *x*

as a column vector with the same type and row dimension as *y*(*i*)

.
The column dimension of *dF*(*i*, *x*)

is equal to the row dimension of
*dF*(*i*, *x*)

is the partial derivative of the *F*(*i*, *x*)

with respect to the *x*

.

The integer scalar *xlow*(*j*) __<__ *x*(*j*) __<__ *xup*(*j*)

must hold for each *j*

.
The column vector *x*

in the extended least squares problem.
The column vector *x*

in the extended least squares problem.
The column vector *x*

is less than or equal *eps*(*j*)

for all *j*

.
All of the elements of *maxstp*(*j*)

is the maximum absolute change allowed in the *x*

between iterations of the algorithm.
All of the elements of

The input value of *x*

at the *v*

that is optimal for the current
*x*

.)
The input value of *x*

at the *lamout*(*k*)

is the line search parameter
that corresponds to the difference between the *x*

as an estimate of the true parameter vector.
The relative weighting algorithm should be used when data sets have different variances. The program below simulates two data sets, each with its own time grid. The first data set has a standard error of .1 and the second has a standard error of .01. The model for the data has three parameters and is

2

*x* + *x* *t* + *x* *t*

1 2 3

The simulation is done using the true, but unknown during fitting,
values of the elements of *x*

which are all 1.
The true value of *x*

and *v*

are
`{1, 1, 1}`

and `{.01, .0001}`

respectively.
These values are approximated by
the values of *x*

and *v*

that solve the
minimization problem.
```
```

clear

#

# simulate data set 1

t1 = seq(100) / 100.

y1 = 1. + t1 + t1^2 + .1 * snormal(100, 1)

#

# simulate data set 2

t2 = seq(10) / 10.

y2 = 1. + t2 + t2^2 + .01 * snormal(10, 1)

#

function y(i) begin

global y1, y2

if i == 1 then ...

return y1

else return y2

end

#

function F(i, x) begin

global t1, t2

if i == 1 then ...

return x(1) + x(2) * t1 + x(3) * t1^2

else return x(1) + x(2) * t2 + x(3) * t2^2

end

#

function dF(i, x) begin

global t1, t2

if i == 1 then ...

return [ones(rowdim(t1), 1), t1, t1^2]

else return [ones(rowdim(t2), 1), t2, t2^2]

end

#

M = 2

xin = {.5, .5, .5}

xlow = {0., 0., 0.}

xup = {10., 10., 10.}

eps = {1e-3, 1e-3, 1e-3}

maxstp = {1., 1., 1.}

mitr = 10

xout = novalue

vout = novalue

Rout = novalue

gout = novalue

lamout = novalue

Cout = novalue

relative(function y, function F, function dF, ...

M, xin, xlow, xup, eps, maxstp, mitr, ...

xout, vout, Rout, gout, lamout, Cout )

#

print "minimizing x =", xout.col(coldim(xout))

print "minimizing v =", vout.col(coldim(vout))