nls2.mypsi - How to Write Programs for Evaluating Functions of Parameters Estimated by nls2
On to:
DESCRIPTION
PROGRAM REQUIRED
SYNTAX
INPUT ARGUMENTS
OUTPUT ARGUMENTS
VALUE
OVERFLOWS PROTECTION
FORTRAN PROGRAM
SEE-ALSO
DESCRIPTION:
This entry explains how
to write manually programs for calculating functions of parameters
that have been estimated by `nls2'.
The functions can be evaluated either
by syntax trees - which are built from the file that describes them
(see `nls2.psi') -,
or by a C or Fortran program.
Source files can be generated automatically: see `loadnls2'.
They can also be provided by the user.
Here are described the conventions that must be respected in that case.
PROGRAM REQUIRED:
The program required should be named "calcpsi_".
It calculates the values of the functions and their derivatives with respect to the parameters.
SYNTAX:
short int calcpsi_(nbp, nbg, nbl, nbc, p, g, z, psi, dpsi, le, ie)
/* input arguments */
short int nbp, nbg, nbl, nbc;
double *p, *g, **z;
/* output arguments */
double *psi, **dpsi;
short int *le, *ie;
INPUT ARGUMENTS:
- nbp
-
number of parameters, i.e the length of the
`ppsi' declaration in the formal description-file.
- nbg
-
number of second level parameters, i.e the length of
the `pbispsi' declaration in the formal description-file.
- nbl
-
number of function values;
"nbl" is equal either to the length of
the `psi' declaration in the formal description-file
or to the number of values of the variables introduced
by the `varpsi' declaration in the formal description-file.
- nbc
-
number of variables introduced by
the `varpsi' declaration in the formal description-file.
If no variable, "nbc" is equal to 0.
- p
-
values of the parameters;
"nbp" values sorted according to
the `ppsi' declaration of the formal description-file.
- g
-
values of the second level parameters;
"nbg" values sorted according to the
`pbispsi' declaration of the formal description-file.
- z
-
values of the variables introduced
by the `varpsi' declaration on the formal description-file, if any;
"nbl*nbc" values sorted first on observations,
then according to the declaration.
OUTPUT ARGUMENTS:
- psi
-
values of the functions: "nbl" values.
- dpsi
-
values of the derivatives of the functions with respect to the parameters:
"nbl*nbp" values,
sorted first on functions or observations, and then on parameters.
- le
-
when an error occurs, indicates whether this happens when
calculating the argument `psi'
(then "le" should be equal to 1), "dpsi" (le=3)
or when calculating auxiliary variables (le=6).
- ie
-
when an error occurs, the index of the function or observation (from 1)
where the error happens.
VALUE:
0 if no error occurs
and the value 150 (a conventional error code)
otherwise.
OVERFLOWS PROTECTION:
Protection against overflows and divisions by zero
are ensured by using the following C-functions:
mylog(x) (instead of log10), myln(x) (=log),
mypow(x, y) (=x**y), mydiv(x, y) (=x/y) , myexp(x) (=exp).
The type of the arguments and the returned value is "double".
To use these functions, you should insert the following sentences at the beginning
of your C source-file:
#include <stdio.h>
#include <math.h>
#include "nltypes.h"
#include "nlcodes.h"
#include "nlmacros.h"
#include "nlfonc.h"
FORTRAN PROGRAM:
In the case of Fortran program, the program name should be
"mycalcpsi"
(without underscore at the ends of the name).
Type "double" corresponds to "double precision"
and "short int" to "integer".
SEE ALSO:
`nls2', `calcpsinls2', `ellips.nls2', `wald.nls2', `loadnls2'
- Mon Sep 30 1996 -