# forum.alglib.net

ALGLIB forum
 It is currently Wed May 29, 2024 2:51 am

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Linear regressionPosted: Wed Oct 26, 2011 10:22 am

Joined: Wed Oct 26, 2011 10:14 am
Posts: 2
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}};"

Top

 Post subject: Re: Linear regressionPosted: Wed Oct 26, 2011 10:38 am

Joined: Fri May 07, 2010 7:06 am
Posts: 916
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.

Top

 Post subject: Re: Linear regressionPosted: Wed Oct 26, 2011 10:53 am

Joined: Wed Oct 26, 2011 10:14 am
Posts: 2
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?

Top

 Post subject: Re: Linear regressionPosted: Wed Oct 26, 2011 12:44 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 916
For historical reasons ALGLIB has two similar sets of functions for linear modelling. You can use linreg functions, and get your coefficients with lrunpack().

Top

 Post subject: Re: Linear regressionPosted: Fri Dec 09, 2011 4:58 pm

Joined: Thu Sep 02, 2010 12:27 pm
Posts: 3
Using lrbuild, is there any way to force that the coefficients not take any value?
For example, only inside a range, -20<A<20

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: