Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Regression with custom interception #1080

Answered by diluculo
JP-Reis asked this question in Q&A
Discussion options

Hello community,

I have been trying to figure out how to obtain the regression equation for a linear regression model with a pre-defined intercept value with no success.

The customer want to replicate some of the Excel functionalities that they are used to use in Excel. Is this even possible in with this lib?

Thank you.

You must be logged in to vote

You can apply y - 3.0 to the FitThroughOrigin function to model the equation with an intercept of 3 on the y-axis.

Replies: 2 comments 4 replies

Comment options

I know that there is a built-in function to FitThroughOrigin, but what if I want to model the equation to intercept (a=xyz) on Y=3?

You must be logged in to vote
0 replies
Comment options

You can apply y - 3.0 to the FitThroughOrigin function to model the equation with an intercept of 3 on the y-axis.

You must be logged in to vote
4 replies
Comment options

Ok, so far that seems to do the trick!

Is there any similar function as FitThroughOrigin for exponential and polynomial models?

Comment options

var slope = FitThroughOrigin(x, y.Select(p => p - 3.0).ToArray())

Comment options

Please see mathnet-numerics/src/Numerics/Fit.cs.

For general models, nonlinear least square fitting (Levenberg-Marquardt) or other optimization methods can be used. Please see the test cases in mathnet-numerics/src/Numerics.Tests/OptimizationTests.

Comment options

I'll give it a look. Thank you.

Answer selected by JP-Reis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /