welcome to nls2C | Site Plan |
Subroutines of nls2C |
---|
Available subroutines to:
estimate | access results | specific print | global print | create a file for SPlus/R |
replicate data | free memory | cut the estimation process |
See also:
how to write the calling program | how to process series of non-linear regressions. |
You can also access intermediate results: See their syntax, list, an example of use.
Syntax of the access subroutines:
When values has not been calculated, for numerical or other reasons,
they are arbitraly set to DBL_MAX, (generally 1.79E+308)
a value
you find in the standard C file "float.h" on your site.
In all of these subroutines:
See the help-file
'nls2.object' of nls2,
as to the statistical meaning of the returned
structure.
List of the access subroutines:
Note:
as.var and correl are returned in dimension
multot x multot,
multot been the total number of parameters.
Example of use of an access subroutine:
Access to intermediate structures
Syntax of the intermediate structures access subroutines:
List of the intermediate structures access subroutines:
Example of use of an intermediate structures access subroutine:
List of the subroutines:
Examples:
List of these subroutines:
Syntax:
Arguments:
Example:
Example:
The file simul.main.c.
The name and syntax of the access subroutines depend
on the type of the returned result,
long int, character string
or double,
and on their structure, scalar or multidimensional.
In case of a multidimensional result, you do not have to allocate the
target structure: a pointer to the internal data-structures
of a nls2 is returned.
The access subroutines and
the valid values for their first
argument, *name, are:
When the model is described by an "odes":
ci.odes (1 if the initial conditions are parameters, 0 otherwise),
x.odes (1 if the observations appear in the "odes" equations),
n.times (number of time values, it is integration for),
n.eq.odes (number of equations in the "odes"),
n.theta.odes (number of parameters in the "odes"),
lg.odes (length of the "odes").
b.varz.b and w are returned in dimension
acttot x acttot, i.e the number of active parameters
(the parameters set to a numerical constraint or equal to
another one are not included).
b and d are returned in dimension
number of sufficient statistics Z
x acttot.
/* Declaration of the target structure: */
double statcrit;
...
nls2C("myfile");
statcrit=recup0D("stat.crit", 1);
printf("\n*** stat.crit value: %g ***\n");
The intermediate
saved structures have one dimension more:
their first dimension is equal to the number of
saved iterations, nitsv.
To access the intermediate structures, the subroutines are:
/* Declaration of the target structure and subroutine argument: */
double *statcrit;
int nitsv;
...
nls2C("myfile");
statcrit=recupIt1D("stat.crit", 1, &nitsv);
printf("\n*** stat.crit values ***\n");
for (i=0; i< nitsv; i++)
{
printf(" Iteration %d: ", i);
printf("%10g ", statcrit[i]);
printf("\n");
}
printf("\n");
}
Some subroutines are provided to print multi-dimensional results.
Syntax:
The names of the subroutines and their syntax depend on the type of
structure to print, but for all of them:
/* Declaration of the target structure and subroutines arguments: */
double **dresp;
int n1, n2;
...
dresp = recup2D("d.resp", 1, &n1, &n2);
pr2D(stdout, dresp, n1, n2);
Some subroutines print the whole of
a nls2 structure.
Syntax
They have one input argument, only:
a pointer to a file
opened in write mode, the print unit.
Two subroutines generate files with
SPlus
(or R)
commands.
- splus2C
allows to create a structure
which contains the results,
- splusData
allows to create a data-frame which contains the observations.
The created structures are compatible with nls2.
int splus2C( char *name , char *dataname, FILE *file);
int splusData( char *name , FILE *file);
Then,
in a Splus (R) session, type in:
source("filename")
where filename is the name of the file.
/* ------- Declarations ------------ */
int code;
FILE *filesplus;
/* ------- Call nls2C ------------ */
/* The name of the input-file is the first argument of the
executable command */
if ( (code =nls2C(argv[1])) != 0)
{
fprintf(stderr,"Fatal error in nls2C, code %d \n", code);
exit(code);
}
/* Create a splus file for Splus */
if ( (int)(filesplus=fopen("SPLUSFILE", "w")) == NULL)
{
printf("Cannot open the output splus-file \n");
return(ERRINPUT);
}
/* ------- Call splus2C ------------ */
if ((code= splus2C("mynls2.object" , filesplus)) != OK)
{
printf("Error in 'splus2C'\n");
return(ERRINPUT);
}
In a Splus (R) session, the command:
source("SPLUSFILE")
creates the nls2.object named mynls2.object.
- datan: pointer to the structure in dimension
n (output argument).
long int nobst;
int k;
double *fk, *fn;
...
fk = recup1D("fitted",1, &k);
nobst= recup0L("n.obst", 1);
fn=(double *) calloc (nobst, sizeof (double));
rep2C(fk, fn);
Instead of executing estimation in one "black box",
you can process by steps: initialization of
the nls2 structures, read input,
estimate the parameters, and,
eventually, clean memory.
int init2C();
int lect2C(char *filein);
filein is the pathname
of the input file.
int go2C();
void delnls2();
Each of the following subroutines returns
0 or an error code;
A positive value means that there is an error
in the estimation process
(see code in the
the help-file
'nls2.object' of nls2).
A negative value means that there is an error in your
input.
©
INRA, 2001-