The R package nlstools : a toolbox for nonlinear regression Florent Baty Sandrine Charles Jean-Pierre Flandrois Marie-Laure Delignette-Muller Pneumologie & Interdisziplinäres Zentrum für Schl afmed izi n 10/07/2009 Florent Baty (KSSG) R package nlstools 10/07/2009 1 / 17
Introduction Increasing interest for nonlinear regression ◮ Chemistry ◮ Agricultural science ◮ Pharmacology ◮ Microbiology Diversity of tools available in R (Ritz & Streibig, 2008) Florent Baty (KSSG) R package nlstools 10/07/2009 2 / 17
Introduction Many users still reluctant in using nonlinear regression ◮ Complexity of the least-squares minimization procedure algorithms ◮ Definition of starting values ◮ Validity of the error model ◮ Confidence region estimation nlstools ◮ A toolbox which helps the fit of gaussian nonlinear models and assess its quality of fit y i = f ( x i , θ ) + ǫ i , ǫ i ∼ N (0 , σ ) (1) ◮ Available on CRAN Florent Baty (KSSG) R package nlstools 10/07/2009 3 / 17
Overview of nlstools Main features of nlstools Extended summary Validity of the error model Resampling Help for nls Bootstrapping the fit Jackknifing Parameters’ confidence regions Collection of models and data sets Florent Baty (KSSG) R package nlstools 10/07/2009 4 / 17
Help of fit: preview Estimation of starting values by iterative ”manual” fitting > preview (formula, data, start, variable = 1) + + + + ● ● ● ● + + + + ● + + ● 8.5 lag = 40 ● 8.5 lag = 50 ● mumax = 0.1 mumax = 0.08 + + ● ● LOG10N0 = 6 LOG10N0 = 6 + + 8.0 8.0 LOG10Nmax = 8.8 ● LOG10Nmax = 8.8 ● + Predicted + Predicted 7.5 7.5 ● + ● + ● ● 7.0 7.0 + ● ● + + 6.5 6.5 ● ● + + + ● ● 6.0 + + 6.0 + ● + + + ● RSS = 3.1 RSS = 0.3 ● ● ● ● ● ● 0 50 100 150 0 50 100 150 t t Florent Baty (KSSG) R package nlstools 10/07/2009 5 / 17
Help of fit: preview Models with non-meaningful parameters (Ratkowsky) µ max = b ( pH − pH min )(1 − exp ( c ( pH − pH max ))) 2 (2) + ● b = 10 RSS = 2.02 b = 16 RSS = 0.07 1.0 c = 0.01 c = 0.03 ● 0.8 pHmin=4 pHmin=4 ● ● pHmax=10 pHmax=10 + + ● 0.8 ● 0.6 Predicted Predicted 0.6 0.4 0.4 + ● + ● ● ● 0.2 + ● ● 0.2 + + ● ● + + + + + ++ ++++ + ++++++ 0.0 0.0 ++ + + ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 5 6 7 8 9 10 4 5 6 7 8 9 10 pH pH Florent Baty (KSSG) R package nlstools 10/07/2009 6 / 17
Fit: nls Central function > nls (formula, data, start, ...) nlstools requires objects of class ’nls’ Florent Baty (KSSG) R package nlstools 10/07/2009 7 / 17
Fit summary: plotfit, overview Extended summary of fit > plotfit (nls) > overview (nls) ● ● ● 8.5 ● ● Formula 8.0 ● Parameters estimates and 7.5 ● LOG10N standard error ● 7.0 Residual sum of squares ● ● 6.5 Asymptotic confidence intervals ● 6.0 Parameters correlation matrix ● ● ● ● 0 50 100 150 t Florent Baty (KSSG) R package nlstools 10/07/2009 8 / 17
Error model: nlsResiduals, test.nlsResiduals Residuals analysis: validation of the error model > plot(nlsResiduals(nls)) > test.nlsResiduals(nlsResiduals(nls)) Residuals Standardized Residuals 0.10 ● 2 Standardized residuals ● ● ● ● ● ● ● 1 Residuals ● ● ● ● 0.00 ● ● ● ● 0 ● ● ● ● ● ● ● ● −1 ● ● ● −0.10 ● ● −2 ● Normality test: 6.0 6.5 7.0 7.5 8.0 8.5 6.0 6.5 7.0 7.5 8.0 8.5 Fitted values Fitted values ◮ Shapiro-Wilk Normal Q−Q Plot of Test of independence: Autocorrelation Standardized Residuals 0.10 ● ● ◮ Runs test ● ● ● ● Sample Quantiles ● Residuals i+1 0.5 ● ● ● ● ● ● 0.00 ● ● ● ● ● ● −0.5 ● ● ● ● −0.10 ● ● ● ● −1.5 ● ● −0.10 −0.05 0.00 0.05 0.10 −1 0 1 Residuals i Theoretical Quantiles Florent Baty (KSSG) R package nlstools 10/07/2009 9 / 17
Recommend
More recommend