bootstrap.nls2(nls2.object, method="param", wanted=list(pStar=T,var.pStar=T, sigma2Star=T, psiStar=T, var.psiStar=T, tStar=T,conf.int=T, YStar=F,SStar=F), n.loops=119, conf.level=0.95, file=NULL, pbispsi=c(nls2.object$model$gamf,nls2.object$model$gamv), varpsi=NULL, ord=NULL)
VALUE:
A list with the following components:
SIDE EFFECTS:
- The printed output are ruled by the argument
control used in the first call to nls2.
Use the value control=list(freq=0) when creating the
nls2.object to suppress
the default printed output of bootstrap.
- When the argument `method' is "param" or "wild.1",
the side-effects of "rnorm()",
and, when it is "wild.2", the side-effects of "rbinom()".
- If a function is provided and
no program loaded to calculate it
(see `loadnls2'),
an operating-system file is created which contains the C-program
that corresponds to its formal description.
If this file already exists, it is replaced.
DETAILS:
- THE ARGUMENT method:
Pseudo-observations, YStar, are generated according
to the argument `method':
Let response, variance, residuals and s.residuals be
the last fitted values of the response,
variance, residuals and standardized residuals in the `nls2.object'.
- if method="param", pseudo-errors, pse, are randomly generated as a
sample of the centered normal
distribution with standard deviation equal to 1.
Then, YStar=response + sqrt(variance)*pse
- if method="residuals", the pseudo-errors are randomly generated among
"residuals - mean(residuals)".
Then, YStar=response + pse
- if method="s.residuals", the pseudo-errors are randomly generated among
"s.residuals -mean(s.residuals)".
Then, YStar=response + sqrt(variance)*pse
- if method="wild.1", two samples Z1 and Z2 of the centered normal
distribution with standard deviation equal to 1
are generated. The pseudo-errors are:
pse=residuals * (Z1/sqrt(2) + (Z2**2-1)/2))
Then, YStar=response + pse
- if method="wild.2", a sample Z of a binomial
distribution with probability (5+sqrt(5))/10 of success
is generated.
The pseudo-errors are:
pse[Z==1] = residuals[Z==1] * (1-sqrt(5))/2
pse[Z==0] = residuals[Z==0] * (1+sqrt(5))/2
- if method="calib", see below.
Methods of user's choice can be added by modifying the function
"generbootnls2":
see comments included in the source of the function bootstrap.nls2.
- THE QUANTITY tStar AND THE CONFIDENCE INTERVAL conf.int:
Let pact be the last estimated values of the parameters in the
`nls2.object', psi the value of the function of parameters at pact,
and var.psi its variance.
The quantity tStar:
For each value of "psiStar", the variance var.psiStar is calculated
and then:
tStar= (psiStar-psi)/sqrt(var.psiStar)
The confidence interval:
Let b1, b2, the smallest integers such as
b1/n.loops is greater or equal to "(1-conf.level)/2"
and b2/n.loops is greater or equal to "(1+conf.level)/2".
Let tStar0 be the ascending ordered values of "tStar".
Then, the bounds of the confidence interval are:
psi-sqrt(var.psi)*tStar0[b1], and
psi-sqrt(var.psi)*tStar0[b2]
Note that the loops where the convergence has not been correctly reached
are not taken into account.
- THE METHOD calib AND THE QUANTITIES YStar, SStar, conf.bounds:
A function must be provided
and it is assumed that it describes the regression model.
An additional "pbispsi" must be declared which represents
the independent variable to be calibrated.
At each loop, (n+m) pseudo-observations YStar are
generated: the n first ones are generated
with method="residuals" and the
m last ones are equal to:
ZStar=mean(ord)+pse,
pse being randomly generated among
"residuals - mean(residuals)".
The value of the independent variable for these m observations
is the value of the additional "pbispsi".
(In general, this value is the estimator of the independent
variable returned by the function `calib.nls2':
see the paragraph `EXAMPLE-3')
Estimation is carried on with these (n+m) observations
and the residuals, called here residualsStar, are calculated.
Then, the quantities SStar are calculated so:
S=sum(residualsStar^2)
A= sqrt(S) * sqrt(1/m + var.psiStar/sigma2Star)
SStar=(sqrt(n+m) * (mean(ZStar)- f(pbispsi, pStar)))/A
At the end of the iterative process, the values of SStar are sorted.
SStar[b1] and SStar[b2] are returned in
the component `conf.bounds',
b1 and b2 been calculated as above.
Note that the loops where the convergence has not been correctly reached
are not taken into account.
For statistical explanations about
the method "calib", see the paragraph `REFERENCES'.
CONSTRAINTS:
- Do not invoke functions `loadnls2' nor `delnls2' between the "nls2.object"
creation and a call to "bootstrap".
- When functions of parameters are provided,
only one function and at most one value of the variables "varpsi"
are allowed and the function `loadnls2', argument `psi' not NULL,
should have been previously called.
- When the argument `method' is "calib",
the data frame containing the observations,
(its name is nls2.object$call$data), must be available.
It is then assumed that this data frame has been neither deleted nor
modified since the nls2.object was created.
It must not include curves and have a single independent variable.
- When the argument `method' is "calib",
the model is assumed to be described in the file whose
name appears in `nls2.object', component `model'.
The variance must be constant.
NOTE:
This function is a method for the generic function `bootstrap'
for class `nls2'.
It can be invoked by calling `bootstrap' for an object of the appropriate
class, or directly by calling `bootstrap.nls2' regardless of the
class of the object.
SEE ALSO:
EXAMPLE-1:
No function of parameters is provided: only the values
of "pStar" and "var.pStar" are calculated.
# Creation of the nls2.object with option renls2=T:
r_nls2(data,model,stat.ctx,control=list(freq=0),renls2=T)
# remark: "freq=0" prevents the intermediary results from
# being printed at each estimation.
z_ bootstrap(r)
EXAMPLE-2:
A function of parameters is provided.
It is described in a file called "Func.d".
r_nls2(data,model,stat.ctx,control=list(freq=0),renls2=T)
z_bootstrap(r, file="Func.d", method="residuals", n.loops=30)
EXAMPLE-3:
Use of method "calib":
A function is provided that describes the regression function,
the independent variable been considered as an additional "pbispsi".
It is described in the following file "Calib.d":
model cortisol with variance constant
The original model description file has been modified:
"resp" has been replaced by "psi",
"parresp" by "ppsi",
"pbisresp" by "pbispsi",
"varind"-list placed at the end of "pbispsi" and then removed.
psi f;
ppsi n,d,a,b,g;
pbispsi minf,pinf, x;
aux a1, a2;
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;
end
Function "bootstrap" is invoked:
out_bootstrap(nls2.out.cst,
method="calib",
ord=c(1500,1600),
file="Calib.d",
pbispsi=c(-5,5, calib.out$x))