nlsResiduals | R Documentation |
Provides several plots and tests for the analysis of residuals
nlsResiduals (nls)
## S3 method for class 'nlsResiduals'
plot(x, which = 0, ...)
test.nlsResiduals (x)
## S3 method for class 'nlsResiduals'
print(x, ...)
nls |
an object of class 'nls' |
x |
an object of class 'nlsResiduals' |
which |
an integer: |
... |
further arguments passed to or from other methods |
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
.
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 |
Florent Baty, Marie-Laure Delignette-Muller
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.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.