welcome to nls2C Site Plan

Subroutine renls2C

Description Syntaxe Arguments Constraints Example


Description:

This function is the equivalent of the functions renls2 and rexnls2 of nls2.

It is intended to process series of non-linear regressions when one or several of the following input are modified at each loop:

For example, it is especially convenient for processing estimations by the method usually called "jackknife", as in the example below: affecting null weight to an observation suppresses it from the analysis.

Syntaxe:

int renls2C(double *ThetaStart, double *BetaStart, 
	    double *GamF, double *GamV,
            double **x,
	    double *y,
	    double *weights,
	    int ip)

Retour au début

Arguments:

All the arguments are input arguments. When one is irrelevant --- i.e the preceeding values are unchanged ---, affect to it the pointer NULL, as in the example below.
The value returned by the function is 0 or a number equal to an error code: See code in the help-file 'nls2.object' of nls2.
ThetaStart:
new initial values for the parameters of the function (parameters "theta").

BetaStart:
new initial values for the parameters of the variance function (parameters "beta").

GamF:
new values for the second-level parameters of the function (parameters "gamf").

GamV:
new values for the second-level parameters of the variance function (parameters "gamv").

x:
new values for independent variables.

y:
new values for the response.

weights:
new values for the weights.

ip:
if equal to 0, all the intermediate print of nls2 are suppressed.

Retour au début

Constraints:

  1. nls2C should be called once before.
  2. The memory cleaning subroutine, delnls2, should not be called between this invokation to nls2C and the last invokation to renls2C.
  3. The number of observations should remain the same during a series of calls:
    - in the invokation to nls2C,
    - in all the subsequent invokations to renls2C.
    In particular, be careful if you change weighting values: the same weight must be affected to all the replications of each observation and remember that a null weight substracts one from the number of observations.

Retour au début

Example:

Here is the reweibull example, you will find in the directory examples of nls2C.
/* ------------------------------------------------------
Example "weibull" of call to renls2C: 
return the successive values of "rss"
by removing one observation each time.
 ----------------------------------------------------------- */


/* +++++++++++++++++++++++++++++++++++++++++++++++++++
 includes 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include "nls2C.h"
/* ------------------------------------------------------------
Calling program
---------------------------------------------------------------*/

int main(argc, argv)
  int argc;
  char *argv[];
{
/* --------  Declarations ------------ */


/* Local variables: */
int n1, code=OK,  b;
long int nobst;
double rss, *weights;


/* First invokation of nls2C: */
if ( (code =nls2C(argv[1])) != 0)
  {
  fprintf(stderr,"Fatal error in nls2C, code %d \n", code);
  exit(code);
  }
rss = recup0D("rss", 1);
printf("Residual sum of squares at the first loop: %g\n", rss);

weights= recup1D("weights",1,&n1);
nobst= recup0L("n.obst", 1);

for (b=1; b <= nobst; b++)
  {
/* The new estimation is realized by call to the function "renls2C": */
    /* At each loop, an observation is removed, the preceeding one
    is taken into account again */
    weights[b-1]=1;
    weights[b]=0;
    code=renls2C((double *)NULL, (double *)NULL, 
	    (double *)NULL, (double *)NULL,
            (double **)NULL,
	    (double *)NULL, weights, 0);

    if (code != (int)OK)
	  {
	    fprintf(stderr,
	"Wrong execution of the loop %d code = %d\n",
	b, code);
	    exit(code);
	  }

	rss = recup0D("rss", 1);
        printf("Residual sum of squares  at loop %d: %g\n", (b+1), rss);
  }
delnls2();

return(0);
}

Retour au début

 


© INRA, 2001-