forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:51 pm

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.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Linear regression
PostPosted: Wed Oct 26, 2011 10:22 am 
Offline

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}};"
but then i get some weird array. Please someone help with this. I am very confused about this


Top
 Profile  
 
 Post subject: Re: Linear regression
PostPosted: Wed Oct 26, 2011 10:38 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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
 Profile  
 
 Post subject: Re: Linear regression
PostPosted: Wed Oct 26, 2011 10:53 am 
Offline

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
 Profile  
 
 Post subject: Re: Linear regression
PostPosted: Wed Oct 26, 2011 12:44 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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
 Profile  
 
 Post subject: Re: Linear regression
PostPosted: Fri Dec 09, 2011 4:58 pm 
Offline

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group