nls2.myinv - How to Write Programs for Evaluating the Inverse of an nls2 Regression Function
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 the inverse of a regression
function estimated by `nls2'.
The regression function, "f", of a model studied by `nls2'
being defined by:
y=f(x, theta)+epsilon
its inverse (denoted here by "f-1"):
x=f-1(y, theta)+nu
can be evaluated either
by syntax trees - which are built from the file that describes it (see `nls2.inv') -,
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 "calcinvf_".
It calculates the values of "f-1"
on given values of the abscissa x, of the parameters theta, and, possibly of
second level parameters.
It calculates also the derivatives of "f-1" with respect to the parameters theta
and with respect to the ordinate y, and if defined, the variance of y.
SYNTAX:
short int calcinvf_(nbp, nbga, nbl, nbgv, p, ga, ord,
gv, abs, dabsdp, dabsdo, varord, le, ie)
/* input arguments */
short int nbp, nbga, nbl, nbgv;
double *p, *ga,*gv, *ord;
/* output arguments */
double *abs, **dabsdp, *dabsdo, *varord;
short int *le, *ie;
INPUT ARGUMENTS:
- nbp
-
number of parameters theta, i.e the length of
the `paract' declaration of the description-file of "f-1".
- nbga
-
number of the second level parameters that occur in the expression of x,
i.e the length of the `pbisabs' declaration of the description-file of "f-1".
- nbl
-
number of values of the ordinate y
- nbgv
-
number of the second level parameters that occur in the expression of the
variance of y,
i.e the length of the `pbisvar' declaration of the description-file of "f-1".
- p
-
values of the parameters theta;
"nbp" values sorted according to
the `paract' declaration of the description-file of "f-1".
- ga
-
values of the second level parameters that occur in the expression of x;
"nbga" values sorted according
to the `pbisabs' declaration of the description-file of "f-1".
- ord
-
the "nbl" values of y.
- gv
-
values of the second level parameters that occur in the variance of y;
"nbgv" values sorted according to
the `pbisvar' declaration of the description-file of "f-1".
OUTPUT ARGUMENTS:
- abs
-
values of "f-1": "nbl" values.
- dabsdp
-
values of the derivatives of "f-1" with respect to the parameters theta;
"nbl*nbp" values,
sorted first on y, and then on parameters.
- dabsdo
-
values of the derivatives of "f-1" with respect to y;
"nbl" values.
- varord
-
the variance of y;
"nbl" values.
- le
-
when an error occurs, indicates whether this error happens when calculating "abs"
(then "le" should be equal to 1), "varord" (le=2), "dabsdp" or "dabsdo" (le=3),
auxiliary variables (le=6).
- ie
-
when an error occurs, the index of the value of y (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
"mycalcinvf"
(without underscore at the ends of the name).
Type "double" corresponds to "double precision"
and "short int" to "integer".
SEE ALSO:
`calcinvnls2', `calib.nls2', `loadnls2', `nls2.inv'
- Mon Sep 30 1996 -