comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » REGRESS Question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: regress question [message #64088 is a reply to message #31982] Thu, 27 November 2008 02:47 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Thu, 27 Nov 2008 01:23:06 -0800 (PST), russ <rlayberry@hotmail.com>
wrote:

> Hi
>
> I'm using multiple linear regression using the REGRESS function. This
> gives me
>
> y = c + a1x1 + a2 x2 ...+ anxn
>
> with the coefficents a1,a2 etc.
>
> What I want to do is the above but force the constant to be zero. ie
> find the coeffcients that give the best linear fit whilst the function
> goes through thr origin (which it should do for physical reasons).
>
> Any ideas?
>
> Thanks
>
> Russ


You can create the design-matrix yourself and then use some
factorization like LU, SVD, Cholesky, QR,... (is your linear system
over/under determined?) The example below uses SVD. First it solves a
system not going through the origin by REGRESS and then by SVD.
Finally SVD is used for a system that goes through the origin.


X1 = [1.0, 2.0, 4.0, 8.0, 16.0, 32.0]
X2 = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
X = transpose([[X1],[X2]])
Y = 3*X1 - 4*X2 + 5
Yorg = 3*X1 - 4*X2

; Regress
result1=regress(X,Y,const=const)
result1=[reform(result1),const]

; SVD (concat. X with 1's for the const)
SVDC, [X,replicate(1,1,n_elements(Y))], W, U, V
result2=reform(SVSOL(U, W, V, Y))

; SVD (origin)
SVDC, X, W, U, V
result3=reform(SVSOL(U, W, V, Yorg))

print,'Regress: ',result1
print,'SVD: ',result2
print,'SVD(origin): ',result3
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL Programming Techniques, 3rd edition
Next Topic: Reading fortran

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 11:32:48 PDT 2025

Total time taken to generate the page: 0.00901 seconds