nlsList.Rd
Data
is partitioned according to the levels of the grouping
factor defined in model
and individual nls
fits are
obtained for each data
partition, using the model defined in
model
.
nlsList(model, data, start, control, level, subset,
na.action = na.fail, pool = TRUE, warn.nls = NA)
# S3 method for class 'formula'
nlsList(model, data, start, control, level, subset,
na.action = na.fail, pool = TRUE, warn.nls = NA)
# S3 method for class 'nlsList'
update(object, model., ..., evaluate = TRUE)
an object inheriting from class nlsList
, representing
a list of fitted nls
objects.
either a nonlinear model formula, with the response on
the left of a ~
operator and an expression involving
parameters, covariates, and a grouping factor separated by the
|
operator on the right, or a selfStart
function. The
method function nlsList.selfStart
is documented separately.
changes to the model – see update.formula
for details.
a data frame in which to interpret the variables named in
model
.
an optional named list with initial values for the
parameters to be estimated in model
. It is passed as the
start
argument to each nls
call and is required when
the nonlinear function in model
does not inherit from class
selfStart
.
a list of control values passed as the control
argument to nls
. Defaults to an empty list.
an optional integer specifying the level of grouping to be used when multiple nested levels of grouping are present.
an optional expression indicating the subset of the rows of
data
that should be used in the fit. This can be a logical
vector, or a numeric vector indicating which observation numbers are
to be included, or a character vector of the row names to be
included. All observations are included by default.
a function that indicates what should happen when the
data contain NA
s. The default action (na.fail
) causes
nlsList
to print an error message and terminate if there are any
incomplete observations.
an optional logical value that is preserved as an attribute of the
returned value. This will be used as the default for pool
in
calculations of standard deviations or standard errors for summaries.
logical
indicating if nls()
errors (all of which are caught by tryCatch
) should be
signalled as a “summarizing” warning
.
some methods for this generic require additional arguments. None are used in this method.
If TRUE
evaluate the new call else return the call.
As nls(.)
is called on each sub group, and convergence
of these may be problematic, these calls happen with error catching.
Since nlme version 3.1-127
(2016-04), all the errors are
caught (via tryCatch
) and if present, a “summarizing”
warning
is stored as attribute of the resulting
"nlsList"
object and signalled unless suppressed by
warn.nls = FALSE
or currently also when warn.nls = NA
(default) and getOption("show.error.messages")
is
false.
nlsList()
originally had used try(*)
(with its default
silent=FALSE)
and hence all errors were printed to the console
unless the global option show.error.messages
was set to true.
This still works, but has been deprecated.
a list of nls
objects with as many components as the number of
groups defined by the grouping factor. Generic functions such as
coef
, fixed.effects
, lme
, pairs
,
plot
, predict
, random.effects
, summary
,
and update
have methods that can be applied to an nlsList
object.
Pinheiro, J.C., and Bates, D.M. (2000), Mixed-Effects Models in S and S-PLUS, Springer.
fm1 <- nlsList(uptake ~ SSasympOff(conc, Asym, lrc, c0),
data = CO2, start = c(Asym = 30, lrc = -4.5, c0 = 52))
summary(fm1)
#> Call:
#> Model: uptake ~ SSasympOff(conc, Asym, lrc, c0) | Plant
#> Data: CO2
#>
#> Coefficients:
#> Asym
#> Estimate Std. Error t value Pr(>|t|)
#> Qn1 38.13977 0.9911148 38.48169 1.991990e-06
#> Qn2 42.87169 1.0932089 39.21638 2.583953e-06
#> Qn3 44.22800 1.0241029 43.18706 1.809264e-07
#> Qc1 36.42874 1.1941594 30.50576 1.140085e-05
#> Qc3 40.68373 1.2480923 32.59673 1.424635e-04
#> Qc2 39.81950 1.0167249 39.16447 2.692304e-06
#> Mn3 28.48286 1.0624246 26.80930 1.066434e-06
#> Mn2 32.12827 1.0174826 31.57624 3.488786e-06
#> Mn1 34.08482 1.3400596 25.43530 4.199333e-06
#> Mc2 13.55519 1.0506404 12.90184 4.385886e-06
#> Mc3 18.53506 0.8363371 22.16219 1.461563e-06
#> Mc1 21.78723 1.4113318 15.43735 5.756870e-06
#> lrc
#> Estimate Std. Error t value Pr(>|t|)
#> Qn1 -4.380644 0.2208028 -19.839619 2.789830e-05
#> Qn2 -4.665729 0.1581312 -29.505433 8.036962e-06
#> Qn3 -4.486118 0.1698748 -26.408377 1.291542e-06
#> Qc1 -4.861743 0.2124536 -22.883790 3.574865e-05
#> Qc3 -4.945224 0.1794899 -27.551544 2.755565e-04
#> Qc2 -4.463838 0.1564976 -28.523374 9.531807e-06
#> Mn3 -4.591568 0.2690656 -17.064866 6.469560e-06
#> Mn2 -4.466159 0.2330265 -19.165888 2.548156e-05
#> Mn1 -5.064581 0.2069979 -24.466818 4.902553e-06
#> Mc2 -4.560837 0.8205919 -5.557985 1.242261e-04
#> Mc3 -3.465154 1.2239549 -2.831113 4.548635e-03
#> Mc1 -5.142254 0.4475241 -11.490451 1.865741e-05
#> c0
#> Estimate Std. Error t value Pr(>|t|)
#> Qn1 51.22339 12.621415 4.0584503 0.0117881705
#> Qn2 55.85812 9.998223 5.5868047 0.0051398910
#> Qn3 54.64957 9.814189 5.5684251 0.0006120973
#> Qc1 31.07523 18.988562 1.6365238 0.2228656247
#> Qc3 35.08849 15.994855 2.1937360 0.3930978982
#> Qc2 72.09421 6.924937 10.4108111 0.0005089520
#> Mn3 46.97175 18.133617 2.5903133 0.0092921369
#> Mn2 56.03854 13.055059 4.2924772 0.0079487725
#> Mn1 36.40792 19.079715 1.9082002 0.0606748414
#> Mc2 13.05797 78.005843 0.1673973 0.6806034305
#> Mc3 67.84888 33.737248 2.0110971 0.0150825859
#> Mc1 -20.39979 62.466416 -0.3265722 0.5367855446
#>
#> Residual standard error: 1.79822 on 48 degrees of freedom
#>
cfm1 <- confint(fm1) # via profiling each % FIXME: only *one* message instead of one *each*
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
mat.class <- class(matrix(1)) # ("matrix", "array") for R >= 4.0.0; ("matrix" in older R)
i.ok <- which(vapply(cfm1,
function(r) identical(class(r), mat.class), NA))
stopifnot(length(i.ok) > 0, !anyNA(match(c(2:4, 6:9, 12), i.ok)))
## where as (some of) the others gave errors during profile re-fitting :
str(cfm1[- i.ok])
#> List of 4
#> $ Qn1: logi [1:2] NA NA
#> ..- attr(*, "errMsg")= chr "NA/NaN/Inf in foreign function call (arg 1)"
#> $ Qc3: logi [1:2] NA NA
#> ..- attr(*, "errMsg")= chr "step factor 0.000488281 reduced below 'minFactor' of 0.000976562"
#> $ Mc2: logi [1:2] NA NA
#> ..- attr(*, "errMsg")= chr "NA/NaN/Inf in foreign function call (arg 1)"
#> $ Mc3: logi [1:2] NA NA
#> ..- attr(*, "errMsg")= chr "singular gradient"