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)
OPTIONAL ARGUMENTS:
All the following arguments are required if necessary for
evaluating the function requested. They must be omitted otherwise.
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.
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:
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")