

   BOD {nls}                                    R Documentation

   BBiioocchheemmiiccaall OOxxyyggeenn DDeemmaanndd

   DDeessccrriippttiioonn::

        The `BOD' data frame has 6 rows and 2 columns giving
        the biochemical oxygen demand versus time in an evalua-
        tion of water quality.

   AArrgguummeennttss::

       Time: A numeric vector giving the time of the measure-
             ment (days).

     demand: A numeric vector giving the biochemical oxygen
             demand (mg/l).

   FFoorrmmaatt::

        This data frame contains the following columns:

   SSoouurrccee::

        Bates and Watts (1998), Nonlinear Regression Analysis
        and Its Applications, Wiley, Appendix A1.4.  Originally
        from Marske (1967), M.Sc. Thesis, University of Wiscon-
        sin - Madison.

   EExxaammpplleess::

        library(nls)
        data(BOD)
        # simplest form of fitting a first-order model to these data
        fm1 <- nls(demand ~ A*(1-exp(-exp(lrc)*Time)), data = BOD,
           start = c(A = 20, lrc = log(.35)))
        coef(fm1)
        print(fm1)
        # using the plinear algorithm
        fm2 <- nls(demand ~ (1-exp(-exp(lrc)*Time)), data = BOD,
           start = c(lrc = log(.35)), algorithm = "plinear", trace = TRUE)
        # using a self-starting model
        fm3 <- nls(demand ~ SSasympOrig(Time, A, lrc), data = BOD)
        summary( fm3 )

