Giter VIP home page Giter VIP logo

nls2's People

Contributors

ggrothendieck avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

vs-genn

nls2's Issues

subset

Double check whether subset= works.

confint

confint does not work on the objects produced by nls2. This example is adapted from an example in nlmrt package.


    library(nlmrt)

    # setup and run nlfb example
    shobbs.res  <-  function(x) 100.0*x[1]/(1+x[2]*10.*exp(-0.1*x[3]*seq(12))) - y
    y  <-  c(5.308, 7.24, 9.638, 12.866, 17.069, 23.192, 31.443, 
              38.558, 50.156, 62.948, 75.995, 91.972)
    st  <-  c(b1=1, b2=1, b3=1)
    ans1n <- nlfb(st, shobbs.res)

    # get nls object
    ans <- nls2(y ~ shobbs.res(c(b1, b2, b3)) + y, start = coef(ans1n), alg = "brute")

    # this fails with error
    confint(ans)

Fix iterations output when using nls2 with "brute-force" to evaluate at a single point

When nls2 is used with alg="brute-force" and a start argument which is a data frame having one row (or list) it evaluates the formula once but erroneously returns k for the iteration count where k is the number of parameters. For example, below it reports 2 iterations but this should be 1.

> nls2(y ~ a * x + b * x^2, start = list(a = 0, b = 0), alg = "brute-force")
Nonlinear regression model
  model: y ~ a * x + b * x^2
   data: NULL
a b 
0 0 
 residual sum-of-squares: 8.243

Number of iterations to convergence: 2 
Achieved convergence tolerance: NA

One parameter

Fails with one parameter:

if (exists("out")) rm(out)
out <- nls2(demand ~ Time ^ b, BOD, start = data.frame(b = c(-10, 10)), algorithm = "plinear-brute")
out
## Error: object 'out' not found

data argument not quoted if algorithm not specified

If algorithm= not specified then the data= argument is not quoted so that its structure is shown in the output rather than its name.

> nls2(demand ~ a + b * Time, BOD, start = c(a = 1, b = 1))
Nonlinear regression model
  model: demand ~ a + b * Time
   data: structure(list(Time = c(1, 2, 3, 4, 5, 7), demand = c(8.3, 10.3, 19, 16, 15.6, 19.8)), class = "data.frame", row.names = c(NA, -6L), reference = "A1.4, p. 270")
    a     b 
8.521 1.721 
 residual sum-of-squares: 38.07

Number of iterations to convergence: 1 
Achieved convergence tolerance: 3.967e-09

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.