Giter Club home page Giter Club logo

gslnls's People

Contributors

jorischau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gslnls's Issues

Unable to extact the formula from the model with the same method as in nls and minpack.lm::nlsLM

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)

Missing row names in `confint()`

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

Add topic tags

I suggest adding the topics nonlinear-least-squares, levenberg-marquardt, r-package, gsl, gsl-library in the About section

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.