boot_nls: Bootstrapping for nonlinear models

View source: R/boot_nls.R

boot_nlsR Documentation

Bootstrapping for nonlinear models

Description

Bootstraping for nonlinear models

Usage

boot_nls(
  object,
  f = NULL,
  R = 999,
  psim = 2,
  resid.type = c("resample", "normal", "wild"),
  data = NULL,
  verbose = TRUE,
  ...
)

Arguments

object

object of class nls

f

function to be applied (and bootstrapped), default coef

R

number of bootstrap samples, default 999

psim

simulation level for simulate_nls

resid.type

either “resample”, “normal” or “wild”.

data

optional data argument (useful/needed when data are not in an available environment).

verbose

logical (default TRUE) whether to print a message if model does not converge.

...

additional arguments to be passed to function boot

Details

The residuals can either be generated by resampling with replacement (default or non-parametric), from a normal distribution (parameteric) or by changing their signs (wild). This last one is called “wild bootstrap”. There is more information in boot_lm.

Note

at the moment, when the argument data is used, it is not possible to check that it matches the original data used to fit the model. It will also override the fetching of data.

See Also

Boot

Examples


require(car)
data(barley, package = "nlraa")
## Fit a linear-plateau
fit.nls <- nls(yield ~ SSlinp(NF, a, b, xs), data = barley)

## Bootstrap coefficients by default
## Keeping R small for simplicity, increase R for a more realistic use
fit.nls.bt <- boot_nls(fit.nls, R = 1e2)
## Compute confidence intervals
confint(fit.nls.bt, type = "perc")
## Visualize
hist(fit.nls.bt, 1, ci = "perc", main = "Intercept")
hist(fit.nls.bt, 2, ci = "perc", main = "linear term")
hist(fit.nls.bt, 3, ci = "perc", main = "xs break-point term")



femiguez/nlraa documentation built on Jan. 26, 2024, 9:31 p.m.