lsquares_mse SciMax Toolbox lsquares_residuals

SciMax Toolbox >> lsquares_residual_mse

lsquares_residual_mse

Maxima Function

Calling Sequence

lsquares_residual_mse (D, x, e, a)

Description

Returns the residual mean square error (MSE) for the equation e with specified parameters a and data D.

The residual MSE is defined as:

n
====
\                        2
>    (lhs(e ) - rhs(e ))
/           i         i
====
i = 1
--------------------------
           n

where e[i] is the equation e evaluated with the variables in x assigned values from the i-th datum, D[i], and assigning any remaining free variables from a.

load(lsquares) loads this function.

Example:

(%i1) load (lsquares)$
(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]);
                           [ 1  1  1 ]
                           [         ]
                           [ 3       ]
                           [ -  1  2 ]
                           [ 2       ]
                           [         ]
(%o2)                      [ 9       ]
                           [ -  2  1 ]
                           [ 4       ]
                           [         ]
                           [ 3  2  2 ]
                           [         ]
                           [ 2  2  1 ]
(%i3) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]);
                  59        27      10921        107
(%o3)     [[A = - --, B = - --, C = -----, D = - ---]]
                  16        16      1024         32
(%i4) lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a));
                              169
(%o4)                         ----
                              2560
lsquares_mse SciMax Toolbox lsquares_residuals