项目作者: dmbates

项目描述 :
Nonlinear regression in Julia
高级语言: Julia
项目地址: git://github.com/dmbates/NLreg.jl.git
创建时间: 2013-09-12T17:47:04Z
项目社区:https://github.com/dmbates/NLreg.jl

开源协议:

下载


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,

  1. 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.

  1. julia> using CSV, DataFrames, NLreg
  2. julia> datadir = normpath(joinpath(dirname(pathof(NLreg)), "..", "data"));
  3. julia> PurTrt = first(groupby(CSV.read(joinpath(datadir, "Puromycin.csv")), :state))
  4. 12×3 SubDataFrame
  5. Row conc rate state
  6. Float64 Float64 String
  7. ├─────┼─────────┼─────────┼─────────┤
  8. 1 0.02 76.0 treated
  9. 2 0.02 47.0 treated
  10. 3 0.06 97.0 treated
  11. 9 0.56 191.0 treated
  12. 10 0.56 201.0 treated
  13. 11 1.1 207.0 treated
  14. 12 1.1 200.0 treated
  15. julia> pm1 = fit(NLregModel, PurTrt, :rate, (p,d) -> p.Vm * d.conc/(p.K + d.conc),
  16. (Vm = 200., K = 0.05))
  17. Nonlinear regression model fit by maximum likelihood
  18. Data schema (response variable is rate)
  19. Tables.Schema:
  20. :conc Float64
  21. :rate Float64
  22. :state String
  23. Number of observations: 12
  24. Parameter estimates
  25. ───────────────────────────────────────
  26. Estimate Std.Error t-statistic
  27. ───────────────────────────────────────
  28. Vm 212.684 6.94715 30.6145
  29. K 0.064121 0.00828092 7.74322
  30. ───────────────────────────────────────
  31. Sum of squared residuals at convergence: 1195.4488145417758
  32. Achieved convergence criterion: 8.798637504793927e-6