forum.alglib.net
http://forum.alglib.net/

Linear regression
http://forum.alglib.net/viewtopic.php?f=2&t=461
Page 1 of 1

Author:  patex1987 [ Wed Oct 26, 2011 10:22 am ]
Post subject:  Linear regression

I cant find a way how to calculate the linear regression.
The problem is with lrbuild function. Can me someone explain how to interpret the data into double[,] xy . What is Nvar and NPoints.
For example i have these points :
x : 1 , 2 , 3 ,4 , 5
y : 2 , 4, 6 , 8 , 10
How to put them in to the array xy???

I tried "double[,] x = new double[,]{ {1,2},{2,4},{3,6},{4,5},{5,10}};"
but then i get some weird array. Please someone help with this. I am very confused about this

Author:  Sergey.Bochkanov [ Wed Oct 26, 2011 10:38 am ]
Post subject:  Re: Linear regression

In your case NVars=1 and NPoints=5. And your xy array is correct.

ALGLIB Reference Manual has section for linreg subpackage - http://www.alglib.net/translator/man/ma ... nit_linreg It describes several functions which work with linear model structure, one of them is lrprocess() - you should create structure with lrbuild() and use lprocess() to calculate linear model estimate.

Author:  patex1987 [ Wed Oct 26, 2011 10:53 am ]
Post subject:  Re: Linear regression

One more thing. Iwant to get the coeffitients a,b from the equation y = ax+b .
Which function should i use, beacuse i found another one lsfitlinear?

Author:  Sergey.Bochkanov [ Wed Oct 26, 2011 12:44 pm ]
Post subject:  Re: Linear regression

For historical reasons ALGLIB has two similar sets of functions for linear modelling. You can use linreg functions, and get your coefficients with lrunpack().

Author:  joamaca [ Fri Dec 09, 2011 4:58 pm ]
Post subject:  Re: Linear regression

Using lrbuild, is there any way to force that the coefficients not take any value?
For example, only inside a range, -20<A<20

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/