nlsResiduals: NLS residuals

nlsResidualsR Documentation

NLS residuals

Description

Provides several plots and tests for the analysis of residuals

Usage

  nlsResiduals (nls)
  ## S3 method for class 'nlsResiduals'
 plot(x, which = 0, ...)
  test.nlsResiduals (x)
  ## S3 method for class 'nlsResiduals'
 print(x, ...)

Arguments

nls

an object of class 'nls'

x

an object of class 'nlsResiduals'

which

an integer:
0 = 4 graphs of residuals (types 1, 2, 4 and 6)
1 = non-transformed residuals against fitted values
2 = standardized residuals against fitted values
3 = sqrt of absolute value of standardized residuals against fitted values
4 = auto-correlation residuals (i+1th residual against ith residual)
5 = histogram of the residuals
6 = qq-plot of the residuals

...

further arguments passed to or from other methods

Details

Several plots and tests are proposed to check the validity of the assumptions of the error model based on the analysis of residuals.
The function plot.nlsResiduals proposes several plots of residuals from the nonlinear fit: plot of non-transformed residuals against fitted values, plot of standardized residuals against fitted values, plot of square root of absolute value of standardized residuals against fitted values, auto-correlation plot of residuals (i+1th residual against ith residual), histogram of the non-transformed residuals and normal Q-Q plot of standardized residuals.
test.nlsResiduals tests the normality of the residuals with the Shapiro-Wilk test (shapiro.test in package stats) and the randomness of residuals with the runs test (Siegel and Castellan, 1988). The runs.test function used in nlstools is the one implemented in the package tseries.

Value

nlsResiduals returns a list of five objects:

std95

the Student value for alpha=0.05 (bilateral) and the degree of freedom of the model

resi1

a matrix with fitted values vs. non-transformed residuals

resi2

a matrix with fitted values vs. standardized residuals

resi3

a matrix with fitted values vs. sqrt(abs(standardized residuals))

resi4

a matrix with ith residuals vs. i+1th residuals

Author(s)

Florent Baty, Marie-Laure Delignette-Muller

References

Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK.

Siegel S and Castellan NJ (1988) Non parametric statistics for behavioral sciences. McGraw-Hill international, New York.

Examples

# Plots of residuals
formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * 
                        (VO2rest + (VO2peak - VO2rest) * 
                        (1 - exp(-(t - 5.883) / mu))))
O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, mu = 1), 
               data = O2K)
O2K.res1 <- nlsResiduals(O2K.nls1)
plot(O2K.res1, which = 0)

# Histogram and qq-plot
plot(O2K.res1, which = 5)
plot(O2K.res1, which = 6)
	
# Tests
test.nlsResiduals(O2K.res1)

nlstools documentation built on May 29, 2024, 7:32 a.m.