calcmodnls2 - Evaluate an nls2 Model


On to:
DESCRIPTION
USAGE
REQUIRED-ARGUMENTS
OPTIONAL-ARGUMENTS
VALUE
SIDE-EFFECTS
CONSTRAINTS
REFERENCES
SEE-ALSO
EXAMPLE



DESCRIPTION:

Calculate an `nls2' model and the values of its derivatives with respect to the parameters on given values of the parameters.


USAGE:
calcmodnls2(data, file, 
            func="f",
            theta=NULL, beta=NULL, gamf=NULL, gamv=NULL, 
            response=NULL, d.resp=NULL, 
            FOdes=NULL, d.FOdes=NULL, integ.ctx=NULL) 

REQUIRED ARGUMENTS:
data
the data frame that contains the independent variables and the response; see `nls2'.
file
a character string equal to the pathname of an operating-system file that contains the formal description of the model (see `nls2.model').

Sommaire


OPTIONAL ARGUMENTS:

All the following arguments are required if necessary for evaluating the function requested. They must be omitted otherwise.

func
a character string that specifies which function is to be calculated. Valid values are: "f" (regression function), "v" (variance function), "odes" (regression function when the model is described by an "odes" - "odes" stands for ordinary differential equations system -), and "phi" (regression function on given values of the "odes").
theta
a vector that contains the values of the regression parameters. Its values must be sorted according to the `parresp' declaration of the model description-file. If there are any curves, they must be sorted on curves first.
beta
a vector that contains the values of the variance parameters. Its values must be sorted according to the `parvar' declaration of the model description-file. If there are any curves, they must be sorted on curves first.
gamf
a vector that contains the values of the second level parameters of the regression function (i.e parameters that will not be estimated but are set to a known value). Its values must be sorted according to the `pbisresp' declaration of the model description-file.
gamv
a vector that contains the values of the second level parameters of the variance function. Its values must be sorted according to the `pbisvar' declaration of the model description-file.
response
a vector that contains the values of the response (as many values as observations, not including replications and null-weighted observations, if any). Required only if the argument `func' is "v" and if necessary for the evaluation.
d.resp
a matrix that contains the derivatives of the response with respect to the regression parameters. Required only if the argument `func' is "v" and if it is necessary for the evaluation.
FOdes
the values of the differential equations system (see `nls2.object', component `FOdes'). Required only if the argument `func' is "phi".
d.FOdes
the derivatives of the differential equations system (see `nls2.object', component `d.FOdes'). Required only if the argument `func' is "phi".
integ.ctx
the integration context (see `nls2', argument `integ.ctx').
Always required when the argument `func' is "odes".
When the argument `func' is "phi", can be omitted if the model is evaluated by syntax trees and can be reduced to the "nb.theta.odes" component otherwise.

Sommaire


VALUE:

a list with the following components:
- "response" and "d.resp", when the argument `func' is "f", "phi" or "odes",
- "v", "d.theta.v" and "d.beta.v", when the argument `func' is "v",
- "FOdes" and "d.FOdes", when the argument `func' is "odes".
See `nls2.object' for a description of these components.
When the argument `func' is "v", the returned value corresponds to the variance before it is multiplied by square sigma and weighted.


Sommaire

SIDE EFFECTS:

If no program has been previously loaded to calculate the model (see `loadnls2'), an operating-system file is created which contains the C-programs that correspond to the formal description of the model. If this file already exists, it is replaced.


CONSTRAINTS:

The `loadnls2' function should have been previously called to load into the S-session all the programs necessary for execution.


REFERENCES:

`nls2 Reference Manual'.


SEE ALSO:

Sommaire

EXAMPLE:

Example 1: 
The model is described is in the following file, 
 called "cortisol":

resp f; 
var v;
varind x; 
aux a1,a2; 
parresp n,d,a,b,g; 
pbisresp minf,pinf; 
pbisvar h;
subroutine;
begin 
a1= 1+exp(a+b*x); 
a2= if x==minf then d else 
      if x==pinf then n else 
      n+(d-n)*exp(-g*log(a1))
    fi fi; 
f=a2; 
v=exp(h*log(f));
end 


The commands of the S-session are: # create data: x <- matrix(c( -5.0,-5.0,-5.0,-5.0,-5.0,-5.0,-5.0,-5.0, -1.699,-1.699,-1.699,-1.699,-1.398,-1.398,-1.398,-1.398, -1.222,-1.222,-1.222,-1.222,-1.097,-1.097,-1.097,-1.097, -1.000,-1.000,-1.000,-1.000,-0.699,-0.699,-0.699,-0.699, -0.398,-0.398,-0.398,-0.398,-0.222,-0.222,-0.222,-0.222, -0.097,-0.097,-0.097,-0.097,0.000,0.000,0.000,0.000, 0.176,0.176,0.176,0.176,0.301,0.301,0.301,0.301, 0.602,0.602,0.602,0.602,5.000,5.000,5.000,5.000), ncol=1,byrow=T) f <- c( 2868,2785,2849,2805,2779,2588,2701,2752, 2615,2651,2506,2498,2474,2573,2378,2494, 2152,2307,2101,2216,2114,2052,2016,2030, 1862,1935,1800,1871,1364,1412,1377,1304, 910,919,855,875,702,701,689,696, 586,596,561,562,501,495,478,493, 392,358,399,394,330,351,343,333, 250,261,244,242,131,135,134, 133) data <-data.frame(x,f) # load the programs required: loadnls2() # evaluate the model: f.out <-calcmodnls2(data, file="cortisol", theta=c(130, 3000, 0,1,1), gamf=c(-5,5)) v.out <-calcmodnls2(data, file="cortisol", gamv=c(2.3), response=f.out$response, d.resp=f.out$d.resp, func="v")

Sommaire


- Mon Sep 30 1996 -