The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Returning all parameters from linear fitting

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
greadey Posted - 03/01/2005 : 08:16:38 AM
Greetings all,

I've been looking at performing a linear regression using code and have found the easiest implementation is by using the fitpoly_range approach.

While I am able to retrieve the fitted parameteres (gradient and intercept) I need to access the correlation coefficient, the errors in the estimation of the fit would also be beneficial.

Are these numbers available to Origin C?

Thanks all,

greadey
2   L A T E S T    R E P L I E S    (Newest First)
greadey Posted - 03/02/2005 : 03:37:43 AM
Thanks Easwar,

You pointed me in the right direction. I tried to usethe Labtalk LR object but couldn't get it to work, now I'll have a go with this.

greadey
easwar Posted - 03/01/2005 : 2:58:38 PM
Hi greadey,

Those functions (fitpoly, fitpoly_range etc) were written just to get quick estimates on polynomial coefficients - they are used in initialization code for nonlinear fitting mainly.

You would be better off using the LabTalk stat object directly from your Origin C code (these functions in fact use the stat object anyway).

Sample code pasted below:

Easwar
OriginLab

void test()
{
// fit to x,y data in cols 1, 2 of active wks
Worksheet wks = Project.ActiveLayer();
Curve crv( wks, 0, 1);
if( !crv ) return;

// Point to LabTalk stat object
using stat = LabTalk.Stat;
// Reset object
stat.reset();
// Set data name
stat.Data$ = crv.GetName();
// Set chi-sq scaling to 1 - need to do this if no error bars associated with data
// If error bars, then set to 0
stat.ChiSqrErr = 1;
// Set order - poly of order 3 for example
stat.pr.order = 3;
// Perform the operation
stat.pr();
// Print results
printf("Coeff[0], Err[0] = %f, %f\n", stat.pr.a, stat.pr.ase);
for(int ii=1; ii < 4; ii++)
printf("Coeff[%d], Err[%d] = %f, %f\n", ii, ii, stat.pr.b$(ii), stat.pr.bse$(ii));
printf("R-Sqr = %f\n", stat.adrsq);
// See the documentation on Stat object under LabTalk language reference file for more info
}



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000