GithubHelp home page GithubHelp logo

nlreg.jl's Introduction

Nonlinear regression

Stable Dev Build Status Build Status Codecov

This package is an experiment in using the Zygote automatic differentiation package and the lowrankupdate! function in the LinearAlgebra package to solve the linear least squares problem for a Gauss-Newton update.

The data are represented as a Tables.RowTable, which is a vector of NamedTuples. The model parameters are also a NamedTuple. The model function is given as a function of two arguments - the parameters and a data row.

Example - a Michaelis-Menten fit

In the Michaelis-Menten model for enzyme kinetics,

v = Vm * c / (K + c)

the relationship between the velocity, v, of a reaction and the concentration, c, of the substrate depends on two parameters; Vm, the maximum velocity and K, the Michaelis parameter. The Vm parameter occurs linearly in this expression whereas K is a nonlinear parameter.

julia> using CSV, DataFrames, NLreg

julia> datadir = normpath(joinpath(dirname(pathof(NLreg)), "..", "data"));

julia> PurTrt = first(groupby(CSV.read(joinpath(datadir, "Puromycin.csv")), :state))
12×3 SubDataFrame
│ Row │ conc    │ rate    │ state   │
│     │ Float64 │ Float64 │ String  │
├─────┼─────────┼─────────┼─────────┤
│ 10.0276.0    │ treated │
│ 20.0247.0    │ treated │
│ 30.0697.0    │ treated │
90.56191.0   │ treated │
│ 100.56201.0   │ treated │
│ 111.1207.0   │ treated │
│ 121.1200.0   │ treated │

julia> pm1 = fit(NLregModel, PurTrt, :rate, (p,d) -> p.Vm * d.conc/(p.K + d.conc),
                  (Vm = 200., K = 0.05))
Nonlinear regression model fit by maximum likelihood

Data schema (response variable is rate)
Tables.Schema:
 :conc   Float64
 :rate   Float64
 :state  String
Number of observations:                  12

Parameter estimates
───────────────────────────────────────
      Estimate   Std.Error  t-statistic
───────────────────────────────────────
Vm  212.684     6.94715        30.6145
K     0.064121  0.00828092      7.74322
───────────────────────────────────────

Sum of squared residuals at convergence: 1195.4488145417758
Achieved convergence criterion:          8.798637504793927e-6

nlreg.jl's People

Contributors

ciaranomara avatar dmbates avatar johnmyleswhite avatar juliatagbot avatar

Watchers

 avatar

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.