From d22b068d86fee1f1aa2e0a61abc01e07ffb23422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien?= Date: Tue, 17 Apr 2018 12:38:50 +0200 Subject: [PATCH 1/2] Re-write Documentation to Roxygen2 - Everything as Roxygen - Modify README.md to README.Rmd to allow to knit some working examples - Move NEWS to root for pkgdown site - Update NAMESPACE and Rd files automatically --- .Rbuildignore | 3 + .gitignore | 1 + ChangeLog | 98 ------ DESCRIPTION | 42 ++- LICENSE.md | 595 +++++++++++++++++++++++++++++++++++++ NAMESPACE | 152 ++++------ inst/NEWS => NEWS.md | 6 +- R/confint2.R | 34 +++ R/data.R | 60 ++++ R/michaelismodels.R | 75 ++++- R/nlsBoot.R | 75 ++++- R/nlsConfRegions.R | 68 ++++- R/nlsContourRSS.R | 71 ++++- R/nlsJack.R | 73 ++++- R/nlsResiduals.R | 91 +++++- R/nlstools-defunct.R | 47 +++ R/nlstools-package.R | 8 + R/nlstools.R | 80 ++++- README.Rmd | 41 +++ README.md | 30 +- man/L.minor.Rd | 59 ++-- man/O2K.Rd | 39 ++- man/confint2.Rd | 105 ++++--- man/michaelis.Rd | 92 ++++++ man/michaelisdata.Rd | 35 --- man/michaelismodels.Rd | 80 ----- man/nlsBoot.Rd | 111 ++++--- man/nlsConfRegions.Rd | 101 ++++--- man/nlsContourRSS.Rd | 107 ++++--- man/nlsJack.Rd | 97 +++--- man/nlsResiduals.Rd | 107 +++---- man/nlstools-defunct.Rd | 82 ----- man/nlstools-deprecated.Rd | 48 +++ man/nlstools-package.Rd | 36 +++ man/nlstools.Rd | 71 ----- man/preview.Rd | 106 +++++++ man/vmkm.Rd | 34 +++ nlstools.Rproj | 20 ++ 38 files changed, 2129 insertions(+), 851 deletions(-) delete mode 100644 ChangeLog create mode 100644 LICENSE.md rename inst/NEWS => NEWS.md (93%) create mode 100644 R/data.R create mode 100644 R/nlstools-defunct.R create mode 100644 R/nlstools-package.R create mode 100644 README.Rmd create mode 100644 man/michaelis.Rd delete mode 100644 man/michaelisdata.Rd delete mode 100644 man/michaelismodels.Rd delete mode 100644 man/nlstools-defunct.Rd create mode 100644 man/nlstools-deprecated.Rd create mode 100644 man/nlstools-package.Rd delete mode 100644 man/nlstools.Rd create mode 100644 man/preview.Rd create mode 100644 man/vmkm.Rd create mode 100644 nlstools.Rproj diff --git a/.Rbuildignore b/.Rbuildignore index 3912071..711c0fa 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,6 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +^LICENSE\.md$ +Tests_* ^\.github$ +^README\.Rmd$ diff --git a/.gitignore b/.gitignore index 8364ade..b9183bf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .Rhistory .RData .Ruserdata +Tests_* diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 50289a3..0000000 --- a/ChangeLog +++ /dev/null @@ -1,98 +0,0 @@ -2015-07-31 08:09 baty - * Updated citation for the nlstools package - -2015-02-26 09:50 baty - * version 1.0-1 - * The new function 'confint2' (originally implemented in the deprecated package 'nlrwr') was added to the 'nlstools' - * The new dataset 'L.minor' (originated from the deprecated package 'nlwrw') was added to 'nlstools' - -2014-05-12 16:15 baty - * version 1.0-0 - * Most formulas and data sets related to predictive microbiology (as well as the associated vignette) have been moved to the separate package 'nlsMicrobio' - -2013-09-30 17:07 baty - * version 0.0-15 - * O2K.rda: new dataset about oxygen kinetics in 6-minute walk test - -2012-12-10 14:57 baty - * version 0.0-14 - -2012-11-30 11:23 baty - * version 0.0-13 - * fix .First.lib call issue by removing unnecessary First.lib.R - -2012-04-20 16:49 baty - * version 0.0-12 - * plotfit function was modified in order to avoid that different independent variables are used in the plot and points statement (thanks to the help of Wolfgang Kraus) - * plot.nlsContourRSS was updated with an extra argument useRaster (= TRUE by default) so that a bitmap raster is used in the image displaying the contours - -2011-02-11 08:47 baty - * version 0.0-11 - * update contact information - * plotfit: the first independent variable is selected by default for the representation (x-axis) - -2010-01-08 11:22 Delignette-Muller - * version 0.0-10 - * competitionmodels.R and competitionmodels.Rd: add of models - * competitioncurve : add of data for these models - * nlstools_vignette : minor correction - -2009-08-22 17:39 baty - * version 0.0-9 - * nlsBoot: the 95% CI was not supplied correctly (bug fixed, reported by Andrej-Nikolai Spiess) - * nlsContourRSS: new argument 'col.pal' which is used to define the palette of colors used in the background of the plot (suggestion by Dieter Menne). - -2009-02-19 15:53 baty - * version 0.0-8 - * nlsResiduals.R: re-organization of the plots - * michaelismodels.R, michaelismodels.Rd - * vmkm.rda, vmkmki.rda, michaelisdata.Rd - * inst/doc/nlstools_vignette - -2009-02-13 17:03 baty - * version 0.0-7 - * nlsBoot.R: handles exception in the function 'try' - -2008-11-16 17:51 baty - - * nlsBoot.R: function 'try' and 'update' is used now - * nlsJack: function 'update' is used - * survivalcurve: data sets are split - * growthcurve: data sets are split - * nlsResiduals.R: the 4 default plots are types 1, 3, 4, qq-plot - -2007-10-28 14:52 baty - - * *.Rd: changed the \usage entries for S3 methods using the \method markup - -2007-06-22 23:27 baty - - * *.Rd: improved the overall documentation - -2007-06-07 21:14 baty - - * nlsContourRSS.R: the contour of the 95 percent RSS threshold is plotted - * secondary.R, secondary.Rd - * ross.rda, ross.Rd - -2007-06-07 21:14 baty - - * nlsBoot.R, nlsConfRegions.R, nlsContourRSS.R: argument 'ask' for interactive plots - -2007-05-28 21:20 baty - - * survivalmodels.Rd, survivalcurve.Rd - * survivalmodels.R - * survivalcurve.Rda - -2007-05-26 23:28 baty - - * nlstools.R: includes functions preview, plotfit and overview. Replace nlsFit.R - * .Rd files: added and completed some references - * growthcurve.Rd: completed the example - -2007-05-16 22:39 baty - - * data/growthcurve.rda, R/growthmodels.R - * R/nlsFit: plotfit, preview, overview - * R/*.R: changed the variable names (LOG10) diff --git a/DESCRIPTION b/DESCRIPTION index c618ef9..a53cbed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,16 +1,38 @@ Package: nlstools -Version: 1.0-3 Title: Tools for Nonlinear Regression Analysis -Authors@R: c(person("Florent", "Baty", role = "aut", email = "florent.baty@gmail.com"), - person("Marie-Laure", "Delignette-Muller", role = "aut", email = "marielaure.delignettemuller@vetagro-sup.fr"), - person("Sandrine", "Charles", role = "ctb"), - person("Jean-Pierre", "Flandrois", role = "ctb"), - person("Christian", "Ritz", role = "ctb"), - person("Aurelie", "Siberchicot", role = c("aut", "cre"), email = "aurelie.siberchicot@univ-lyon1.fr")) -Imports: graphics, grDevices, stats -Description: Several tools for assessing the quality of fit of a gaussian nonlinear model are provided. +Version: 1.0-3 +Authors@R: + c(person(given = "Florent", + family = "Baty", + role = "aut", + email = "florent.baty@gmail.com"), + person(given = "Marie-Laure", + family = "Delignette-Muller", + role = "aut", + email = "marielaure.delignettemuller@vetagro-sup.fr"), + person(given = "Sandrine", + family = "Charles", + role = "ctb"), + person(given = "Jean-Pierre", + family = "Flandrois", + role = "ctb"), + person(given = "Christian", + family = "Ritz", + role = "ctb"), + person(given = "Aurelie", + family = "Siberchicot", + role = c("aut", "cre"), + email = "aurelie.siberchicot@univ-lyon1.fr")) +Description: Several tools for assessing the quality of fit of a + gaussian nonlinear model are provided. +License: GPL-3 URL: https://github.com/aursiber/nlstools BugReports: https://github.com/aursiber/nlstools/issues -License: GPL-3 +Imports: + graphics, + grDevices, + stats, + utils Encoding: UTF-8 LazyData: true +RoxygenNote: 7.1.1 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c461f63 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,595 @@ +GNU General Public License +========================== + +_Version 3, 29 June 2007_ +_Copyright © 2007 Free Software Foundation, Inc. <>_ + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +## Preamble + +The GNU General Public License is a free, copyleft license for software and other +kinds of works. + +The licenses for most software and other practical works are designed to take away +your freedom to share and change the works. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change all versions of a +program--to make sure it remains free software for all its users. We, the Free +Software Foundation, use the GNU General Public License for most of our software; it +applies also to any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General +Public Licenses are designed to make sure that you have the freedom to distribute +copies of free software (and charge for them if you wish), that you receive source +code or can get it if you want it, that you can change the software or use pieces of +it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or +asking you to surrender the rights. Therefore, you have certain responsibilities if +you distribute copies of the software, or if you modify it: responsibilities to +respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, +you must pass on to the recipients the same freedoms that you received. You must make +sure that they, too, receive or can get the source code. And you must show them these +terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: **(1)** assert +copyright on the software, and **(2)** offer you this License giving you legal permission +to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is +no warranty for this free software. For both users' and authors' sake, the GPL +requires that modified versions be marked as changed, so that their problems will not +be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of +the software inside them, although the manufacturer can do so. This is fundamentally +incompatible with the aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we have designed +this version of the GPL to prohibit the practice for those products. If such problems +arise substantially in other domains, we stand ready to extend this provision to +those domains in future versions of the GPL, as needed to protect the freedom of +users. + +Finally, every program is threatened constantly by software patents. States should +not allow patents to restrict development and use of software on general-purpose +computers, but in those that do, we wish to avoid the special danger that patents +applied to a free program could make it effectively proprietary. To prevent this, the +GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +## TERMS AND CONDITIONS + +### 0. Definitions + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in +a fashion requiring copyright permission, other than the making of an exact copy. The +resulting work is called a “modified version” of the earlier work or a +work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on +the Program. + +To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for infringement under +applicable copyright law, except executing it on a computer or modifying a private +copy. Propagation includes copying, distribution (with or without modification), +making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through a computer +network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the +extent that it includes a convenient and prominently visible feature that **(1)** +displays an appropriate copyright notice, and **(2)** tells the user that there is no +warranty for the work (except to the extent that warranties are provided), that +licensees may convey the work under this License, and how to view a copy of this +License. If the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +### 1. Source Code + +The “source code” for a work means the preferred form of the work for +making modifications to it. “Object code” means any non-source form of a +work. + +A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of interfaces +specified for a particular programming language, one that is widely used among +developers working in that language. + +The “System Libraries” of an executable work include anything, other than +the work as a whole, that **(a)** is included in the normal form of packaging a Major +Component, but which is not part of that Major Component, and **(b)** serves only to +enable use of the work with that Major Component, or to implement a Standard +Interface for which an implementation is available to the public in source code form. +A “Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system (if any) on which +the executable work runs, or a compiler used to produce the work, or an object code +interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the +source code needed to generate, install, and (for an executable work) run the object +code and to modify the work, including scripts to control those activities. However, +it does not include the work's System Libraries, or general-purpose tools or +generally available free programs which are used unmodified in performing those +activities but which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for the work, and +the source code for shared libraries and dynamically linked subprograms that the work +is specifically designed to require, such as by intimate data communication or +control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate +automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +### 2. Basic Permissions + +All rights granted under this License are granted for the term of copyright on the +Program, and are irrevocable provided the stated conditions are met. This License +explicitly affirms your unlimited permission to run the unmodified Program. The +output from running a covered work is covered by this License only if the output, +given its content, constitutes a covered work. This License acknowledges your rights +of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without +conditions so long as your license otherwise remains in force. You may convey covered +works to others for the sole purpose of having them make modifications exclusively +for you, or provide you with facilities for running those works, provided that you +comply with the terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for you must do so +exclusively on your behalf, under your direction and control, on terms that prohibit +them from making any copies of your copyrighted material outside their relationship +with you. + +Conveying under any other circumstances is permitted solely under the conditions +stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +### 3. Protecting Users' Legal Rights From Anti-Circumvention Law + +No covered work shall be deemed part of an effective technological measure under any +applicable law fulfilling obligations under article 11 of the WIPO copyright treaty +adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention +of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of +technological measures to the extent such circumvention is effected by exercising +rights under this License with respect to the covered work, and you disclaim any +intention to limit operation or modification of the work as a means of enforcing, +against the work's users, your or third parties' legal rights to forbid circumvention +of technological measures. + +### 4. Conveying Verbatim Copies + +You may convey verbatim copies of the Program's source code as you receive it, in any +medium, provided that you conspicuously and appropriately publish on each copy an +appropriate copyright notice; keep intact all notices stating that this License and +any non-permissive terms added in accord with section 7 apply to the code; keep +intact all notices of the absence of any warranty; and give all recipients a copy of +this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer +support or warranty protection for a fee. + +### 5. Conveying Modified Source Versions + +You may convey a work based on the Program, or the modifications to produce it from +the Program, in the form of source code under the terms of section 4, provided that +you also meet all of these conditions: + +* **a)** The work must carry prominent notices stating that you modified it, and giving a +relevant date. +* **b)** The work must carry prominent notices stating that it is released under this +License and any conditions added under section 7. This requirement modifies the +requirement in section 4 to “keep intact all notices”. +* **c)** You must license the entire work, as a whole, under this License to anyone who +comes into possession of a copy. This License will therefore apply, along with any +applicable section 7 additional terms, to the whole of the work, and all its parts, +regardless of how they are packaged. This License gives no permission to license the +work in any other way, but it does not invalidate such permission if you have +separately received it. +* **d)** If the work has interactive user interfaces, each must display Appropriate Legal +Notices; however, if the Program has interactive interfaces that do not display +Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are +not by their nature extensions of the covered work, and which are not combined with +it such as to form a larger program, in or on a volume of a storage or distribution +medium, is called an “aggregate” if the compilation and its resulting +copyright are not used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work in an aggregate +does not cause this License to apply to the other parts of the aggregate. + +### 6. Conveying Non-Source Forms + +You may convey a covered work in object code form under the terms of sections 4 and +5, provided that you also convey the machine-readable Corresponding Source under the +terms of this License, in one of these ways: + +* **a)** Convey the object code in, or embodied in, a physical product (including a +physical distribution medium), accompanied by the Corresponding Source fixed on a +durable physical medium customarily used for software interchange. +* **b)** Convey the object code in, or embodied in, a physical product (including a +physical distribution medium), accompanied by a written offer, valid for at least +three years and valid for as long as you offer spare parts or customer support for +that product model, to give anyone who possesses the object code either **(1)** a copy of +the Corresponding Source for all the software in the product that is covered by this +License, on a durable physical medium customarily used for software interchange, for +a price no more than your reasonable cost of physically performing this conveying of +source, or **(2)** access to copy the Corresponding Source from a network server at no +charge. +* **c)** Convey individual copies of the object code with a copy of the written offer to +provide the Corresponding Source. This alternative is allowed only occasionally and +noncommercially, and only if you received the object code with such an offer, in +accord with subsection 6b. +* **d)** Convey the object code by offering access from a designated place (gratis or for +a charge), and offer equivalent access to the Corresponding Source in the same way +through the same place at no further charge. You need not require recipients to copy +the Corresponding Source along with the object code. If the place to copy the object +code is a network server, the Corresponding Source may be on a different server +(operated by you or a third party) that supports equivalent copying facilities, +provided you maintain clear directions next to the object code saying where to find +the Corresponding Source. Regardless of what server hosts the Corresponding Source, +you remain obligated to ensure that it is available for as long as needed to satisfy +these requirements. +* **e)** Convey the object code using peer-to-peer transmission, provided you inform +other peers where the object code and Corresponding Source of the work are being +offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the +Corresponding Source as a System Library, need not be included in conveying the +object code work. + +A “User Product” is either **(1)** a “consumer product”, which +means any tangible personal property which is normally used for personal, family, or +household purposes, or **(2)** anything designed or sold for incorporation into a +dwelling. In determining whether a product is a consumer product, doubtful cases +shall be resolved in favor of coverage. For a particular product received by a +particular user, “normally used” refers to a typical or common use of +that class of product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected to use, the +product. A product is a consumer product regardless of whether the product has +substantial commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install and execute +modified versions of a covered work in that User Product from a modified version of +its Corresponding Source. The information must suffice to ensure that the continued +functioning of the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for +use in, a User Product, and the conveying occurs as part of a transaction in which +the right of possession and use of the User Product is transferred to the recipient +in perpetuity or for a fixed term (regardless of how the transaction is +characterized), the Corresponding Source conveyed under this section must be +accompanied by the Installation Information. But this requirement does not apply if +neither you nor any third party retains the ability to install modified object code +on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to +continue to provide support service, warranty, or updates for a work that has been +modified or installed by the recipient, or for the User Product in which it has been +modified or installed. Access to a network may be denied when the modification itself +materially and adversely affects the operation of the network or violates the rules +and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with +this section must be in a format that is publicly documented (and with an +implementation available to the public in source code form), and must require no +special password or key for unpacking, reading or copying. + +### 7. Additional Terms + +“Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. Additional +permissions that are applicable to the entire Program shall be treated as though they +were included in this License, to the extent that they are valid under applicable +law. If additional permissions apply only to part of the Program, that part may be +used separately under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any +additional permissions from that copy, or from any part of it. (Additional +permissions may be written to require their own removal in certain cases when you +modify the work.) You may place additional permissions on material, added by you to a +covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a +covered work, you may (if authorized by the copyright holders of that material) +supplement the terms of this License with terms: + +* **a)** Disclaiming warranty or limiting liability differently from the terms of +sections 15 and 16 of this License; or +* **b)** Requiring preservation of specified reasonable legal notices or author +attributions in that material or in the Appropriate Legal Notices displayed by works +containing it; or +* **c)** Prohibiting misrepresentation of the origin of that material, or requiring that +modified versions of such material be marked in reasonable ways as different from the +original version; or +* **d)** Limiting the use for publicity purposes of names of licensors or authors of the +material; or +* **e)** Declining to grant rights under trademark law for use of some trade names, +trademarks, or service marks; or +* **f)** Requiring indemnification of licensors and authors of that material by anyone +who conveys the material (or modified versions of it) with contractual assumptions of +liability to the recipient, for any liability that these contractual assumptions +directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you received +it, or any part of it, contains a notice stating that it is governed by this License +along with a term that is a further restriction, you may remove that term. If a +license document contains a further restriction but permits relicensing or conveying +under this License, you may add to a covered work material governed by the terms of +that license document, provided that the further restriction does not survive such +relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in +the relevant source files, a statement of the additional terms that apply to those +files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a +separately written license, or stated as exceptions; the above requirements apply +either way. + +### 8. Termination + +You may not propagate or modify a covered work except as expressly provided under +this License. Any attempt otherwise to propagate or modify it is void, and will +automatically terminate your rights under this License (including any patent licenses +granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a +particular copyright holder is reinstated **(a)** provisionally, unless and until the +copyright holder explicitly and finally terminates your license, and **(b)** permanently, +if the copyright holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently +if the copyright holder notifies you of the violation by some reasonable means, this +is the first time you have received notice of violation of this License (for any +work) from that copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of +parties who have received copies or rights from you under this License. If your +rights have been terminated and not permanently reinstated, you do not qualify to +receive new licenses for the same material under section 10. + +### 9. Acceptance Not Required for Having Copies + +You are not required to accept this License in order to receive or run a copy of the +Program. Ancillary propagation of a covered work occurring solely as a consequence of +using peer-to-peer transmission to receive a copy likewise does not require +acceptance. However, nothing other than this License grants you permission to +propagate or modify any covered work. These actions infringe copyright if you do not +accept this License. Therefore, by modifying or propagating a covered work, you +indicate your acceptance of this License to do so. + +### 10. Automatic Licensing of Downstream Recipients + +Each time you convey a covered work, the recipient automatically receives a license +from the original licensors, to run, modify and propagate that work, subject to this +License. You are not responsible for enforcing compliance by third parties with this +License. + +An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an organization, or +merging organizations. If propagation of a covered work results from an entity +transaction, each party to that transaction who receives a copy of the work also +receives whatever licenses to the work the party's predecessor in interest had or +could give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if the predecessor +has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or +affirmed under this License. For example, you may not impose a license fee, royalty, +or other charge for exercise of rights granted under this License, and you may not +initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging +that any patent claim is infringed by making, using, selling, offering for sale, or +importing the Program or any portion of it. + +### 11. Patents + +A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The work thus +licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or +controlled by the contributor, whether already acquired or hereafter acquired, that +would be infringed by some manner, permitted by this License, of making, using, or +selling its contributor version, but do not include claims that would be infringed +only as a consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant patent +sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license +under the contributor's essential patent claims, to make, use, sell, offer for sale, +import and otherwise run, modify and propagate the contents of its contributor +version. + +In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent (such as an +express permission to practice a patent or covenant not to sue for patent +infringement). To “grant” such a patent license to a party means to make +such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the +Corresponding Source of the work is not available for anyone to copy, free of charge +and under the terms of this License, through a publicly available network server or +other readily accessible means, then you must either **(1)** cause the Corresponding +Source to be so available, or **(2)** arrange to deprive yourself of the benefit of the +patent license for this particular work, or **(3)** arrange, in a manner consistent with +the requirements of this License, to extend the patent license to downstream +recipients. “Knowingly relying” means you have actual knowledge that, but +for the patent license, your conveying the covered work in a country, or your +recipient's use of the covered work in a country, would infringe one or more +identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you +convey, or propagate by procuring conveyance of, a covered work, and grant a patent +license to some of the parties receiving the covered work authorizing them to use, +propagate, modify or convey a specific copy of the covered work, then the patent +license you grant is automatically extended to all recipients of the covered work and +works based on it. + +A patent license is “discriminatory” if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on the +non-exercise of one or more of the rights that are specifically granted under this +License. You may not convey a covered work if you are a party to an arrangement with +a third party that is in the business of distributing software, under which you make +payment to the third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties who would receive +the covered work from you, a discriminatory patent license **(a)** in connection with +copies of the covered work conveyed by you (or copies made from those copies), or **(b)** +primarily for and in connection with specific products or compilations that contain +the covered work, unless you entered into that arrangement, or that patent license +was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied +license or other defenses to infringement that may otherwise be available to you +under applicable patent law. + +### 12. No Surrender of Others' Freedom + +If conditions are imposed on you (whether by court order, agreement or otherwise) +that contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot convey a covered work so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not convey it at all. For example, if you +agree to terms that obligate you to collect a royalty for further conveying from +those to whom you convey the Program, the only way you could satisfy both those terms +and this License would be to refrain entirely from conveying the Program. + +### 13. Use with the GNU Affero General Public License + +Notwithstanding any other provision of this License, you have permission to link or +combine any covered work with a work licensed under version 3 of the GNU Affero +General Public License into a single combined work, and to convey the resulting work. +The terms of this License will continue to apply to the part which is the covered +work, but the special requirements of the GNU Affero General Public License, section +13, concerning interaction through a network will apply to the combination as such. + +### 14. Revised Versions of this License + +The Free Software Foundation may publish revised and/or new versions of the GNU +General Public License from time to time. Such new versions will be similar in spirit +to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that +a certain numbered version of the GNU General Public License “or any later +version” applies to it, you have the option of following the terms and +conditions either of that numbered version or of any later version published by the +Free Software Foundation. If the Program does not specify a version number of the GNU +General Public License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU +General Public License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no +additional obligations are imposed on any author or copyright holder as a result of +your choosing to follow a later version. + +### 15. Disclaimer of Warranty + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +### 16. Limitation of Liability + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY +COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS +PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE +OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE +WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +### 17. Interpretation of Sections 15 and 16 + +If the disclaimer of warranty and limitation of liability provided above cannot be +given local legal effect according to their terms, reviewing courts shall apply local +law that most closely approximates an absolute waiver of all civil liability in +connection with the Program, unless a warranty or assumption of liability accompanies +a copy of the Program in return for a fee. + +_END OF TERMS AND CONDITIONS_ + +## How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to +the public, the best way to achieve this is to make it free software which everyone +can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them +to the start of each source file to most effectively state the exclusion of warranty; +and each file should have at least the “copyright” line and a pointer to +where the full notice is found. + + + Copyright (C) 2018 Florent Baty ; Marie-Laure Delignette-Muller + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this +when it starts in an interactive mode: + + nlstools Copyright (C) 2018 Florent Baty ; Marie-Laure Delignette-Muller + This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type 'show c' for details. + +The hypothetical commands `show w` and `show c` should show the appropriate parts of +the General Public License. Of course, your program's commands might be different; +for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to +sign a “copyright disclaimer” for the program, if necessary. For more +information on this, and how to apply and follow the GNU GPL, see +<>. + +The GNU General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may consider it +more useful to permit linking proprietary applications with the library. If this is +what you want to do, use the GNU Lesser General Public License instead of this +License. But first, please read +<>. diff --git a/NAMESPACE b/NAMESPACE index 903c06e..248a7cc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,103 +1,61 @@ -### Imports -importFrom("stats", "coef", "confint", "df.residual", "fitted", "formula", - "pnorm", "ppoints", "predict", "profile", "qf", "qnorm", - "qqline", "qqnorm", "qt", "quantile", "resid", "residuals", - "runif", "sd", "shapiro.test", "update", "vcov") -importFrom("grDevices", "terrain.colors") -importFrom("graphics", "abline", "boxplot", "contour", "hist", "image", - "layout", "lines", "par", "plot", "points", "text") - - - -### Exports -# functions -export(preview, overview, plotfit) - +# Generated by roxygen2: do not edit by hand + +S3method(plot,nlsBoot) +S3method(plot,nlsConfRegions) +S3method(plot,nlsContourRSS) +S3method(plot,nlsJack) +S3method(plot,nlsResiduals) +S3method(print,nlsBoot) +S3method(print,nlsConfRegions) +S3method(print,nlsContourRSS) +S3method(print,nlsJack) +S3method(print,nlsResiduals) +S3method(summary,nlsBoot) +S3method(summary,nlsJack) +export(compet_mich) +export(confint2) +export(michaelis) export(nlsBoot) -S3method(summary, nlsBoot) -S3method(plot, nlsBoot) -S3method(print, nlsBoot) - export(nlsConfRegions) -S3method(plot, nlsConfRegions) -S3method(print, nlsConfRegions) - export(nlsContourRSS) -S3method(plot, nlsContourRSS) -S3method(print, nlsContourRSS) - export(nlsJack) -S3method(plot, nlsJack) -S3method(print, nlsJack) -S3method(summary, nlsJack) - export(nlsResiduals) -S3method(plot, nlsResiduals) -S3method(print, nlsResiduals) +export(non_compet_mich) +export(overview) +export(plotfit) +export(preview) export(test.nlsResiduals) - -# Michaelis models -export(michaelis, compet_mich, non_compet_mich) - -# Defunct functions -#export(geeraerd, geeraerd_without_Nres, geeraerd_without_Sl, mafart, albert, trilinear, bilinear_without_Nres, bilinear_without_Sl, baranyi, baranyi_without_Nmax, baranyi_without_lag, buchanan, buchanan_without_Nmax, buchanan_without_lag, gompertzm, jameson_buchanan, jameson_baranyi, jameson_without_lag, cpm_T, cpm_pH_4p, cpm_pH_3p, cpm_aw_3p, cpm_aw_2p, cpm_T_pH_aw) -#export(competition1, competition2, growthcurve1, growthcurve2, growthcurve3, growthcurve4, ross, survivalcurve1, survivalcurve2, survivalcurve3) - -export(confint2) - -#export(confint2) -#export(nls) - -##################################### -## Not Exported ## -##################################### - -## ******* defunct ******* -## "albert" -## "baranyi" -## "baranyi_without_lag" -## "baranyi_without_Nmax" -## "bilinear_without_Nres" -## "bilinear_without_SI" -## "buchanan" -## "buchanan_without_lag" -## "buchanan_without_Nmax" -## "competition1" -## "competition2" -## "competitioncurve" -## "competitionmodels" -## "compet_mich" -## "cpm_aw_2p" -## "cpm_aw_3p" -## "cpm_pH_3p" -## "cpm_pH_4p" -## "cpm_T" -## "cpm_T_pH_aw" -## "geeraerd" -## "geeraerd_without_Nres" -## "geeraerd_without_SI" -## "gompertzm" -## "growthcurve1" -## "growthcurve2" -## "growthcurve3" -## "growthcurve4" -## "growthmodels" -## "jameson_baranyi" -## "jameson_buchanan" -## "jameson_without_lag" -## "mafart" -## "michaelis" -## "michaelismodels" -## "non_compet_mich" -## "ross" -## "secondary" -## "survivalcurve1" -## "survivalcurve2" -## "survivalcurve3" -## "survivalmodels" -## "trilinear" -## "vmkm" -## "vmkmki" - - - +importFrom(grDevices,terrain.colors) +importFrom(graphics,abline) +importFrom(graphics,boxplot) +importFrom(graphics,contour) +importFrom(graphics,hist) +importFrom(graphics,image) +importFrom(graphics,layout) +importFrom(graphics,lines) +importFrom(graphics,par) +importFrom(graphics,plot) +importFrom(graphics,points) +importFrom(graphics,text) +importFrom(stats,coef) +importFrom(stats,confint) +importFrom(stats,df.residual) +importFrom(stats,fitted) +importFrom(stats,formula) +importFrom(stats,pnorm) +importFrom(stats,ppoints) +importFrom(stats,predict) +importFrom(stats,profile) +importFrom(stats,qf) +importFrom(stats,qnorm) +importFrom(stats,qqline) +importFrom(stats,qqnorm) +importFrom(stats,qt) +importFrom(stats,quantile) +importFrom(stats,resid) +importFrom(stats,residuals) +importFrom(stats,runif) +importFrom(stats,sd) +importFrom(stats,shapiro.test) +importFrom(stats,update) +importFrom(stats,vcov) diff --git a/inst/NEWS b/NEWS.md similarity index 93% rename from inst/NEWS rename to NEWS.md index 4f4d96e..37e666e 100644 --- a/inst/NEWS +++ b/NEWS.md @@ -1,4 +1,8 @@ -=== nlstools: Tools for Nonlinear Regression Analysis === +nlstools 1.0-3 +============= + +* Document with roxygen2, helped by [Rd2roxygen](https://yihui.name/rd2roxygen/) +* Moved `NEWS.md` file to track changes to the package. Version 1.0-2 ============= diff --git a/R/confint2.R b/R/confint2.R index 7f228a1..3241eda 100644 --- a/R/confint2.R +++ b/R/confint2.R @@ -1,3 +1,37 @@ +#' Confidence intervals in nonlinear regression +#' +#' Produces confidence intervals for the parameters in nonlinear regression +#' model fit. The intervals can either be based large sample results or on +#' profiling. +#' +#' The profiling used is the method \code{\link[MASS]{confint.nls}.} +#' +#' @param object object of class \code{\link{nls}}. +#' @param parm a vector character strings with names of the parameter for which +#' to calculate confidence intervals (by default all parameters). +#' @param level the confidence level required. +#' @param method method to be used: "asympotic" for large sample and "profile" +#' for profiling approach. +#' @param \dots additional argument(s) to pass on the method doing the +#' profiling. +#' +#' @importFrom stats coef qt df.residual vcov profile confint +#' +#' @return A matrix with columns giving lower and upper confidence limits for +#' each parameter. +#' @author Christian Ritz +#' @keywords models nonlinear +#' @examples +#' +#' +#' L.minor.m1 <- nls(rate ~ Vm*conc/(K+conc), data = L.minor, start = list(K=20, Vm=120)) +#' +#' confint2(L.minor.m1) +#' +#' confint2(L.minor.m1, "K") +#' +#' +#' @export confint2 "confint2" <- function(object, parm, level = 0.95, method = c("asymptotic", "profile"), ...) { method <- match.arg(method) diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..e81334f --- /dev/null +++ b/R/data.R @@ -0,0 +1,60 @@ +#' Enzyme kinetics +#' +#' Enzyme kinetics +#' +#' +#' @format A data frame with 8 observations on the following 2 variables. +#' \describe{ +#' \item{conc}{a numeric vector} +#' \item{rate}{a numeric vector} +#' } +#' @source Cedergreen, N. and Madsen, T. V. (2002) Nitrogen uptake by the +#' floating macrophyte \emph{Lemna minor}, \emph{New Phytologist}, \bold{155}, +#' 285--292. +#' @keywords datasets +"L.minor" + +#' Michaelis Menten data sets +#' +#' Michaelis Menten data sets +#' +#' +#' @aliases vmkmki michaelisdata +#' @format \code{vmkm} is a data frame with 2 columns (S: concentration of +#' substrat, v: reaction rate)\cr +#' \code{vmkmki} is a data frame with 3 columns +#' (S: concentration of substrat, I: concentration of inhibitor, v: reaction +#' rate) +#' @source These datasets were provided by the French research unit INRA +#' UMR1233. +#' @keywords datasets +#' @examples +#' +#' data(vmkm) +#' data(vmkmki) +#' plot(vmkm) +#' plot(vmkmki) +#' +"vmkm" + +#' Oxygen kinetics during 6-minute walk test data set +#' +#' Oxygen uptake kinetics during a 6-minute walking test in a patient with +#' pulmonary disease. The first 5.83 minutes correspond to the resting phase +#' prior to exercise. +#' +#' +#' @format \code{O2K} is a data frame with 2 columns (t: time, VO2: oxygen +#' uptake)\cr +#' @source This data set was provided by the Cantonal Hospital St. Gallen, +#' Switzerland. +#' @keywords datasets +#' @examples +#' +#' data(O2K) +#' plot(O2K) +#' +"O2K" + + + diff --git a/R/michaelismodels.R b/R/michaelismodels.R index 9ef5c2f..16516d4 100644 --- a/R/michaelismodels.R +++ b/R/michaelismodels.R @@ -1,5 +1,74 @@ -"michaelis" <- as.formula(v ~ S/(S+Km) * Vmax) +#' Michaelis-Menten model and derived equations to model competitive and +#' non-competitive inhibition +#' +#' Formula of Michaelis-Menten model commonly used to describe enzyme kinetics, +#' and derived formulas taking into account the effect of a competitive or a +#' non-competitive inhibitor +#' +#' +#' These models describe the evolution of the reaction rate (v) as a function +#' of the concentration of substrate (S) and the concentration of inhibitor (I) +#' for \code{compet_mich} and \code{non_compet_mich}. +#' +#' \code{michaelis} is the classical Michaelis-Menten model (Dixon, 1979) with +#' two parameters (Km, Vmax) : \deqn{v = \frac{S}{S+K_m} V_{max}}{v = +#' S/(S+Km)*Vmax} \cr\cr +#' +#' \code{compet_mich} is the Michaelis-Menten derived +#' model with three parameters (Km, Vmax, Ki), describing a competitive +#' inhibition : \deqn{v = \frac{S}{S + K_m (1+\frac{I}{K_i})} V_{max}}{v = S/(S +#' + Km*(1+I/Ki) ) * Vmax} \cr\cr +#' +#' \code{non_compet_mich} is the +#' Michaelis-Menten derived model with three parameters (Km, Vmax, Ki), +#' describing a non-competitive inhibition : \deqn{v = +#' \frac{S}{(S+K_m)(1+\frac{I}{Ki})} V_{max}}{v = S/( (S + Km)*(1+I/Ki) ) * +#' Vmax} \cr\cr +#' +#' @aliases michaelismodels michaelis compet_mich non_compet_mich +#' @return A formula +#' @author Florent Baty \email{florent.baty@@gmail.com}\cr Marie-Laure +#' Delignette-Muller \email{ml.delignette@@vetagro-sup.fr} +#' @references Dixon M and Webb EC (1979) \emph{Enzymes}, Academic Press, New +#' York. +#' @keywords models +#' @examples +#' +#' +#' # Example 1 +#' +#' data(vmkm) +#' nls1 <- nls(michaelis,vmkm,list(Km=1,Vmax=1)) +#' plotfit(nls1, smooth = TRUE) +#' +#' # Example 2 +#' +#' data(vmkmki) +#' def.par <- par(no.readonly = TRUE) +#' par(mfrow = c(2,2)) +#' +#' nls2_c <- nls(compet_mich, vmkmki, list(Km=1,Vmax=20,Ki=0.5)) +#' plotfit(nls2_c, variable=1) +#' overview(nls2_c) +#' res2_c <- nlsResiduals(nls2_c) +#' plot(res2_c, which=1) +#' +#' nls2_nc <- nls(non_compet_mich, vmkmki, list(Km=1, Vmax=20, Ki=0.5)) +#' plotfit(nls2_nc, variable=1) +#' overview(nls2_nc) +#' res2_nc <- nlsResiduals(nls2_nc) +#' plot(res2_nc, which=1) +#' +#' par(def.par) +#' +#' @export +#' +michaelis <- as.formula(v ~ S/(S+Km) * Vmax) -"compet_mich" <- as.formula(v ~ S/(S + Km*(1+I/Ki) ) * Vmax) +#' @rdname michaelis +#' @export +compet_mich <- as.formula(v ~ S/(S + Km*(1+I/Ki) ) * Vmax) -"non_compet_mich" <- as.formula(v ~ S/( (S + Km)*(1+I/Ki) ) * Vmax) +#' @rdname michaelis +#' @export +non_compet_mich <- as.formula(v ~ S/( (S + Km)*(1+I/Ki) ) * Vmax) diff --git a/R/nlsBoot.R b/R/nlsBoot.R index a93fb64..52a3a9e 100644 --- a/R/nlsBoot.R +++ b/R/nlsBoot.R @@ -1,4 +1,62 @@ -"nlsBoot"<-function(nls, niter=999){ +#' Bootstrap resampling +#' +#' Bootstrap resampling +#' +#' Non-parametric bootstrapping is used. Mean centered residuals are +#' bootstrapped. By default, 999 resampled data sets are created from which +#' parameter estimates are obtained by fitting the model on each of these data +#' sets. Whenever the fit fails to converge, a flag reports the number of +#' non-convergences. If the fitting procedure fails to converge in more than +#' 50\% of the cases, the procedure is interrupted with a flag and no result is +#' given. The function \code{summary} returns the bootstrap estimates (mean and +#' std. dev. of the bootstrapped estimates) and the median and 95 percent +#' confidence intervals (50, 2.5, and 97.5 percentiles of the bootstrapped +#' estimates). The bootstrapped estimate distributions can be visualized using +#' the function \code{plot.nlsBoot} either by plotting the bootstrapped sample +#' for each pair of parameters or by displaying the boxplot representation of +#' the bootstrapped sample for each parameter. Notice that \code{nlsBoot} does +#' not currently handle transformed dependent variables specified in the left +#' side of the \code{nls} formula. +#' +#' @aliases nlsBoot plot.nlsBoot print.nlsBoot summary.nlsBoot +#' @param nls an object of class 'nls' +#' @param niter number of iterations +#' @param x,object an object of class 'nlsBoot' +#' @param type type of representation (options are "pairs" or "boxplot") +#' @param mfr layout definition (number of rows and columns in the graphics +#' device) +#' @param ask if TRUE, draw plot interactively +#' @param ... further arguments passed to or from other methods +#' +#' @importFrom stats fitted resid formula update coef quantile sd +#' +#' @return \code{nlsBoot} returns a list of 4 objects: \item{ coefboot }{ +#' contains the bootstrap parameter estimates } \item{ bootCI }{ contains the +#' bootstrap medians and the bootstrap 95\% confidence intervals } \item{ +#' estiboot }{ contains the means and std. errors of the bootstrap parameter +#' estimates } \item{ rse }{ is the vector of bootstrap residual errors } +#' @author Florent Baty \email{florent.baty@@gmail.com}\cr Marie-Laure +#' Delignette-Muller \email{ml.delignette@@vetagro-sup.fr} +#' @references Bates DM and Watts DG (1988) Nonlinear regression analysis and +#' its applications. Wiley, Chichester, UK.\cr\cr Huet S, Bouvier A, Poursat +#' M-A, Jolivet E (2003) Statistical tools for nonlinear regression: a +#' practical guide with S-PLUS and R examples. Springer, Berlin, Heidelberg, +#' New York. +#' @keywords nonlinear +#' @examples +#' +#' formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2res + (t > 5.883) * +#' (VO2res + (VO2peak - VO2res) * +#' (1 - exp(-(t - 5.883) / mu)))) +#' O2K.nls1 <- nls(formulaExp, start = list(VO2res = 400, VO2peak = 1600, +#' mu = 1), data = O2K) +#' O2K.boot1 <- nlsBoot(O2K.nls1, niter = 200) +#' plot(O2K.boot1) +#' plot(O2K.boot1, type = "boxplot", ask = FALSE) +#' summary(O2K.boot1) +#' +#' @export nlsBoot +nlsBoot <-function(nls, niter=999){ if (!inherits(nls, "nls")) stop("Use only with 'nls' objects") @@ -31,8 +89,10 @@ } - -"plot.nlsBoot"<-function(x, type=c("pairs","boxplot"), mfr=c(ceiling(sqrt(ncol(x$coefboot))),ceiling(sqrt(ncol(x$coefboot)))),ask=FALSE, ...){ +#' @rdname nlsBoot +#' @importFrom graphics par layout plot boxplot +#' @export +plot.nlsBoot <-function(x, type=c("pairs","boxplot"), mfr=c(ceiling(sqrt(ncol(x$coefboot))),ceiling(sqrt(ncol(x$coefboot)))),ask=FALSE, ...){ if (!inherits(x, "nlsBoot")) stop("Use only with 'nlsBoot' objects") tab <- x$coefboot @@ -60,8 +120,9 @@ par(def.par) } - -"print.nlsBoot" <- function (x, ...) { +#' @rdname nlsBoot +#' @export +print.nlsBoot <- function (x, ...) { if (!inherits(x, "nlsBoot")) stop("Use only with 'nlsBoot' objects") cat("Bootstrap resampling\n") @@ -80,7 +141,9 @@ cat("\n") } -"summary.nlsBoot" <- function (object, ...) { +#' @rdname nlsBoot +#' @export +summary.nlsBoot <- function (object, ...) { if (!inherits(object, "nlsBoot")) stop("Use only with 'nlsBoot' objects") cat("\n------\n") diff --git a/R/nlsConfRegions.R b/R/nlsConfRegions.R index 99e79cb..3bac43c 100644 --- a/R/nlsConfRegions.R +++ b/R/nlsConfRegions.R @@ -1,4 +1,60 @@ -"nlsConfRegions"<-function(nls, length=1000, exp=1.5){ +#' Confidence regions +#' +#' Draws parameter values in the Beale's 95 percent unlinearized confidence +#' region +#' +#' A sample of points in the 95 percent confidence region is computed according +#' to Beale's criterion (Beale, 1960). This region is also named the joint +#' parameter likelihood region (Bates and Watts, 1988). The method used +#' consists in a random sampling of parameters values in a hypercube centered +#' on the least squares estimate and rejecting the parameters values whose +#' residual sum of squares do not verify the Beale criterion. The confidence +#' region is plotted by projection of the sampled points in each plane defined +#' by a couple of parameters. Bounds of the hypercube in which random values of +#' parameters are drawn may be plotted in order to check if the confidence +#' region was totally included in the hypercube defined by default. If not the +#' hypercube should be expanded in order to obtain the full confidence region +#' +#' @aliases nlsConfRegions plot.nlsConfRegions print.nlsConfRegions +#' @param nls an object of class 'nls' +#' @param length number of points to draw in the confidence region +#' @param exp expansion factor of the hypercube in which random values of +#' parameters are drawn +#' @param x an object of class 'nlsConfRegions' +#' @param bounds logical defining whether bounds of the drawing hypercube are +#' plotted +#' @param ask if TRUE, draw plot interactively +#' @param ... further arguments passed to or from other methods +#' +#' @importFrom stats coef formula residuals qf qt runif +#' +#' @return \code{nlsConfRegions} returns a list of four objects: \item{ cr }{ a +#' data frame containing the sample drawn in the Beale's confidence region } +#' \item{ rss }{ a vector containing the residual sums of squares corresponding +#' to \code{cr} } \item{ rss95 }{ the 95 percent residual sum of squares +#' threshold according to Beale (1960) } \item{ bounds }{ lower and upper +#' bounds of the hypercube in which random values of parameters have been drawn +#' } +#' @author Florent Baty \email{florent.baty@@gmail.com}\cr Marie-Laure +#' Delignette-Muller \email{ml.delignette@@vetagro-sup.fr} +#' @seealso \code{ellipse.nls} in the \code{ellipse} library +#' @references Beale EML (1960) Confidence regions in non-linear estimations. +#' \emph{Journal of the Royal Statistical Society}, \bold{22B}, 41-88.\cr\cr +#' Bates DM and Watts DG (1988) Nonlinear regression analysis and its +#' applications. Wiley, Chichester, UK. +#' @keywords nonlinear +#' @examples +#' +#' 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.conf1 <- nlsConfRegions(O2K.nls1, exp = 2, length = 200) +#' plot(O2K.conf1, bounds = TRUE) +#' +#' @export nlsConfRegions +nlsConfRegions <- function(nls, length=1000, exp=1.5){ if (!inherits(nls, "nls")) stop("Use only with 'nls' objects") @@ -51,8 +107,10 @@ return(listcr) } - -"plot.nlsConfRegions"<-function(x, bounds=FALSE, ask=FALSE, ...){ +#' @rdname nlsConfRegions +#' @importFrom graphics par layout plot abline +#' @export +plot.nlsConfRegions <-function(x, bounds=FALSE, ask=FALSE, ...){ if (!inherits(x, "nlsConfRegions")) stop("Use only with 'nlsConfRegions' objects") np <- ncol(x$cr) @@ -78,7 +136,9 @@ par(def.par) } -"print.nlsConfRegions" <- function (x, ...) { +#' @rdname nlsConfRegions +#' @export +print.nlsConfRegions <- function (x, ...) { if (!inherits(x, "nlsConfRegions")) stop("Use only with 'nlsConfRegions' objects") cat("Beale's 95 percent confidence regions\n") diff --git a/R/nlsContourRSS.R b/R/nlsContourRSS.R index 3535529..d01ac93 100644 --- a/R/nlsContourRSS.R +++ b/R/nlsContourRSS.R @@ -1,8 +1,62 @@ -"nlsContourRSS"<-function(nls, lseq=100, exp=2){ +#' Surface contour of RSS +#' +#' Provides residual sum of squares (RSS) contours +#' +#' The aim of these functions is to plot the residual sum of squares (RSS) +#' contours which correspond to likelihood contours for a Gaussian model. For +#' each pair of parameters the RSS is calculated on a grid centered on the +#' least squares estimates of both parameters, the other parameters being fixed +#' to their least square estimates. The contours of RSS values are then plotted +#' for each pair of parameters. For each pair of parameters, one of this +#' contour corresponds to a section of the 95 percent Beale's confidence region +#' in the plane of these parameters. This contour is plotted in a different +#' color. +#' +#' @aliases nlsContourRSS plot.nlsContourRSS print.nlsContourRSS +#' @param nls an object of class 'nls' +#' @param lseq length of the sequences of parameters +#' @param exp expansion factor of the parameter intervals defining the grids +#' @param nlev number of contour levels to add to the likelihood contour at +#' level 95 percent +#' @param col logical. Contours are plotted with colors if \code{TRUE} +#' @param col.pal Palette of colors. Colors to be used as background (default +#' is terrain.colors(100); unused if col is FALSE) +#' @param x an object of class 'nlsContourRSS' +#' @param ask if TRUE, draw plot interactively (default is FALSE) +#' @param useRaster a bitmap raster is used to plot the image instead of +#' polygons (default is TRUE) +#' @param ... further arguments passed to or from other methods +#' +#' @importFrom stats coef formula residuals qf qt +#' +#' @return \code{nlsContourRSS} returns a list of three objects: \item{ seqPara +#' }{ a matrix with the sequence of grid values for each parameter } \item{ +#' lrss }{ a list of matrices with logarithm values of RSS in the grid for each +#' pair of parameters } \item{ lrss95 }{ the logarithm of the 95 percent +#' residual sum of squares threshold according to Beale (1960) } +#' @author Florent Baty \email{florent.baty@@gmail.com}\cr Marie-Laure +#' Delignette-Muller \email{ml.delignette@@vetagro-sup.fr} +#' @references Beale EML (1960) Confidence regions in non-linear estimations. +#' \emph{Journal of the Royal Statistical Society}, \bold{22B}, 41-88.\cr\cr +#' Bates DM and Watts DG (1988) Nonlinear regression analysis and its +#' applications. Wiley, Chichester, UK.\cr +#' @keywords nonlinear +#' @examples +#' +#' 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.cont1 <- nlsContourRSS(O2K.nls1) +#' plot(O2K.cont1) +#' +#' @export nlsContourRSS +nlsContourRSS <-function(nls, lseq=100, exp=2){ if (!inherits(nls, "nls")) stop("Use only with 'nls' objects") - "formula2function"<-function(formu){ + formula2function <-function(formu){ arg1 <- all.vars(formu) arg2 <- vector("list",length(arg1)) names(arg2) <- arg1 @@ -11,7 +65,7 @@ return(fmodele) } - "sce" <- function(para1, para2, i, j, para=lestimates, vari=data[varindep], resp=data[,vardep]){ + sce <- function(para1, para2, i, j, para=lestimates, vari=data[varindep], resp=data[,vardep]){ para[[i]] <- para1; para[[j]] <- para2 lvari <- as.list(vari) paraVar <- c(para, lvari) @@ -59,8 +113,11 @@ return(listsce) } - -"plot.nlsContourRSS"<-function(x, nlev=0, col=TRUE, col.pal=terrain.colors(100), ask=FALSE, useRaster=TRUE, ...){ +#' @rdname nlsContourRSS +#' @importFrom graphics par layout image contour +#' @importFrom grDevices terrain.colors +#' @export +plot.nlsContourRSS <-function(x, nlev=0, col=TRUE, col.pal=terrain.colors(100), ask=FALSE, useRaster=TRUE, ...){ if (!inherits(x, "nlsContourRSS")) stop("Use only with 'nlsContourRSS' objects") @@ -95,7 +152,9 @@ par(def.par) } -"print.nlsContourRSS" <- function (x, ...) { +#' @rdname nlsContourRSS +#' @export +print.nlsContourRSS <- function (x, ...) { if (!inherits(x, "nlsContourRSS")) stop("Use only with 'nlsContourRSS' objects") cat("RSS surface contour\n") diff --git a/R/nlsJack.R b/R/nlsJack.R index 31956d0..8853ec9 100644 --- a/R/nlsJack.R +++ b/R/nlsJack.R @@ -1,4 +1,62 @@ -"nlsJack"<-function(nls){ +#' Jackknife resampling +#' +#' Jackknife resampling +#' +#' +#' A jackknife resampling procedure is performed. Each observation is +#' sequentially removed from the initial data set using a leave-one-out +#' strategy. A data set with \emph{n} observations provides thus \emph{n} +#' resampled data sets of \emph{n-1} observations. The jackknife estimates with +#' confidence intervals are calculated as described by Seber and Wild (1989) +#' from the results of \emph{n} new fits of the model on the \emph{n} jackknife +#' resampled data sets. The leave-one-out procedure is also employed to assess +#' the influence of each observation on each parameter estimate. An observation +#' is empirically defined as influential for one parameter if the difference +#' between the estimate of this parameter with and without the observation +#' exceeds twice the standard error of the estimate divided by \emph{sqrt(n)}. +#' This empirical method assumes a small curvature of the nonlinear model. For +#' each parameter, the absolute relative difference (in percent of the +#' estimate) of the estimates with and without each observation is plotted. An +#' asterisk is plotted for each influential observation. +#' +#' @aliases nlsJack plot.nlsJack print.nlsJack summary.nlsJack +#' @param nls an object of class 'nls' +#' @param x,object an object of class 'nlsJack' +#' @param mfr layout definition, default is k rows (k: number of parameters) +#' and 1 column +#' @param ask if TRUE, draw plot interactively +#' @param ... further arguments passed to or from other methods +#' +#' @importFrom stats coef update residuals qt +#' +#' @return \code{nlsJack} returns a list with 7 objects: \item{ estijack }{ a +#' data frame with jackknife estimates and bias } \item{ coefjack }{ a data +#' frame with the parameter estimates for each jackknife sample } \item{ reldif +#' }{ a data frame with the absolute relative difference (in percent of the +#' estimate) of the estimates with and without each observation } \item{ dfb }{ +#' a data frame with dfbetas for each parameter and each observation } \item{ +#' jackCI }{ a data frame with jackknife confidence intervals } \item{ rse }{ a +#' vector with residual standard error for each jackknife sample } \item{ rss +#' }{ residual a vector with residual sum of squares for each jackknife sample +#' } +#' @author Florent Baty \email{florent.baty@@gmail.com}\cr Marie-Laure +#' Delignette-Muller \email{ml.delignette@@vetagro-sup.fr} +#' @references Seber GAF, Wild CJ (1989) Nonlinear regression. Wiley, New +#' York.\cr\cr +#' @keywords nonlinear +#' @examples +#' +#' 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.jack1 <- nlsJack(O2K.nls1) +#' plot(O2K.jack1) +#' summary(O2K.jack1) +#' +#' @export nlsJack +nlsJack <-function(nls){ if (!inherits(nls, "nls")) stop("Use only with 'nls' objects") @@ -30,7 +88,10 @@ return(listjack) } -"plot.nlsJack"<-function(x, mfr=c(nrow(x$reldif),1), ask=FALSE, ...){ +#' @rdname nlsJack +#' @importFrom graphics par plot text +#' @export +plot.nlsJack <- function(x, mfr=c(nrow(x$reldif),1), ask=FALSE, ...){ if (!inherits(x, "nlsJack")) stop("Use only with 'nlsJack' objects") if(ask) par(ask=TRUE,mar=c(4,4,3,1)) @@ -45,7 +106,9 @@ par(mfrow=c(1,1),ask=FALSE) } -"print.nlsJack" <- function (x, ...) { +#' @rdname nlsJack +#' @export +print.nlsJack <- function (x, ...) { if (!inherits(x, "nlsJack")) stop("Use only with 'nlsJack' objects") cat("Jackknife resampling\n") @@ -67,7 +130,9 @@ cat("\n") } -"summary.nlsJack" <- function (object, ...) { +#' @rdname nlsJack +#' @export +summary.nlsJack <- function (object, ...) { if (!inherits(object, "nlsJack")) stop("Use only with 'nlsJack' objects") cat("\n------\n") diff --git a/R/nlsResiduals.R b/R/nlsResiduals.R index 0217637..8e6ba40 100644 --- a/R/nlsResiduals.R +++ b/R/nlsResiduals.R @@ -1,4 +1,71 @@ -"nlsResiduals" <- function(nls){ +#' NLS residuals +#' +#' Provides several plots and tests for the analysis of residuals +#' +#' +#' Several plots and tests are proposed to check the validity of the +#' assumptions of the error model based on the analysis of residuals.\cr The +#' function \code{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.\cr \code{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 \code{nlstools} is the one implemented in the +#' package \code{tseries}. +#' +#' @aliases nlsResiduals plot.nlsResiduals test.nlsResiduals print.nlsResiduals +#' @param nls an object of class 'nls' +#' @param x an object of class 'nlsResiduals' +#' @param which an integer: \cr 0 = 4 graphs of residuals (types 1, 2, 4 and 6) +#' \cr 1 = non-transformed residuals against fitted values \cr 2 = standardized +#' residuals against fitted values \cr 3 = sqrt of absolute value of +#' standardized residuals against fitted values \cr 4 = auto-correlation +#' residuals (i+1th residual against ith residual) \cr 5 = histogram of the +#' residuals \cr 6 = qq-plot of the residuals +#' @param ... further arguments passed to or from other methods +#' +#' @importFrom stats fitted residuals qt resid coef +#' +#' @return \code{nlsResiduals} returns a list of five objects: \item{ std95 }{ +#' the Student value for alpha=0.05 (bilateral) and the degree of freedom of +#' the model } \item{ resi1 }{ a matrix with fitted values vs. non-transformed +#' residuals } \item{ resi2 }{ a matrix with fitted values vs. standardized +#' residuals } \item{ resi3 }{ a matrix with fitted values vs. +#' sqrt(abs(standardized residuals)) } \item{ resi4 }{ a matrix with ith +#' residuals vs. i+1th residuals } +#' @author Florent Baty \email{florent.baty@@gmail.com}\cr Marie-Laure +#' Delignette-Muller \email{ml.delignette@@vetagro-sup.fr} +#' @references Bates DM and Watts DG (1988) Nonlinear regression analysis and +#' its applications. Wiley, Chichester, UK.\cr\cr Siegel S and Castellan NJ +#' (1988) Non parametric statistics for behavioral sciences. McGraw-Hill +#' international, New York. +#' +#' +#' @keywords nonlinear +#' @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) +#' +#' @export nlsResiduals +nlsResiduals <- function(nls){ if (!inherits(nls, "nls")) stop("Use only with 'nls' objects") @@ -34,21 +101,25 @@ return(listresi) } -"plot.nlsResiduals" <- function(x, which=0, ...){ +#' @rdname nlsResiduals +#' @importFrom graphics hist boxplot par plot abline hist +#' @importFrom stats ppoints quantile qnorm qqnorm qqline +#' @export +plot.nlsResiduals <- function(x, which=0, ...){ - "hist.nlsResiduals" <- function(x, ...){ + hist.nlsResiduals <- function(x, ...){ if (!inherits(x, "nlsResiduals")) stop("Use only with 'nlsResiduals' objects") hist(x$resi1[,"Residuals"], main="Residuals", xlab="Residuals") } - "boxplot.nlsResiduals" <- function(x, ...){ + boxplot.nlsResiduals <- function(x, ...){ if (!inherits(x, "nlsResiduals")) stop("Use only with 'nlsResiduals' objects") boxplot(x$resi1[,"Residuals"], main="Residuals") } - "qq.nlsResiduals" <- function(x){ + qq.nlsResiduals <- function(x){ if (!inherits(x, "nlsResiduals")) stop("Use only with 'nlsResiduals' objects") @@ -100,8 +171,10 @@ } } - -"test.nlsResiduals" <- function(x){ +#' @rdname nlsResiduals +#' @importFrom stats pnorm shapiro.test +#' @export +test.nlsResiduals <- function(x){ "runs.test" <- function (x, alternative = c("two.sided", "less", "greater")){ if(!is.factor(x)) stop("x is not a factor") @@ -153,7 +226,9 @@ runs.test(as.factor(run)) } -"print.nlsResiduals" <- function(x, ...){ +#' @rdname nlsResiduals +#' @export +print.nlsResiduals <- function(x, ...){ if (!inherits(x, "nlsResiduals")) stop("Use only with 'nlsResiduals' objects") cat("Residuals\n") diff --git a/R/nlstools-defunct.R b/R/nlstools-defunct.R new file mode 100644 index 0000000..2251d19 --- /dev/null +++ b/R/nlstools-defunct.R @@ -0,0 +1,47 @@ +#' @title Defunct Functions in Package \pkg{nlstools} +#' +#' @description The models or data sets listed here are no longer part of package +#' \pkg{nlstools}. In order to access these models and data set in the future, +#' please load the additional package \pkg{nlsMicrobio}. +#' +#' +#' Defunct functions are:\cr +#' \code{geeraerd}\cr +#' \code{geeraerd_without_Nres}\cr +#' \code{geeraerd_without_Sl}\cr +#' \code{mafart}\cr +#' \code{albert}\cr +#' \code{trilinear}\cr +#' \code{bilinear_without_Nres}\cr +#' \code{bilinear_without_Sl}\cr +#' \code{baranyi}\cr +#' \code{baranyi_without_Nmax}\cr +#' \code{baranyi_without_lag}\cr +#' \code{buchanan}\cr +#' \code{buchanan_without_Nmax}\cr +#' \code{buchanan_without_lag}\cr +#' \code{gompertzm}\cr +#' \code{jameson_buchanan}\cr +#' \code{jameson_baranyi}\cr +#' \code{jameson_without_lag}\cr +#' \code{cpm_T}\cr +#' \code{cpm_pH_4p}\cr +#' \code{cpm_pH_3p}\cr +#' \code{cpm_aw_3p}\cr +#' \code{cpm_aw_2p}\cr +#' \code{cpm_T_pH_aw}\cr +#' \code{competition1}\cr +#' \code{competition2}\cr +#' \code{growthcurve1}\cr +#' \code{growthcurve2}\cr +#' \code{growthcurve3}\cr +#' \code{growthcurve4}\cr +#' \code{ross}\cr +#' \code{survivalcurve1}\cr +#' \code{survivalcurve2}\cr +#' \code{survivalcurve3}\cr +#' +#' @name nlstools-deprecated +#' @keywords internal +#' +NULL diff --git a/R/nlstools-package.R b/R/nlstools-package.R new file mode 100644 index 0000000..b30bbda --- /dev/null +++ b/R/nlstools-package.R @@ -0,0 +1,8 @@ +#' @keywords internal +"_PACKAGE" + +# The following block is used by usethis to automatically manage +# roxygen namespace tags. Modify with care! +## usethis namespace: start +## usethis namespace: end +NULL diff --git a/R/nlstools.R b/R/nlstools.R index 8ba3077..dc2febc 100644 --- a/R/nlstools.R +++ b/R/nlstools.R @@ -1,6 +1,72 @@ -"preview" <- function(formula, data, start, variable=1){ +#' Nonlinear least squares fit +#' +#' Tools to help the fit of nonlinear models with nls +#' +#' The function \code{preview} helps defining the parameter starting values +#' prior fitting the model. It provides a superimposed plot of observed +#' (circles) and predicted (crosses) values of the dependent variable versus +#' one of the independent variables with the model evaluated at the starting +#' values of the parameters. The function \code{overview} returns the +#' parameters estimates, their standard errors as well as their asymptotic +#' confidence intervals and the correlation matrix (alternately, the function +#' \code{confint} provides better confidence interval estimates whenever it +#' converges). \code{plotfit} displays a superimposed plot of the dependent +#' variable versus one the independent variables together with the fitted +#' model. +#' +#' @param formula formula of a non-linear model +#' @param data a data frame with header matching the variables given in the +#' formula +#' @param start a list of parameter starting values which names match the +#' parameters given in the formula +#' @param variable index of the variable to be plotted against the predicted +#' values; default is the first independent variable as it appears in the +#' orginal dataset +#' @param x an object of class 'nls' +#' @param smooth a logical value, default is FALSE. If smooth is TRUE, a plot +#' of observed values is plotted as a function of 1000 values continuously +#' taken in the range interval [min(variable),max(variable)]. This option can +#' only be used if the number of controlled variables is 1. +#' @param xlab X-label +#' @param ylab Y-label +#' @param pch.obs type of point of the observed values +#' @param pch.fit type of point of the fitted values (not applicable if +#' smooth=TRUE) +#' @param lty type of line of the smoothed fitted values (if smooth=TRUE) +#' @param lwd thickness of line of the smoothed fitted values (if smooth=TRUE) +#' @param col.obs color of the observed points +#' @param col.fit color of the fitted values +#' @param ... further arguments passed to or from other methods +#' +#' +#' @importFrom stats residuals coef qt +#' @importFrom graphics plot points +#' +#' @seealso \code{nls} in the \code{stats} library and \code{confint.nls} in +#' the package \code{MASS} +#' +#' @references Baty F, Ritz C, Charles S, Brutsche M, Flandrois J-P, +#' Delignette-Muller M-L (2015). A Toolbox for Nonlinear Regression in R: The +#' Package nlstools. \emph{Journal of Statistical Software}, \bold{66}(5), +#' 1-21.\cr\cr Bates DM and Watts DG (1988) Nonlinear regression analysis and +#' its applications. Wiley, Chichester, UK. +#' @keywords nonlinear +#' @examples +#' +#' formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * +#' (VO2rest + (VO2peak - VO2rest) * +#' (1 - exp(-(t - 5.883) / mu)))) +#' preview(formulaExp, O2K, list(VO2rest = 400, VO2peak = 1600, mu = 1)) +#' O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, +#' mu = 1), data = O2K) +#' overview(O2K.nls1) +#' plotfit(O2K.nls1, smooth = TRUE) +#' +#' @export - "formula2function"<-function(formu){ +preview <- function(formula, data, start, variable=1){ + + formula2function <- function(formu){ arg1 <- all.vars(formu) arg2 <- vector("list",length(arg1)) names(arg2) <- arg1 @@ -21,7 +87,11 @@ } -"plotfit" <- function(x, smooth=FALSE, variable=1, xlab=NULL, ylab=NULL, pch.obs=1, pch.fit="+", lty=1, lwd=1, col.obs="black", col.fit="red", ...){ +#' @rdname preview +#' @importFrom graphics plot lines points +#' @importFrom stats formula predict +#' @export +plotfit <- function(x, smooth=FALSE, variable=1, xlab=NULL, ylab=NULL, pch.obs=1, pch.fit="+", lty=1, lwd=1, col.obs="black", col.fit="red", ...){ if (!inherits(x, "nls")) stop("Use only with 'nls' objects") d <- eval(x$call$data, sys.frame(0)) @@ -46,7 +116,9 @@ } } -"overview" <- function(x){ +#' @rdname preview +#' @export +overview <- function(x){ if (!inherits(x, "nls")) stop("Use only with 'nls' objects") cat("\n------") diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..008099b --- /dev/null +++ b/README.Rmd @@ -0,0 +1,41 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# nlstools: Tools for Nonlinear Regression Analysis + + +[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/nlstools)](https://cran.r-project.org/package=nlstools) +[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/nlstools)](https://cran.r-project.org/package=nlstools) +[![R-CMD-check](https://github.com/aursiber/nlstools/workflows/R-CMD-check/badge.svg)](https://github.com/aursiber/nlstools/actions) + + +The stable version of `nlstools` can be installed from CRAN using: +```r +install.packages("nlstools") +``` + +The development version of `nlstools` can be installed from GitHub (`remotes` needed): +```r +if (!requireNamespace("remotes", quietly = TRUE)) + install.packages("remotes") + +remotes::install_github("aursiber/nlstools") +``` + +Finally load the package in your current R session with the following R command: +```r +library(nlstools) +``` + diff --git a/README.md b/README.md index d24899d..8bcc173 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,35 @@ -[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/nlstools)](https://cran.r-project.org/package=nlstools) -[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/nlstools)](https://cran.r-project.org/package=nlstools) + + + +# nlstools: Tools for Nonlinear Regression Analysis + + + +[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/nlstools)](https://cran.r-project.org/package=nlstools) +[![CRAN +Downloads](https://cranlogs.r-pkg.org/badges/nlstools)](https://cran.r-project.org/package=nlstools) [![R-CMD-check](https://github.com/aursiber/nlstools/workflows/R-CMD-check/badge.svg)](https://github.com/aursiber/nlstools/actions) + The stable version of `nlstools` can be installed from CRAN using: -```r + +``` r install.packages("nlstools") ``` -The development version of `nlstools` can be installed from GitHub (`remotes` needed): -```r +The development version of `nlstools` can be installed from GitHub +(`remotes` needed): + +``` r if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") remotes::install_github("aursiber/nlstools") -``` +``` + +Finally load the package in your current R session with the following R +command: -Finally load the package in your current R session with the following R command: -```r +``` r library(nlstools) ``` diff --git a/man/L.minor.Rd b/man/L.minor.Rd index 56c522e..5afd110 100644 --- a/man/L.minor.Rd +++ b/man/L.minor.Rd @@ -1,34 +1,25 @@ -\name{L.minor} - -\alias{L.minor} - -\docType{data} - -\title{Enzyme kinetics} - -\description{ - Enzyme kinetics -} - -\usage{data(L.minor)} - -\format{ - A data frame with 8 observations on the following 2 variables. - \describe{ - \item{\code{conc}}{a numeric vector} - \item{\code{rate}}{a numeric vector} - } -} - -%\details{} - -\source{ - Cedergreen, N. and Madsen, T. V. (2002) Nitrogen uptake by the floating macrophyte \emph{Lemna minor}, - \emph{New Phytologist}, \bold{155}, 285--292. -} - -%\references{} - -%\examples{} - -\keyword{datasets} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{L.minor} +\alias{L.minor} +\title{Enzyme kinetics} +\format{ +A data frame with 8 observations on the following 2 variables. +\describe{ + \item{conc}{a numeric vector} + \item{rate}{a numeric vector} +} +} +\source{ +Cedergreen, N. and Madsen, T. V. (2002) Nitrogen uptake by the +floating macrophyte \emph{Lemna minor}, \emph{New Phytologist}, \bold{155}, +285--292. +} +\usage{ +L.minor +} +\description{ +Enzyme kinetics +} +\keyword{datasets} diff --git a/man/O2K.Rd b/man/O2K.Rd index 1d3a370..352f6d5 100644 --- a/man/O2K.Rd +++ b/man/O2K.Rd @@ -1,30 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{O2K} \alias{O2K} -\docType{data} -%- Also NEED an '\alias' for EACH other topic documented here. - -\title{ Oxygen kinetics during 6-minute walk test data set } - -\description{ -Oxygen uptake kinetics during a 6-minute walking test in a patient with pulmonary disease. The first 5.83 minutes correspond to the resting phase prior to exercise. +\title{Oxygen kinetics during 6-minute walk test data set} +\format{ +\code{O2K} is a data frame with 2 columns (t: time, VO2: oxygen +uptake)\cr +} +\source{ +This data set was provided by the Cantonal Hospital St. Gallen, +Switzerland. } - \usage{ -data(O2K) +O2K } -%- maybe also 'usage' for other objects documented here. - -\format{ -\code{O2K} is a data frame with 2 columns (t: time, VO2: oxygen uptake)\cr +\description{ +Oxygen uptake kinetics during a 6-minute walking test in a patient with +pulmonary disease. The first 5.83 minutes correspond to the resting phase +prior to exercise. } - -\source{ This data set was provided by the Cantonal Hospital St. Gallen, Switzerland. } - -%\references{ } - \examples{ + data(O2K) plot(O2K) -} -\keyword{ datasets }% at least one, from doc/KEYWORDS +} +\keyword{datasets} diff --git a/man/confint2.Rd b/man/confint2.Rd index 3f34a22..7ec10e0 100644 --- a/man/confint2.Rd +++ b/man/confint2.Rd @@ -1,55 +1,50 @@ -\name{confint2} - -\alias{confint2} - -\title{Confidence intervals in nonlinear regression} - -\description{ - Produces confidence intervals for the parameters in nonlinear regression model fit. The intervals - can either be based large sample results or on profiling. -} - -\usage{ - confint2(object, parm, level = 0.95, method = c("asymptotic", "profile"), ...) -} - -\arguments{ - \item{object}{object of class \code{\link{nls}}.} - \item{parm}{a vector character strings with names of the parameter for which to calculate - confidence intervals (by default all parameters).} - \item{level}{the confidence level required.} - \item{method}{method to be used: "asympotic" for large sample and "profile" for profiling approach.} - \item{\dots}{additional argument(s) to pass on the method doing the profiling.} -} - -\details{ - The profiling used is the method \code{\link[MASS]{confint.nls}.} -} - -\value{ - A matrix with columns giving lower and upper confidence limits for each parameter. -} - -%\references{} - -\author{Christian Ritz} - -%\note{} - -%\seealso{} - -\examples{ - -L.minor.m1 <- nls(rate ~ Vm*conc/(K+conc), data = L.minor, start = list(K=20, Vm=120)) - -confint2(L.minor.m1) - -confint2(L.minor.m1, "K") - -} - -\keyword{models} -\keyword{nonlinear} - -%\concept{} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/confint2.R +\name{confint2} +\alias{confint2} +\title{Confidence intervals in nonlinear regression} +\usage{ +confint2(object, parm, level = 0.95, method = c("asymptotic", "profile"), ...) +} +\arguments{ +\item{object}{object of class \code{\link{nls}}.} + +\item{parm}{a vector character strings with names of the parameter for which +to calculate confidence intervals (by default all parameters).} + +\item{level}{the confidence level required.} + +\item{method}{method to be used: "asympotic" for large sample and "profile" +for profiling approach.} + +\item{\dots}{additional argument(s) to pass on the method doing the +profiling.} +} +\value{ +A matrix with columns giving lower and upper confidence limits for +each parameter. +} +\description{ +Produces confidence intervals for the parameters in nonlinear regression +model fit. The intervals can either be based large sample results or on +profiling. +} +\details{ +The profiling used is the method \code{\link[MASS]{confint.nls}.} +} +\examples{ + + +L.minor.m1 <- nls(rate ~ Vm*conc/(K+conc), data = L.minor, start = list(K=20, Vm=120)) + +confint2(L.minor.m1) + +confint2(L.minor.m1, "K") + + +} +\author{ +Christian Ritz +} +\keyword{models} +\keyword{nonlinear} diff --git a/man/michaelis.Rd b/man/michaelis.Rd new file mode 100644 index 0000000..d0499cb --- /dev/null +++ b/man/michaelis.Rd @@ -0,0 +1,92 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/michaelismodels.R +\docType{data} +\name{michaelis} +\alias{michaelis} +\alias{michaelismodels} +\alias{compet_mich} +\alias{non_compet_mich} +\title{Michaelis-Menten model and derived equations to model competitive and +non-competitive inhibition} +\format{ +An object of class \code{formula} of length 3. + +An object of class \code{formula} of length 3. + +An object of class \code{formula} of length 3. +} +\usage{ +michaelis + +compet_mich + +non_compet_mich +} +\value{ +A formula +} +\description{ +Formula of Michaelis-Menten model commonly used to describe enzyme kinetics, +and derived formulas taking into account the effect of a competitive or a +non-competitive inhibitor +} +\details{ +These models describe the evolution of the reaction rate (v) as a function +of the concentration of substrate (S) and the concentration of inhibitor (I) +for \code{compet_mich} and \code{non_compet_mich}. + +\code{michaelis} is the classical Michaelis-Menten model (Dixon, 1979) with +two parameters (Km, Vmax) : \deqn{v = \frac{S}{S+K_m} V_{max}}{v = +S/(S+Km)*Vmax} \cr\cr + +\code{compet_mich} is the Michaelis-Menten derived +model with three parameters (Km, Vmax, Ki), describing a competitive +inhibition : \deqn{v = \frac{S}{S + K_m (1+\frac{I}{K_i})} V_{max}}{v = S/(S ++ Km*(1+I/Ki) ) * Vmax} \cr\cr + +\code{non_compet_mich} is the +Michaelis-Menten derived model with three parameters (Km, Vmax, Ki), +describing a non-competitive inhibition : \deqn{v = +\frac{S}{(S+K_m)(1+\frac{I}{Ki})} V_{max}}{v = S/( (S + Km)*(1+I/Ki) ) * +Vmax} \cr\cr +} +\examples{ + + +# Example 1 + +data(vmkm) +nls1 <- nls(michaelis,vmkm,list(Km=1,Vmax=1)) +plotfit(nls1, smooth = TRUE) + +# Example 2 + +data(vmkmki) +def.par <- par(no.readonly = TRUE) +par(mfrow = c(2,2)) + +nls2_c <- nls(compet_mich, vmkmki, list(Km=1,Vmax=20,Ki=0.5)) +plotfit(nls2_c, variable=1) +overview(nls2_c) +res2_c <- nlsResiduals(nls2_c) +plot(res2_c, which=1) + +nls2_nc <- nls(non_compet_mich, vmkmki, list(Km=1, Vmax=20, Ki=0.5)) +plotfit(nls2_nc, variable=1) +overview(nls2_nc) +res2_nc <- nlsResiduals(nls2_nc) +plot(res2_nc, which=1) + +par(def.par) + +} +\references{ +Dixon M and Webb EC (1979) \emph{Enzymes}, Academic Press, New +York. +} +\author{ +Florent Baty \email{florent.baty@gmail.com}\cr Marie-Laure +Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +} +\keyword{datasets} +\keyword{models} diff --git a/man/michaelisdata.Rd b/man/michaelisdata.Rd deleted file mode 100644 index 24cd33c..0000000 --- a/man/michaelisdata.Rd +++ /dev/null @@ -1,35 +0,0 @@ -\name{michaelisdata} -\alias{vmkm} -\alias{vmkmki} -\docType{data} -%- Also NEED an '\alias' for EACH other topic documented here. - -\title{ Michaelis Menten data sets } - -\description{ -Michaelis Menten data sets -} - -\usage{ -data(vmkm) -data(vmkmki) -} -%- maybe also 'usage' for other objects documented here. - -\format{ -\code{vmkm} is a data frame with 2 columns (S: concentration of substrat, v: reaction rate)\cr -\code{vmkmki} is a data frame with 3 columns (S: concentration of substrat, I: concentration of inhibitor, v: reaction rate) -} - -\source{ These datasets were provided by the French research unit INRA UMR1233. } - -%\references{ } - -\examples{ -data(vmkm) -data(vmkmki) -plot(vmkm) -plot(vmkmki) -} - -\keyword{ datasets }% at least one, from doc/KEYWORDS diff --git a/man/michaelismodels.Rd b/man/michaelismodels.Rd deleted file mode 100644 index 493f4b8..0000000 --- a/man/michaelismodels.Rd +++ /dev/null @@ -1,80 +0,0 @@ -\name{michaelismodels} -\alias{michaelismodels} -\alias{michaelis} -\alias{compet_mich} -\alias{non_compet_mich} -%- Also NEED an '\alias' for EACH other topic documented here. -\title{ Michaelis-Menten model and derived equations to model competitive and non-competitive inhibition } -\description{ - Formula of Michaelis-Menten model commonly used to describe enzyme kinetics, and derived formulas taking into account the - effect of a competitive or a non-competitive inhibitor - } -\usage{ -michaelis -compet_mich -non_compet_mich -} - -%- maybe also 'usage' for other objects documented here. - -%\arguments{ } - -\details{ - - These models describe the evolution of the reaction rate (v) as a function - of the concentration of substrate (S) and the concentration of inhibitor (I) for \code{compet_mich} and \code{non_compet_mich}. - - \code{michaelis} is the classical Michaelis-Menten model (Dixon, 1979) with two parameters (Km, Vmax) : - \deqn{v = \frac{S}{S+K_m} V_{max}}{v = S/(S+Km)*Vmax} \cr\cr - \code{compet_mich} is the Michaelis-Menten derived model with three parameters (Km, Vmax, Ki), describing - a competitive inhibition : \deqn{v = \frac{S}{S + K_m (1+\frac{I}{K_i})} V_{max}}{v = S/(S + Km*(1+I/Ki) ) * Vmax} \cr\cr - \code{non_compet_mich} is the Michaelis-Menten derived model with three parameters (Km, Vmax, Ki), describing - a non-competitive inhibition : \deqn{v = \frac{S}{(S+K_m)(1+\frac{I}{Ki})} V_{max}}{v = S/( (S + Km)*(1+I/Ki) ) * Vmax} \cr\cr -} - -\value{ - A formula -} - -\references{ -Dixon M and Webb EC (1979) \emph{Enzymes}, Academic Press, New York. -} - -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} -} - -%\note{ } - -\examples{ - -# Example 1 - -data(vmkm) -nls1 <- nls(michaelis,vmkm,list(Km=1,Vmax=1)) -plotfit(nls1, smooth = TRUE) - -# Example 2 - -data(vmkmki) -def.par <- par(no.readonly = TRUE) -par(mfrow = c(2,2)) - -nls2_c <- nls(compet_mich, vmkmki, list(Km=1,Vmax=20,Ki=0.5)) -plotfit(nls2_c, variable=1) -overview(nls2_c) -res2_c <- nlsResiduals(nls2_c) -plot(res2_c, which=1) - -nls2_nc <- nls(non_compet_mich, vmkmki, list(Km=1, Vmax=20, Ki=0.5)) -plotfit(nls2_nc, variable=1) -overview(nls2_nc) -res2_nc <- nlsResiduals(nls2_nc) -plot(res2_nc, which=1) - -par(def.par) - - } - -\keyword{ models }% at least one, from doc/KEYWORDS diff --git a/man/nlsBoot.Rd b/man/nlsBoot.Rd index d8ce7cd..055b274 100644 --- a/man/nlsBoot.Rd +++ b/man/nlsBoot.Rd @@ -1,63 +1,71 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlsBoot.R \name{nlsBoot} \alias{nlsBoot} \alias{plot.nlsBoot} \alias{print.nlsBoot} \alias{summary.nlsBoot} -%- Also NEED an '\alias' for EACH other topic documented here. +\title{Bootstrap resampling} +\usage{ +nlsBoot(nls, niter = 999) -\title{ Bootstrap resampling } +\method{plot}{nlsBoot}( + x, + type = c("pairs", "boxplot"), + mfr = c(ceiling(sqrt(ncol(x$coefboot))), ceiling(sqrt(ncol(x$coefboot)))), + ask = FALSE, + ... +) -\description{ -Bootstrap resampling -} +\method{print}{nlsBoot}(x, ...) -\usage{ -nlsBoot (nls, niter = 999) -\method{plot}{nlsBoot} (x, type = c("pairs", "boxplot"), - mfr = c(ceiling(sqrt(ncol(x$coefboot))), - ceiling(sqrt(ncol(x$coefboot)))), - ask = FALSE, \dots) -\method{print}{nlsBoot} (x, \dots) -\method{summary}{nlsBoot} (object, \dots) +\method{summary}{nlsBoot}(object, ...) } - -%- maybe also 'usage' for other objects documented here. - \arguments{ - \item{nls}{ an object of class 'nls' } - \item{niter}{ number of iterations } - \item{x, object}{ an object of class 'nlsBoot' } - \item{type}{ type of representation (options are "pairs" or "boxplot")} - \item{mfr}{ layout definition (number of rows and columns in the graphics device) } - \item{ask}{ if TRUE, draw plot interactively } - \item{...}{ further arguments passed to or from other methods } -} +\item{nls}{an object of class 'nls'} -\details{ - Non-parametric bootstrapping is used. Mean centered residuals are bootstrapped. By default, 999 resampled data sets are created from which parameter estimates are obtained by fitting the model on each of these data sets. Whenever the fit fails to converge, a flag reports the number of non-convergences. If the fitting procedure fails to converge in more than 50\% of the cases, the procedure is interrupted with a flag and no result is given. The function \code{summary} returns the bootstrap estimates (mean and std. dev. of the bootstrapped estimates) and the median and 95 percent confidence intervals (50, 2.5, and 97.5 percentiles of the bootstrapped estimates). The bootstrapped estimate distributions can be visualized using the function \code{plot.nlsBoot} either by plotting the bootstrapped sample for each pair of parameters or by displaying the boxplot representation of the bootstrapped sample for each parameter. Notice that \code{nlsBoot} does not currently handle transformed dependent variables specified in the left side of the \code{nls} formula. -} +\item{niter}{number of iterations} -\value{ - \code{nlsBoot} returns a list of 4 objects: - \item{ coefboot }{ contains the bootstrap parameter estimates } - \item{ bootCI }{ contains the bootstrap medians and the bootstrap 95\% confidence intervals } - \item{ estiboot }{ contains the means and std. errors of the bootstrap parameter estimates } - \item{ rse }{ is the vector of bootstrap residual errors } -} +\item{x, object}{an object of class 'nlsBoot'} -\references{ -Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK.\cr\cr -Huet S, Bouvier A, Poursat M-A, Jolivet E (2003) Statistical tools for nonlinear regression: a practical guide with S-PLUS and R examples. Springer, Berlin, Heidelberg, New York. -} +\item{type}{type of representation (options are "pairs" or "boxplot")} -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} -} +\item{mfr}{layout definition (number of rows and columns in the graphics +device)} -%\note{ } +\item{ask}{if TRUE, draw plot interactively} +\item{...}{further arguments passed to or from other methods} +} +\value{ +\code{nlsBoot} returns a list of 4 objects: \item{ coefboot }{ +contains the bootstrap parameter estimates } \item{ bootCI }{ contains the +bootstrap medians and the bootstrap 95\% confidence intervals } \item{ +estiboot }{ contains the means and std. errors of the bootstrap parameter +estimates } \item{ rse }{ is the vector of bootstrap residual errors } +} +\description{ +Bootstrap resampling +} +\details{ +Non-parametric bootstrapping is used. Mean centered residuals are +bootstrapped. By default, 999 resampled data sets are created from which +parameter estimates are obtained by fitting the model on each of these data +sets. Whenever the fit fails to converge, a flag reports the number of +non-convergences. If the fitting procedure fails to converge in more than +50\% of the cases, the procedure is interrupted with a flag and no result is +given. The function \code{summary} returns the bootstrap estimates (mean and +std. dev. of the bootstrapped estimates) and the median and 95 percent +confidence intervals (50, 2.5, and 97.5 percentiles of the bootstrapped +estimates). The bootstrapped estimate distributions can be visualized using +the function \code{plot.nlsBoot} either by plotting the bootstrapped sample +for each pair of parameters or by displaying the boxplot representation of +the bootstrapped sample for each parameter. Notice that \code{nlsBoot} does +not currently handle transformed dependent variables specified in the left +side of the \code{nls} formula. +} \examples{ + formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2res + (t > 5.883) * (VO2res + (VO2peak - VO2res) * (1 - exp(-(t - 5.883) / mu)))) @@ -67,6 +75,17 @@ O2K.boot1 <- nlsBoot(O2K.nls1, niter = 200) plot(O2K.boot1) plot(O2K.boot1, type = "boxplot", ask = FALSE) summary(O2K.boot1) - } - -\keyword{ nonlinear }% at least one, from doc/KEYWORDS + +} +\references{ +Bates DM and Watts DG (1988) Nonlinear regression analysis and +its applications. Wiley, Chichester, UK.\cr\cr Huet S, Bouvier A, Poursat +M-A, Jolivet E (2003) Statistical tools for nonlinear regression: a +practical guide with S-PLUS and R examples. Springer, Berlin, Heidelberg, +New York. +} +\author{ +Florent Baty \email{florent.baty@gmail.com}\cr Marie-Laure +Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +} +\keyword{nonlinear} diff --git a/man/nlsConfRegions.Rd b/man/nlsConfRegions.Rd index 51b5aa6..c3b117f 100644 --- a/man/nlsConfRegions.Rd +++ b/man/nlsConfRegions.Rd @@ -1,62 +1,62 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlsConfRegions.R \name{nlsConfRegions} \alias{nlsConfRegions} \alias{plot.nlsConfRegions} \alias{print.nlsConfRegions} -%- Also NEED an '\alias' for EACH other topic documented here. +\title{Confidence regions} +\usage{ +nlsConfRegions(nls, length = 1000, exp = 1.5) -\title{ Confidence regions } +\method{plot}{nlsConfRegions}(x, bounds = FALSE, ask = FALSE, ...) -\description{ - Draws parameter values in the Beale's 95 percent unlinearized confidence region +\method{print}{nlsConfRegions}(x, ...) } +\arguments{ +\item{nls}{an object of class 'nls'} -\usage{ -nlsConfRegions (nls, length = 1000, exp = 1.5) -\method{plot}{nlsConfRegions} (x, bounds = FALSE, ask = FALSE, \dots) -\method{print}{nlsConfRegions} (x, \dots) -} +\item{length}{number of points to draw in the confidence region} -%- maybe also 'usage' for other objects documented here. +\item{exp}{expansion factor of the hypercube in which random values of +parameters are drawn} -\arguments{ - \item{nls}{ an object of class 'nls' } - \item{length}{ number of points to draw in the confidence region } - \item{exp}{ expansion factor of the hypercube in which random values of parameters are drawn } - \item{x}{ an object of class 'nlsConfRegions' } - \item{bounds}{ logical defining whether bounds of the drawing hypercube are plotted } - \item{ask}{ if TRUE, draw plot interactively } - \item{...}{ further arguments passed to or from other methods } -} +\item{x}{an object of class 'nlsConfRegions'} -\details{ - A sample of points in the 95 percent confidence region is computed according to Beale's criterion (Beale, 1960). This region is also named the joint parameter likelihood region (Bates and Watts, 1988). The method used consists in a random sampling of parameters values in a hypercube centered on the least squares estimate and rejecting the parameters values whose residual sum of squares do not verify the Beale criterion. The confidence region is plotted by projection of the sampled points in each plane defined by a couple of parameters. Bounds of the hypercube in which random values of parameters are drawn may be plotted in order to check if the confidence region was totally included in the hypercube defined by default. If not the hypercube should be expanded in order to obtain the full confidence region -} +\item{bounds}{logical defining whether bounds of the drawing hypercube are +plotted} -\value{ - \code{nlsConfRegions} returns a list of four objects: - \item{ cr }{ a data frame containing the sample drawn in the Beale's confidence region } - \item{ rss }{ a vector containing the residual sums of squares corresponding to \code{cr} } - \item{ rss95 }{ the 95 percent residual sum of squares threshold according to Beale (1960) } - \item{ bounds }{ lower and upper bounds of the hypercube in which random values of parameters have been drawn } -} +\item{ask}{if TRUE, draw plot interactively} -\seealso{ -\code{ellipse.nls} in the \code{ellipse} library +\item{...}{further arguments passed to or from other methods} } - -\references{ -Beale EML (1960) Confidence regions in non-linear estimations. \emph{Journal of the Royal Statistical Society}, \bold{22B}, 41-88.\cr\cr -Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK. +\value{ +\code{nlsConfRegions} returns a list of four objects: \item{ cr }{ a +data frame containing the sample drawn in the Beale's confidence region } +\item{ rss }{ a vector containing the residual sums of squares corresponding +to \code{cr} } \item{ rss95 }{ the 95 percent residual sum of squares +threshold according to Beale (1960) } \item{ bounds }{ lower and upper +bounds of the hypercube in which random values of parameters have been drawn } - -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} } - -%\note{ } - +\description{ +Draws parameter values in the Beale's 95 percent unlinearized confidence +region +} +\details{ +A sample of points in the 95 percent confidence region is computed according +to Beale's criterion (Beale, 1960). This region is also named the joint +parameter likelihood region (Bates and Watts, 1988). The method used +consists in a random sampling of parameters values in a hypercube centered +on the least squares estimate and rejecting the parameters values whose +residual sum of squares do not verify the Beale criterion. The confidence +region is plotted by projection of the sampled points in each plane defined +by a couple of parameters. Bounds of the hypercube in which random values of +parameters are drawn may be plotted in order to check if the confidence +region was totally included in the hypercube defined by default. If not the +hypercube should be expanded in order to obtain the full confidence region +} \examples{ + formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * (VO2rest + (VO2peak - VO2rest) * (1 - exp(-(t - 5.883) / mu)))) @@ -64,6 +64,19 @@ O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, mu = 1), data = O2K) O2K.conf1 <- nlsConfRegions(O2K.nls1, exp = 2, length = 200) plot(O2K.conf1, bounds = TRUE) -} -\keyword{ nonlinear }% at least one, from doc/KEYWORDS +} +\references{ +Beale EML (1960) Confidence regions in non-linear estimations. +\emph{Journal of the Royal Statistical Society}, \bold{22B}, 41-88.\cr\cr +Bates DM and Watts DG (1988) Nonlinear regression analysis and its +applications. Wiley, Chichester, UK. +} +\seealso{ +\code{ellipse.nls} in the \code{ellipse} library +} +\author{ +Florent Baty \email{florent.baty@gmail.com}\cr Marie-Laure +Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +} +\keyword{nonlinear} diff --git a/man/nlsContourRSS.Rd b/man/nlsContourRSS.Rd index 1928b02..764b45c 100644 --- a/man/nlsContourRSS.Rd +++ b/man/nlsContourRSS.Rd @@ -1,61 +1,72 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlsContourRSS.R \name{nlsContourRSS} \alias{nlsContourRSS} \alias{plot.nlsContourRSS} \alias{print.nlsContourRSS} -%- Also NEED an '\alias' for EACH other topic documented here. +\title{Surface contour of RSS} +\usage{ +nlsContourRSS(nls, lseq = 100, exp = 2) -\title{ Surface contour of RSS } +\method{plot}{nlsContourRSS}( + x, + nlev = 0, + col = TRUE, + col.pal = terrain.colors(100), + ask = FALSE, + useRaster = TRUE, + ... +) -\description{ -Provides residual sum of squares (RSS) contours +\method{print}{nlsContourRSS}(x, ...) } +\arguments{ +\item{nls}{an object of class 'nls'} -\usage{ -nlsContourRSS (nls, lseq = 100, exp = 2) -\method{plot}{nlsContourRSS} (x, nlev = 0, col = TRUE, col.pal = terrain.colors(100), - ask = FALSE, useRaster = TRUE, \dots) -\method{print}{nlsContourRSS} (x, \dots) -} +\item{lseq}{length of the sequences of parameters} -%- maybe also 'usage' for other objects documented here. +\item{exp}{expansion factor of the parameter intervals defining the grids} -\arguments{ - \item{nls}{ an object of class 'nls' } - \item{lseq}{ length of the sequences of parameters } - \item{exp}{ expansion factor of the parameter intervals defining the grids } - \item{nlev}{ number of contour levels to add to the likelihood contour at level 95 percent } - \item{col}{ logical. Contours are plotted with colors if \code{TRUE} } - \item{col.pal}{ Palette of colors. Colors to be used as background (default is terrain.colors(100); unused if col is FALSE) } - \item{x}{ an object of class 'nlsContourRSS' } - \item{ask}{ if TRUE, draw plot interactively (default is FALSE) } - \item{useRaster}{ a bitmap raster is used to plot the image instead of polygons (default is TRUE) } - \item{...}{ further arguments passed to or from other methods } -} +\item{x}{an object of class 'nlsContourRSS'} -\details{ -The aim of these functions is to plot the residual sum of squares (RSS) contours which correspond to likelihood contours for a Gaussian model. For each pair of parameters the RSS is calculated on a grid centered on the least squares estimates of both parameters, the other parameters being fixed to their least square estimates. The contours of RSS values are then plotted for each pair of parameters. For each pair of parameters, one of this contour corresponds to a section of the 95 percent Beale's confidence region in the plane of these parameters. This contour is plotted in a different color. -} +\item{nlev}{number of contour levels to add to the likelihood contour at +level 95 percent} -\value{ - \code{nlsContourRSS} returns a list of three objects: - \item{ seqPara }{ a matrix with the sequence of grid values for each parameter } - \item{ lrss }{ a list of matrices with logarithm values of RSS in the grid for each pair of parameters } - \item{ lrss95 }{ the logarithm of the 95 percent residual sum of squares threshold according to Beale (1960) } -} +\item{col}{logical. Contours are plotted with colors if \code{TRUE}} -\references{ -Beale EML (1960) Confidence regions in non-linear estimations. \emph{Journal of the Royal Statistical Society}, \bold{22B}, 41-88.\cr\cr -Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK.\cr -} +\item{col.pal}{Palette of colors. Colors to be used as background (default +is terrain.colors(100); unused if col is FALSE)} -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} -} +\item{ask}{if TRUE, draw plot interactively (default is FALSE)} -%\note{ } +\item{useRaster}{a bitmap raster is used to plot the image instead of +polygons (default is TRUE)} +\item{...}{further arguments passed to or from other methods} +} +\value{ +\code{nlsContourRSS} returns a list of three objects: \item{ seqPara +}{ a matrix with the sequence of grid values for each parameter } \item{ +lrss }{ a list of matrices with logarithm values of RSS in the grid for each +pair of parameters } \item{ lrss95 }{ the logarithm of the 95 percent +residual sum of squares threshold according to Beale (1960) } +} +\description{ +Provides residual sum of squares (RSS) contours +} +\details{ +The aim of these functions is to plot the residual sum of squares (RSS) +contours which correspond to likelihood contours for a Gaussian model. For +each pair of parameters the RSS is calculated on a grid centered on the +least squares estimates of both parameters, the other parameters being fixed +to their least square estimates. The contours of RSS values are then plotted +for each pair of parameters. For each pair of parameters, one of this +contour corresponds to a section of the 95 percent Beale's confidence region +in the plane of these parameters. This contour is plotted in a different +color. +} \examples{ + formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * (VO2rest + (VO2peak - VO2rest) * (1 - exp(-(t - 5.883) / mu)))) @@ -63,6 +74,16 @@ O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, mu = 1), data = O2K) O2K.cont1 <- nlsContourRSS(O2K.nls1) plot(O2K.cont1) -} -\keyword{ nonlinear }% at least one, from doc/KEYWORDS +} +\references{ +Beale EML (1960) Confidence regions in non-linear estimations. +\emph{Journal of the Royal Statistical Society}, \bold{22B}, 41-88.\cr\cr +Bates DM and Watts DG (1988) Nonlinear regression analysis and its +applications. Wiley, Chichester, UK.\cr +} +\author{ +Florent Baty \email{florent.baty@gmail.com}\cr Marie-Laure +Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +} +\keyword{nonlinear} diff --git a/man/nlsJack.Rd b/man/nlsJack.Rd index d8e3adc..73b3f44 100644 --- a/man/nlsJack.Rd +++ b/man/nlsJack.Rd @@ -1,55 +1,66 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlsJack.R \name{nlsJack} \alias{nlsJack} \alias{plot.nlsJack} \alias{print.nlsJack} \alias{summary.nlsJack} -%- Also NEED an '\alias' for EACH other topic documented here. -\title{ Jackknife resampling } -\description{ - Jackknife resampling - } +\title{Jackknife resampling} \usage{ -nlsJack (nls) -\method{plot}{nlsJack} (x, mfr = c(nrow(x$reldif),1), ask = FALSE, \dots) -\method{print}{nlsJack} (x, \dots) -\method{summary}{nlsJack} (object, \dots) +nlsJack(nls) + +\method{plot}{nlsJack}(x, mfr = c(nrow(x$reldif), 1), ask = FALSE, ...) + +\method{print}{nlsJack}(x, ...) + +\method{summary}{nlsJack}(object, ...) } -%- maybe also 'usage' for other objects documented here. \arguments{ - \item{nls}{ an object of class 'nls' } - \item{x, object}{ an object of class 'nlsJack' } - \item{mfr}{ layout definition, default is k rows (k: number of parameters) and 1 column } - \item{ask}{ if TRUE, draw plot interactively } - \item{...}{ further arguments passed to or from other methods } -} +\item{nls}{an object of class 'nls'} -\value{ - \code{nlsJack} returns a list with 7 objects: - \item{ estijack }{ a data frame with jackknife estimates and bias } - \item{ coefjack }{ a data frame with the parameter estimates for each jackknife sample } - \item{ reldif }{ a data frame with the absolute relative difference (in percent of the estimate) of the estimates with and without each observation } - \item{ dfb }{ a data frame with dfbetas for each parameter and each observation } - \item{ jackCI }{ a data frame with jackknife confidence intervals } - \item{ rse }{ a vector with residual standard error for each jackknife sample } - \item{ rss }{ residual a vector with residual sum of squares for each jackknife sample } -} +\item{x, object}{an object of class 'nlsJack'} -\details{ +\item{mfr}{layout definition, default is k rows (k: number of parameters) +and 1 column} - A jackknife resampling procedure is performed. Each observation is sequentially removed from the initial data set using a leave-one-out strategy. A data set with \emph{n} observations provides thus \emph{n} resampled data sets of \emph{n-1} observations. The jackknife estimates with confidence intervals are calculated as described by Seber and Wild (1989) from the results of \emph{n} new fits of the model on the \emph{n} jackknife resampled data sets. The leave-one-out procedure is also employed to assess the influence of each observation on each parameter estimate. An observation is empirically defined as influential for one parameter if the difference between the estimate of this parameter with and without the observation exceeds twice the standard error of the estimate divided by \emph{sqrt(n)}. This empirical method assumes a small curvature of the nonlinear model. For each parameter, the absolute relative difference (in percent of the estimate) of the estimates with and without each observation is plotted. An asterisk is plotted for each influential observation. -} +\item{ask}{if TRUE, draw plot interactively} -\references{ - Seber GAF, Wild CJ (1989) Nonlinear regression. Wiley, New York.\cr\cr +\item{...}{further arguments passed to or from other methods} } -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +\value{ +\code{nlsJack} returns a list with 7 objects: \item{ estijack }{ a +data frame with jackknife estimates and bias } \item{ coefjack }{ a data +frame with the parameter estimates for each jackknife sample } \item{ reldif +}{ a data frame with the absolute relative difference (in percent of the +estimate) of the estimates with and without each observation } \item{ dfb }{ +a data frame with dfbetas for each parameter and each observation } \item{ +jackCI }{ a data frame with jackknife confidence intervals } \item{ rse }{ a +vector with residual standard error for each jackknife sample } \item{ rss +}{ residual a vector with residual sum of squares for each jackknife sample +} +} +\description{ +Jackknife resampling +} +\details{ +A jackknife resampling procedure is performed. Each observation is +sequentially removed from the initial data set using a leave-one-out +strategy. A data set with \emph{n} observations provides thus \emph{n} +resampled data sets of \emph{n-1} observations. The jackknife estimates with +confidence intervals are calculated as described by Seber and Wild (1989) +from the results of \emph{n} new fits of the model on the \emph{n} jackknife +resampled data sets. The leave-one-out procedure is also employed to assess +the influence of each observation on each parameter estimate. An observation +is empirically defined as influential for one parameter if the difference +between the estimate of this parameter with and without the observation +exceeds twice the standard error of the estimate divided by \emph{sqrt(n)}. +This empirical method assumes a small curvature of the nonlinear model. For +each parameter, the absolute relative difference (in percent of the +estimate) of the estimates with and without each observation is plotted. An +asterisk is plotted for each influential observation. } - -%\note{ } - \examples{ + formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * (VO2rest + (VO2peak - VO2rest) * (1 - exp(-(t - 5.883) / mu)))) @@ -58,6 +69,14 @@ O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, mu = 1), O2K.jack1 <- nlsJack(O2K.nls1) plot(O2K.jack1) summary(O2K.jack1) -} -\keyword{ nonlinear }% at least one, from doc/KEYWORDS +} +\references{ +Seber GAF, Wild CJ (1989) Nonlinear regression. Wiley, New +York.\cr\cr +} +\author{ +Florent Baty \email{florent.baty@gmail.com}\cr Marie-Laure +Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +} +\keyword{nonlinear} diff --git a/man/nlsResiduals.Rd b/man/nlsResiduals.Rd index 8dd02c6..06f6810 100644 --- a/man/nlsResiduals.Rd +++ b/man/nlsResiduals.Rd @@ -1,72 +1,63 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlsResiduals.R \name{nlsResiduals} \alias{nlsResiduals} \alias{plot.nlsResiduals} -%\alias{boxplot.nlsResiduals} -%\alias{hist.nlsResiduals} -%\alias{qq.nlsResiduals} \alias{test.nlsResiduals} \alias{print.nlsResiduals} -%- Also NEED an '\alias' for EACH other topic documented here. +\title{NLS residuals} +\usage{ +nlsResiduals(nls) -\title{ NLS residuals } +\method{plot}{nlsResiduals}(x, which = 0, ...) -\description{ - Provides several plots and tests for the analysis of residuals -} +test.nlsResiduals(x) -\usage{ -nlsResiduals (nls) -\method{plot}{nlsResiduals} (x, which = 0, \dots) -%\method{boxplot}{nlsResiduals} (x, \dots) -%\method{hist}{nlsResiduals} (x, \dots) -%qq.nlsResiduals (x) -test.nlsResiduals (x) -\method{print}{nlsResiduals} (x, \dots) +\method{print}{nlsResiduals}(x, ...) } -%- maybe also 'usage' for other objects documented here. \arguments{ - \item{nls}{ an object of class 'nls' } - \item{x}{ an object of class 'nlsResiduals' } - \item{which}{ an integer: \cr - 0 = 4 graphs of residuals (types 1, 2, 4 and 6) \cr - 1 = non-transformed residuals against fitted values \cr - 2 = standardized residuals against fitted values \cr - 3 = sqrt of absolute value of standardized residuals against fitted values \cr - 4 = auto-correlation residuals (i+1th residual against ith residual) \cr - 5 = histogram of the residuals \cr - 6 = qq-plot of the residuals } - \item{...}{ further arguments passed to or from other methods } -} -\details{ +\item{nls}{an object of class 'nls'} -Several plots and tests are proposed to check the validity of the assumptions of the error model based on the analysis of residuals.\cr -The function \code{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.\cr -\code{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 \code{nlstools} is the one implemented in the package \code{tseries}. +\item{x}{an object of class 'nlsResiduals'} -} +\item{which}{an integer: \cr 0 = 4 graphs of residuals (types 1, 2, 4 and 6) +\cr 1 = non-transformed residuals against fitted values \cr 2 = standardized +residuals against fitted values \cr 3 = sqrt of absolute value of +standardized residuals against fitted values \cr 4 = auto-correlation +residuals (i+1th residual against ith residual) \cr 5 = histogram of the +residuals \cr 6 = qq-plot of the residuals} +\item{...}{further arguments passed to or from other methods} +} \value{ - \code{nlsResiduals} returns a list of five objects: - \item{ std95 }{ the Student value for alpha=0.05 (bilateral) and the degree of freedom of the model } - \item{ resi1 }{ a matrix with fitted values vs. non-transformed residuals } - \item{ resi2 }{ a matrix with fitted values vs. standardized residuals } - \item{ resi3 }{ a matrix with fitted values vs. sqrt(abs(standardized residuals)) } - \item{ resi4 }{ a matrix with ith residuals vs. i+1th residuals } +\code{nlsResiduals} returns a list of five objects: \item{ std95 }{ +the Student value for alpha=0.05 (bilateral) and the degree of freedom of +the model } \item{ resi1 }{ a matrix with fitted values vs. non-transformed +residuals } \item{ resi2 }{ a matrix with fitted values vs. standardized +residuals } \item{ resi3 }{ a matrix with fitted values vs. +sqrt(abs(standardized residuals)) } \item{ resi4 }{ a matrix with ith +residuals vs. i+1th residuals } } - -\references{ -Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK.\cr\cr -Siegel S and Castellan NJ (1988) Non parametric statistics for behavioral sciences. McGraw-Hill international, New York. +\description{ +Provides several plots and tests for the analysis of residuals } - -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +\details{ +Several plots and tests are proposed to check the validity of the +assumptions of the error model based on the analysis of residuals.\cr The +function \code{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.\cr \code{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 \code{nlstools} is the one implemented in the +package \code{tseries}. } - -%\note{ } - \examples{ + # Plots of residuals formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * (VO2rest + (VO2peak - VO2rest) * @@ -82,6 +73,16 @@ plot(O2K.res1, which = 6) # Tests test.nlsResiduals(O2K.res1) -} -\keyword{ nonlinear }% at least one, from doc/KEYWORDS +} +\references{ +Bates DM and Watts DG (1988) Nonlinear regression analysis and +its applications. Wiley, Chichester, UK.\cr\cr Siegel S and Castellan NJ +(1988) Non parametric statistics for behavioral sciences. McGraw-Hill +international, New York. +} +\author{ +Florent Baty \email{florent.baty@gmail.com}\cr Marie-Laure +Delignette-Muller \email{ml.delignette@vetagro-sup.fr} +} +\keyword{nonlinear} diff --git a/man/nlstools-defunct.Rd b/man/nlstools-defunct.Rd deleted file mode 100644 index 195a40f..0000000 --- a/man/nlstools-defunct.Rd +++ /dev/null @@ -1,82 +0,0 @@ -\name{nlstools-defunct} - -\alias{nlstools-defunct} -%\alias{geeraerd} -%\alias{geeraerd_without_Nres} -%\alias{geeraerd_without_Sl} -%\alias{mafart} -%\alias{albert} -%\alias{trilinear} -%\alias{bilinear_without_Nres} -%\alias{bilinear_without_Sl} -%\alias{baranyi} -%\alias{baranyi_without_Nmax} -%\alias{baranyi_without_lag} -%\alias{buchanan} -%\alias{buchanan_without_Nmax} -%\alias{buchanan_without_lag} -%\alias{gompertzm} -%\alias{jameson_buchanan} -%\alias{jameson_baranyi} -%\alias{jameson_without_lag} -%\alias{cpm_T} -%\alias{cpm_pH_4p} -%\alias{cpm_pH_3p} -%\alias{cpm_aw_3p} -%\alias{cpm_aw_2p} -%\alias{cpm_T_pH_aw} -%\alias{competition1} -%\alias{competition2} -%\alias{growthcurve1} -%\alias{growthcurve2} -%\alias{growthcurve3} -%\alias{growthcurve4} -%\alias{ross} -%\alias{survivalcurve1} -%\alias{survivalcurve2} -%\alias{survivalcurve3} - -\title{Defunct Functions in Package \pkg{nlstools}} - -\description{ - The models or data sets listed here are no longer part of package \pkg{nlstools}. In order to access these models and data set in the future, please load the additional package \pkg{nlsMicrobio}. -} - -\details{ - -Defunct functions are:\cr -\code{geeraerd}\cr -\code{geeraerd_without_Nres}\cr -\code{geeraerd_without_Sl}\cr -\code{mafart}\cr -\code{albert}\cr -\code{trilinear}\cr -\code{bilinear_without_Nres}\cr -\code{bilinear_without_Sl}\cr -\code{baranyi}\cr -\code{baranyi_without_Nmax}\cr -\code{baranyi_without_lag}\cr -\code{buchanan}\cr -\code{buchanan_without_Nmax}\cr -\code{buchanan_without_lag}\cr -\code{gompertzm}\cr -\code{jameson_buchanan}\cr -\code{jameson_baranyi}\cr -\code{jameson_without_lag}\cr -\code{cpm_T}\cr -\code{cpm_pH_4p}\cr -\code{cpm_pH_3p}\cr -\code{cpm_aw_3p}\cr -\code{cpm_aw_2p}\cr -\code{cpm_T_pH_aw}\cr -\code{competition1}\cr -\code{competition2}\cr -\code{growthcurve1}\cr -\code{growthcurve2}\cr -\code{growthcurve3}\cr -\code{growthcurve4}\cr -\code{ross}\cr -\code{survivalcurve1}\cr -\code{survivalcurve2}\cr -\code{survivalcurve3}\cr -} \ No newline at end of file diff --git a/man/nlstools-deprecated.Rd b/man/nlstools-deprecated.Rd new file mode 100644 index 0000000..4647f75 --- /dev/null +++ b/man/nlstools-deprecated.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlstools-defunct.R +\name{nlstools-deprecated} +\alias{nlstools-deprecated} +\title{Defunct Functions in Package \pkg{nlstools}} +\description{ +The models or data sets listed here are no longer part of package +\pkg{nlstools}. In order to access these models and data set in the future, +please load the additional package \pkg{nlsMicrobio}. + + +Defunct functions are:\cr +\code{geeraerd}\cr +\code{geeraerd_without_Nres}\cr +\code{geeraerd_without_Sl}\cr +\code{mafart}\cr +\code{albert}\cr +\code{trilinear}\cr +\code{bilinear_without_Nres}\cr +\code{bilinear_without_Sl}\cr +\code{baranyi}\cr +\code{baranyi_without_Nmax}\cr +\code{baranyi_without_lag}\cr +\code{buchanan}\cr +\code{buchanan_without_Nmax}\cr +\code{buchanan_without_lag}\cr +\code{gompertzm}\cr +\code{jameson_buchanan}\cr +\code{jameson_baranyi}\cr +\code{jameson_without_lag}\cr +\code{cpm_T}\cr +\code{cpm_pH_4p}\cr +\code{cpm_pH_3p}\cr +\code{cpm_aw_3p}\cr +\code{cpm_aw_2p}\cr +\code{cpm_T_pH_aw}\cr +\code{competition1}\cr +\code{competition2}\cr +\code{growthcurve1}\cr +\code{growthcurve2}\cr +\code{growthcurve3}\cr +\code{growthcurve4}\cr +\code{ross}\cr +\code{survivalcurve1}\cr +\code{survivalcurve2}\cr +\code{survivalcurve3}\cr +} +\keyword{internal} diff --git a/man/nlstools-package.Rd b/man/nlstools-package.Rd new file mode 100644 index 0000000..f936578 --- /dev/null +++ b/man/nlstools-package.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlstools-package.R +\docType{package} +\name{nlstools-package} +\alias{nlstools} +\alias{nlstools-package} +\title{nlstools: Tools for Nonlinear Regression Analysis} +\description{ +Several tools for assessing the quality of fit of a gaussian nonlinear model are provided. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/aursiber/nlstools} + \item Report bugs at \url{https://github.com/aursiber/nlstools/issues} +} + +} +\author{ +\strong{Maintainer}: Aurelie Siberchicot \email{aurelie.siberchicot@univ-lyon1.fr} + +Authors: +\itemize{ + \item Florent Baty \email{florent.baty@gmail.com} + \item Marie-Laure Delignette-Muller \email{marielaure.delignettemuller@vetagro-sup.fr} +} + +Other contributors: +\itemize{ + \item Sandrine Charles [contributor] + \item Jean-Pierre Flandrois [contributor] + \item Christian Ritz [contributor] +} + +} +\keyword{internal} diff --git a/man/nlstools.Rd b/man/nlstools.Rd deleted file mode 100644 index 42a861a..0000000 --- a/man/nlstools.Rd +++ /dev/null @@ -1,71 +0,0 @@ -\name{nlstools} -\alias{nlstools} -\alias{preview} -\alias{plotfit} -\alias{overview} -%- Also NEED an '\alias' for EACH other topic documented here. -\title{ Nonlinear least squares fit } - -\description{ -Tools to help the fit of nonlinear models with nls -} - -\usage{ -preview (formula, data, start, variable = 1) -plotfit (x, smooth = FALSE, variable = 1, xlab = NULL, ylab = NULL, - pch.obs = 1, pch.fit = "+", lty = 1, lwd = 1, col.obs = "black", - col.fit = "red", ...) -overview (x) -} -%- maybe also 'usage' for other objects documented here. -\arguments{ - \item{formula}{ formula of a non-linear model } - \item{data}{ a data frame with header matching the variables given in the formula } - \item{start}{ a list of parameter starting values which names match the parameters given in the formula } - \item{variable}{ index of the variable to be plotted against the predicted values; default is the first independent variable as it appears in the orginal dataset } - \item{x}{ an object of class 'nls' } - \item{smooth}{ a logical value, default is FALSE. If smooth is TRUE, a plot of observed values is plotted as a function of 1000 values continuously taken in the range interval [min(variable),max(variable)]. This option can only be used if the number of controlled variables is 1. } - \item{xlab}{ X-label } - \item{ylab}{ Y-label } - \item{pch.obs}{ type of point of the observed values } - \item{pch.fit}{ type of point of the fitted values (not applicable if smooth=TRUE)} - \item{lty}{ type of line of the smoothed fitted values (if smooth=TRUE) } - \item{lwd}{ thickness of line of the smoothed fitted values (if smooth=TRUE) } - \item{col.obs}{ color of the observed points } - \item{col.fit}{ color of the fitted values } - \item{...}{ further arguments passed to or from other methods } - -} -\details{ - The function \code{preview} helps defining the parameter starting values prior fitting the model. It provides a superimposed plot of observed (circles) and predicted (crosses) values of the dependent variable versus one of the independent variables with the model evaluated at the starting values of the parameters. The function \code{overview} returns the parameters estimates, their standard errors as well as their asymptotic confidence intervals and the correlation matrix (alternately, the function \code{confint} provides better confidence interval estimates whenever it converges). \code{plotfit} displays a superimposed plot of the dependent variable versus one the independent variables together with the fitted model. -} - -%\value{ } - -\seealso{ -\code{nls} in the \code{stats} library and \code{confint.nls} in the package \code{MASS} -} - -\references{ -Baty F, Ritz C, Charles S, Brutsche M, Flandrois J-P, Delignette-Muller M-L (2015). A Toolbox for Nonlinear Regression in R: The Package nlstools. \emph{Journal of Statistical Software}, \bold{66}(5), 1-21.\cr\cr -Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK. -} -\author{ -Florent Baty \email{florent.baty@gmail.com}\cr -Marie-Laure Delignette-Muller \email{ml.delignette@vetagro-sup.fr} -} - -%\note{ } - -\examples{ -formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * - (VO2rest + (VO2peak - VO2rest) * - (1 - exp(-(t - 5.883) / mu)))) -preview(formulaExp, O2K, list(VO2rest = 400, VO2peak = 1600, mu = 1)) -O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, - mu = 1), data = O2K) -overview(O2K.nls1) -plotfit(O2K.nls1, smooth = TRUE) -} - -\keyword{ nonlinear }% at least one, from doc/KEYWORDS diff --git a/man/preview.Rd b/man/preview.Rd new file mode 100644 index 0000000..0ba6842 --- /dev/null +++ b/man/preview.Rd @@ -0,0 +1,106 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nlstools.R +\name{preview} +\alias{preview} +\alias{plotfit} +\alias{overview} +\title{Nonlinear least squares fit} +\usage{ +preview(formula, data, start, variable = 1) + +plotfit( + x, + smooth = FALSE, + variable = 1, + xlab = NULL, + ylab = NULL, + pch.obs = 1, + pch.fit = "+", + lty = 1, + lwd = 1, + col.obs = "black", + col.fit = "red", + ... +) + +overview(x) +} +\arguments{ +\item{formula}{formula of a non-linear model} + +\item{data}{a data frame with header matching the variables given in the +formula} + +\item{start}{a list of parameter starting values which names match the +parameters given in the formula} + +\item{variable}{index of the variable to be plotted against the predicted +values; default is the first independent variable as it appears in the +orginal dataset} + +\item{x}{an object of class 'nls'} + +\item{smooth}{a logical value, default is FALSE. If smooth is TRUE, a plot +of observed values is plotted as a function of 1000 values continuously +taken in the range interval [min(variable),max(variable)]. This option can +only be used if the number of controlled variables is 1.} + +\item{xlab}{X-label} + +\item{ylab}{Y-label} + +\item{pch.obs}{type of point of the observed values} + +\item{pch.fit}{type of point of the fitted values (not applicable if +smooth=TRUE)} + +\item{lty}{type of line of the smoothed fitted values (if smooth=TRUE)} + +\item{lwd}{thickness of line of the smoothed fitted values (if smooth=TRUE)} + +\item{col.obs}{color of the observed points} + +\item{col.fit}{color of the fitted values} + +\item{...}{further arguments passed to or from other methods} +} +\description{ +Tools to help the fit of nonlinear models with nls +} +\details{ +The function \code{preview} helps defining the parameter starting values +prior fitting the model. It provides a superimposed plot of observed +(circles) and predicted (crosses) values of the dependent variable versus +one of the independent variables with the model evaluated at the starting +values of the parameters. The function \code{overview} returns the +parameters estimates, their standard errors as well as their asymptotic +confidence intervals and the correlation matrix (alternately, the function +\code{confint} provides better confidence interval estimates whenever it +converges). \code{plotfit} displays a superimposed plot of the dependent +variable versus one the independent variables together with the fitted +model. +} +\examples{ + +formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * + (VO2rest + (VO2peak - VO2rest) * + (1 - exp(-(t - 5.883) / mu)))) +preview(formulaExp, O2K, list(VO2rest = 400, VO2peak = 1600, mu = 1)) +O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, + mu = 1), data = O2K) +overview(O2K.nls1) +plotfit(O2K.nls1, smooth = TRUE) + +} +\references{ +Baty F, Ritz C, Charles S, Brutsche M, Flandrois J-P, +Delignette-Muller M-L (2015). A Toolbox for Nonlinear Regression in R: The +Package nlstools. \emph{Journal of Statistical Software}, \bold{66}(5), +1-21.\cr\cr Bates DM and Watts DG (1988) Nonlinear regression analysis and +its applications. Wiley, Chichester, UK. +} +\seealso{ +\code{nls} in the \code{stats} library and \code{confint.nls} in +the package \code{MASS} +} +\keyword{nonlinear} diff --git a/man/vmkm.Rd b/man/vmkm.Rd new file mode 100644 index 0000000..039922e --- /dev/null +++ b/man/vmkm.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{vmkm} +\alias{vmkm} +\alias{vmkmki} +\alias{michaelisdata} +\title{Michaelis Menten data sets} +\format{ +\code{vmkm} is a data frame with 2 columns (S: concentration of +substrat, v: reaction rate)\cr +\code{vmkmki} is a data frame with 3 columns +(S: concentration of substrat, I: concentration of inhibitor, v: reaction +rate) +} +\source{ +These datasets were provided by the French research unit INRA +UMR1233. +} +\usage{ +vmkm +} +\description{ +Michaelis Menten data sets +} +\examples{ + +data(vmkm) +data(vmkmki) +plot(vmkm) +plot(vmkmki) + +} +\keyword{datasets} diff --git a/nlstools.Rproj b/nlstools.Rproj new file mode 100644 index 0000000..6d314d7 --- /dev/null +++ b/nlstools.Rproj @@ -0,0 +1,20 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source + From 60d5570bb977491c49fdf3026edd50b5e615a394 Mon Sep 17 00:00:00 2001 From: statnmap Date: Wed, 17 Mar 2021 11:30:32 +0100 Subject: [PATCH 2/2] Add pkgdown website with GA --- .github/workflows/pkgdown.yaml | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/pkgdown.yaml diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..1abece4 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,48 @@ +on: + push: + branches: + - main + - master + +name: pkgdown + +jobs: + pkgdown: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown", type = "binary") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Deploy package + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'