boot_nlme: Bootstraping for generalized nonlinear models and nonlinear...

View source: R/boot_nlme.R

boot_nlmeR Documentation

Bootstraping for generalized nonlinear models and nonlinear mixed models

Description

Bootstraping tools for nonlinear models using a consistent interface

bootstrap function for objects of class gnls

Usage

boot_nlme(
  object,
  f = NULL,
  R = 999,
  psim = 1,
  cores = 1L,
  data = NULL,
  verbose = TRUE,
  ...
)

boot_gnls(
  object,
  f = NULL,
  R = 999,
  psim = 1,
  cores = 1L,
  data = NULL,
  verbose = TRUE,
  ...
)

Arguments

object

object of class nlme or gnls

f

function to be applied (and bootstrapped), default coef (gnls) or fixef (nlme)

R

number of bootstrap samples, default 999

psim

simulation level for vector of fixed parameters either for simulate_gnls or simulate_nlme_one

cores

number of cores to use for parallel computation

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

This function is inspired by Boot, which does not seem to work with 'gnls' or 'nlme' objects. This function makes multiple copies of the original data, so it can be very hungry in terms of memory use, but I do not believe this to be a big problem given the models we typically fit.

Examples


require(car)
require(nlme)
data(barley, package = "nlraa")
barley2 <- subset(barley, year < 1974)
fit.lp.gnls2 <- gnls(yield ~ SSlinp(NF, a, b, xs), data = barley2)
barley2$year.f <- as.factor(barley2$year)
cfs <- coef(fit.lp.gnls2)
fit.lp.gnls3 <- update(fit.lp.gnls2, 
                      params = list(a + b + xs ~ year.f),
                      start = c(cfs[1], 0, 0, 0, 
                                cfs[2], 0, 0, 0,
                                cfs[3], 0, 0, 0))
## This will take a few seconds                               
fit.lp.gnls.Bt3 <- boot_nlme(fit.lp.gnls3, R = 300) 
confint(fit.lp.gnls.Bt3, type = "perc")



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