Learn R Programming

statforbiology (version 0.9.9)

boxcox.nls: Transform-both-sides (TBS) method for nonlinear regression

Description

Finds the optimal Box-Cox transformation for non-linear regression models.

Usage

# S3 method for nls
boxcox(object, lambda = seq(-2, 2, 1/10), plotit = TRUE, 
             start, eps = 1/50, bcAdd = 0, level = 0.95, 
             xlab = expression(lambda), ylab = "log-likelihood", ...)
  # S3 method for nlsbc
summary(object, ...)

Value

An object of class nls (returned invisibly). If plotit = TRUE a plot of loglik vs lambda is shown indicating a confidence interval (by default 95%) about the optimal lambda value.

Arguments

object

object of class nls. For bcSummary the nls fit should have been obtained using boxcox.nls

lambda

numeric vector of lambda values; the default is (-2, 2) in steps of 0.1.

plotit

logical which controls whether the result should be plotted.

start

a list of starting values (optional).

eps

numeric value: the tolerance for lambda = 0; defaults to 0.02.

bcAdd

numeric value specifying the constant to be added on both sides prior to Box-Cox transformation. The default is 0.

level

numeric value: the confidence level required.

xlab

character string: the label on the x axis, defaults to "lambda".

ylab

character string: the label on the y axis, defaults to "log-likelihood".

...

additional graphical parameters.

Author

Christian Ritz, modified by Andrea Onofri

Details

boxcox.nls is very similar to the boxcox in its arguments. The optimal lambda value is determined using a profile likelihood approach: For each lambda value the non-linear regression model is fitted and the lambda value resulting in thre largest value of the log likelihood function is picked. If a self starter model was used in the model fit, then gradient information will be used in the profiling.

References

Carroll, R. J. and Ruppert, D. (1988) Transformation and Weighting in Regression, New York: Chapman and Hall (Chapter 4).

See Also

For linear regression the analogue is boxcox.

Examples

Run this code
## Fitting log-logistic model without transformation
ryegrass.m1 <- nls(rootl ~ NLS.L4(conc, b, c, d, e), 
                 data=ryegrass)
summary(ryegrass.m1)

## Fitting the same model with optimal Box-Cox transformation
ryegrass.m2 <- boxcox(ryegrass.m1, plotit = TRUE)
summary(ryegrass.m2)

Run the code above in your browser using DataLab