VOOZH about

URL: https://www.nuget.org/packages/HEAL.NonlinearRegression/

⇱ NuGet Gallery | HEAL.NonlinearRegression 0.1.0-rc.2




HEAL.NonlinearRegression 0.1.0-rc.2

This is a prerelease version of HEAL.NonlinearRegression.
dotnet add package HEAL.NonlinearRegression --version 0.1.0-rc.2
 
 
NuGet\Install-Package HEAL.NonlinearRegression -Version 0.1.0-rc.2
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HEAL.NonlinearRegression" Version="0.1.0-rc.2" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HEAL.NonlinearRegression" Version="0.1.0-rc.2" />
 
Directory.Packages.props
<PackageReference Include="HEAL.NonlinearRegression" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HEAL.NonlinearRegression --version 0.1.0-rc.2
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HEAL.NonlinearRegression, 0.1.0-rc.2"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HEAL.NonlinearRegression@0.1.0-rc.2
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HEAL.NonlinearRegression&version=0.1.0-rc.2&prerelease
 
Install as a Cake Addin
#tool nuget:?package=HEAL.NonlinearRegression&version=0.1.0-rc.2&prerelease
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

HEAL.NonlinearRegression

C# implementation of nonlinear least squares fitting including calculation of t-profiles and pairwise profile plots (see [1]). The t-profiles allow to calculate exact confidence intervals for nonlinear parameters and approximate pairwise confidence regions.

Implementation is based on:

[1] Douglas Bates and Donald Watts, Nonlinear Regression and Its Applications, John Wiley and Sons, 1988

👁 Unit tests

Building

git clone https://github.com/heal-research/HEAL.NonlinearRegression
cd HEAL.NonlinearRegression
dotnet build

Run the tests for fitting nonlinear models:

dotnet test --filter "FullyQualifiedName~Fit"
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
p_opt: 1.10421e+002 1.03488e+002
Successful: True, NumIters: 2, NumFuncEvals: 10, NumJacEvals: 0
SSR: 9.5471e+003 s: 3.0898e+001 AICc: 19.0 BIC: 17.5 MDL: 15.1
Para Estimate Std. error z Score Lower Upper Correlation matrix
 0 1.1042e+002 2.3371e+001 4.72e+000 5.8347e+001 1.6249e+002 1.00
 1 1.0349e+002 1.2024e+001 8.61e+000 7.6697e+001 1.3028e+002 -0.67 1.00

Optimized: ((110.42107672063618 * x0) + 103.48806186471386)


p_opt: 1.38378e+000 4.84833e-002 5.24299e-001 3.52511e-001 -6.84851e-002 -1.11809e+001
Successful: True, NumIters: 2, NumFuncEvals: 41, NumJacEvals: 0
Deviance: 7.8438e+002 Dispersion: 1.0000e+000 AICc: 808.7 BIC: 866.8 MDL: 456.0
Para Estimate Std. error z Score Lower Upper Correlation matrix
 0 1.3838e+000 1.7042e-001 8.12e+000 1.0493e+000 1.7182e+000 1.00
 1 4.8483e-002 7.5999e-003 6.38e+000 3.3569e-002 6.3398e-002 -0.04 1.00
 2 5.2430e-001 9.7525e-002 5.38e+000 3.3291e-001 7.1569e-001 -0.08 0.02 1.00
 3 3.5251e-001 8.0993e-002 4.35e+000 1.9357e-001 5.1145e-001 -0.16 -0.08 -0.55 1.00
 4 -6.8485e-002 2.4032e-001 -2.85e-001 -5.4009e-001 4.0312e-001 -0.04 0.00 0.02 -0.10 1.00
 5 -1.1181e+001 1.0533e+000 -1.06e+001 -1.3248e+001 -9.1140e+000 -0.60 -0.38 -0.11 0.12 -0.62 1.00

Optimized: Logistic(((((((1.3837834757792504 * BI_RADS) + (0.04848326870703262 * Age)) + (0.5242993934295344 * Shape)) + (0.35251072256817134 * Margin)) + (-0.06848513367625395 * Density)) + -11.180915607397576))


p_opt: 6.41213e-002 2.12684e+002
Successful: True, NumIters: 3, NumFuncEvals: 44, NumJacEvals: 0
SSR: 1.1954e+003 s: 1.0934e+001 AICc: 19.0 BIC: 17.5 MDL: 21.5
Para Estimate Std. error z Score Lower Upper Correlation matrix
 0 6.4121e-002 8.7112e-003 7.36e+000 4.4711e-002 8.3531e-002 1.00
 1 2.1268e+002 7.1607e+000 2.97e+001 1.9673e+002 2.2864e+002 0.78 1.00

Optimized: ((x0 / (0.06412128166090875 + x0)) * 212.68374312341493)

Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 274 ms - HEAL.NonlinearRegression.Console.Tests.dll (net6.0)

Run the tests for profile likelihood confidence intervals:

dotnet test --filter "(FullyQualifiedName~ProfilePuromycin|FullyQualifiedName~ProfileMammography)"
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

profile-based marginal confidence intervals (alpha=0.05)
p0 1.3838e+000 1.0586e+000 1.7270e+000
p1 4.8483e-002 3.3810e-002 6.3677e-002
p2 5.2430e-001 3.3325e-001 7.1665e-001
p3 3.5251e-001 1.9415e-001 5.1249e-001
p4 -6.8485e-002 -5.3640e-001 4.0944e-001
p5 -1.1181e+001 -1.3314e+001 -9.1744e+000


profile-based marginal confidence intervals (alpha=0.05)
p0 6.4121e-002 4.6920e-002 8.6157e-002
p1 2.1268e+002 1.9730e+002 2.2929e+002

Passed! - Failed: 0, Passed: 2, Skipped: 0, Total: 2, Duration: 5 s - HEAL.NonlinearRegression.Console.Tests.dll (net6.0)

Usage

To call the library you have to provide an expression for the model as well as a dataset to fit to.

var x = new double[,] { { 0.02 }, { 0.02 }, { 0.06 }, { 0.06 }, { 0.11 }, { 0.11 }, { 0.22 }, { 0.22 }, { 0.56 }, { 0.56 }, { 1.10 }, { 1.10 } };
var y = new double[] {76, 47, 97, 107, 123, 139, 159, 152, 191, 201, 207, 200 };

var nlr = new NonlinearRegression();
nlr.Fit("0.1 * x0 / (1.0f + 0.1 * x0)", new[] { "x0" }, LikelihoodEnum.Gaussian, x, y);
var prediction = nlr.PredictWithIntervals(x, IntervalEnum.LaplaceApproximation);
System.Console.WriteLine($"pred: {prediction[0, 0]}, low: {prediction[0, 2]}, high: {prediction[0, 3]}");

Dependencies

The implementation uses alglib (https://alglib.net) for linear algebra and nonlinear least squares fitting. Alglib is licensed under GPL2+ and includes code from other projects. Commercial licenses for alglib are available.

License

The code is licensed under the conditions of the GPL version 3.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 netstandard2.1 is compatible. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-rc.2 261 4/3/2023
0.1.0-rc.1 225 3/31/2023