jorischau / gslnls Goto Github PK
View Code? Open in Web Editor NEW{gslnls}: GSL multi-start nonlinear least-squares fitting in R
Home Page: https://CRAN.R-project.org/package=gslnls
{gslnls}: GSL multi-start nonlinear least-squares fitting in R
Home Page: https://CRAN.R-project.org/package=gslnls
Hi,
There are a few generic functions that depend on extracting the formula call from the model. Even though gslnls
inherits from nls
, model$call$formula
is missing & instead it is present in model$call$fn
.
For example, the predictNLS
function from the package propagate
for prediction using second-order Taylor expansion and Monte Carlo simulation instead of the delta method (first-order Taylor expansion) gives an error as it is not able to find model$call$formula
.
Can model$call$fn
be changed to model$call$formula
?
library(propagate)
library(minpack.lm)
library(gslnls)
data(Puromycin, package = "datasets")
Puromycin2 <- Puromycin[Puromycin$state == "treated", ][, 1:2]
# nls
Puro.nls <- nls(rate ~ Vm * conc/(K + conc), data = Puromycin2,
start = c(Vm = 200, K = 0.05))
pred_nls <- predictNLS(Puro.nls, interval = "prediction",
newdata = data.frame(conc = Puromycin$conc),
alpha = 0.05, nsim = 10000)
# minpack.lm
Puro.nlsLM <- nlsLM(rate ~ Vm * conc/(K + conc), data = Puromycin2,
start = c(Vm = 200, K = 0.05))
pred_nlsLM <- predictNLS(Puro.nlsLM, interval = "prediction",
newdata = data.frame(conc = Puromycin$conc),
alpha = 0.05, nsim = 10000)
# gslnls
Puro.gslnls <- gsl_nls(rate ~ Vm * conc/(K + conc), data = Puromycin2,
start = c(Vm = 200, K = 0.05))
pred_gslnls <- predictNLS(Puro.gslnls, interval = "prediction",
newdata = data.frame(conc = Puromycin$conc),
alpha = 0.05, nsim = 10000)
#> Error in as.list(eval(model$call$formula))[[3]]: subscript out of bounds
Puro.nls$call$formula
#> rate ~ Vm * conc/(K + conc)
Puro.nlsLM$call$formula
#> rate ~ Vm * conc/(K + conc)
Puro.gslnls$call$formula
#> NULL
Puro.gslnls$call$fn
#> rate ~ Vm * conc/(K + conc)
Example:
n <- 50
xy <- data.frame(
x = (1:n) / n,
y = 2.5 * exp(-1.5 * (1:n) / n) + 1 + rnorm(n, sd = 0.1)
)
fit <- gsl_nls(y ~ A * exp(-lam * x), data = xy, start = c(A = 1, lam = 1))
confint(fit)
#> 2.5 % 97.5 %
#> 1 3.2817373 3.4308953
#> 2 0.7681381 0.8634295
Using method = "profile"
, row names are returned as expected:
confint(fit, method = "profile")
#> Waiting for profiling to be done...
#> 2.5% 97.5%
#> A 3.3208899 3.4727355
#> lam 0.8169809 0.9146047
I suggest adding the topics nonlinear-least-squares
, levenberg-marquardt
, r-package
, gsl
, gsl-library
in the About section
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.