ggrothendieck / nls2 Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/nls2
Automatically exported from code.google.com/p/nls2
Vector parameters only work with this workaround:
Check if documentation points out that a string can be provided as the formula.
Double check whether subset= works.
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)
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
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
If formula
argument is omitted then nls2
should return the starting values.
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
Add vignette.
Add algorithm = "lhs"
and algorithm = "plinear-lhs"
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.