
nls_() is an experimental wrapper around the base stats::nls()
function. It behaves similarly to glm(), but enriches the returned object
with additional metadata. The order of the arguments differs from glm(),
and the function uses evaluation through svBase::recall_with_data_dot() to support
the data-dot mechanism.
nls_(data = (.), formula, model = TRUE, ..., .data = data)A data.frame containing the variables in the model.
An object of class formula: a symbolic description of the
model to be fitted.
logical. If true, the model frame is returned as part of the object. Default is FALSE.
Additional arguments passed to stats::nls().
an alias for the data argument
An object of class nls_, which inherits from nls, and includes
additional components such as labels. If no additional attributes are
added, a standard nls object is returned.
chick1 <- ChickWeight[ChickWeight$Chick == 1, ]
# Add labels to variables
attr(chick1$weight, "label") <- "Body weight [gm]"
attr(chick1$Time, "label") <- "Number of days"
chick1_nls <- nls_(data = chick1, weight ~ SSlogis(Time, Asym, xmid, scal))
chick1_nls
#> Nonlinear regression model
#> model: weight ~ SSlogis(Time, Asym, xmid, scal)
#> data: data
#> Asym xmid scal
#> 937.03 35.22 11.41
#> residual sum-of-squares: 76.66
#>
#> Number of iterations to convergence: 0
#> Achieved convergence tolerance: 7.343e-06
class(chick1_nls)
#> [1] "nls_" "nls"
summary(chick1_nls)
#>
#> Formula: weight ~ SSlogis(Time, Asym, xmid, scal)
#>
#> Parameters:
#> Estimate Std. Error t value Pr(>|t|)
#> Asym 937.0300 465.8677 2.011 0.07516 .
#> xmid 35.2230 8.3120 4.238 0.00218 **
#> scal 11.4052 0.9052 12.599 5.08e-07 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 2.919 on 9 degrees of freedom
#>
#> Number of iterations to convergence: 0
#> Achieved convergence tolerance: 7.343e-06
#>
# Access labels
chick1_nls
#> Nonlinear regression model
#> model: weight ~ SSlogis(Time, Asym, xmid, scal)
#> data: data
#> Asym xmid scal
#> 937.03 35.22 11.41
#> residual sum-of-squares: 76.66
#>
#> Number of iterations to convergence: 0
#> Achieved convergence tolerance: 7.343e-06