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
 Origin Forum
 reversed regression (ch^2)

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
OndrejM Posted - 08/30/2007 : 01:52:45 AM
Hi guys,

Can someone help me how to do “reversed regression” let me explain,… I have experimental data (x, y) (worksheet1) and I have model data (x, y) (worksheet2) the data in worksheet2 represents the model (of fit but not produced by Origin) to the experimental data in worksheet1,… they both are shown in one graph,… what I need to do is find ch^2 between data in worksheet1 and data in worksheet2 (i.e. some number which can describe the goodness of the fit),…. Any ideas?

Cheers
Ondrej
10   L A T E S T    R E P L I E S    (Newest First)
larry_lan Posted - 08/31/2007 : 04:31:41 AM
Hi Ondrej:

The script supposed there are two columns, XY in data1 and data2 respectivily. And the yDataset(interpolatedXValue) function interpolates or extrapolates on a specified X dataset to find the corresponding interpolated or extrapolated value in a Y dataset. So if you run the script directly, it will create interpolated Y value on Data1_Stress. However, your actually X value is Data1_Lat.Str.Exp. So maybe you can modify this line:

wcol(icol)=Data2_B(col(2));

to make sure interpolate on X values.

More information about the yDataset(interpolatedXValue) function, please refer to Accessing Interpolated or Extrapolated Points of Origin Programming Help.

Thanks
Larry
OriginLab Technical Services
Mike Buess Posted - 08/31/2007 : 04:21:17 AM
The Stress column in Data1 is unsorted which will affect the results of a linear interpolation. However, the main problem is that half of the Stress values in Data2 lie between the same two data points of Data1 and the rest are completely outside of the range of Data1. Since there is very little overlap between the two Stress columns I'm not surprised that a linear interpolation fails.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 08/31/2007 04:22:04 AM
OndrejM Posted - 08/31/2007 : 02:54:44 AM



Thanks Larry,

You are right it works but that interpolation doesn’t look correct,… have a look at this figure (column A in Data1 is interpolated column Lat.Str.Mod(X,Data2) at the Stress(Y,Data1),… I also put that interpolated values to the graphs,… so you can see that it works but not properly,…

Thank you
Ondrej
larry_lan Posted - 08/31/2007 : 01:54:29 AM
Hi Ondrej:

Maybe you can check to make sure all the worksheet names are correct? In your attached jpg, a worksheet looks like data7 but not data2? Or you can use some simple column name like A, B..., and put the string like Lat.Str.Mod to column label. I tried the script again and it works.

Thanks
Larry
OriginLab Technical Services
OndrejM Posted - 08/31/2007 : 01:08:32 AM
Hi Larry,

That’s actually very good idea to write the result on the graph,… but it still doesn't calculate that chi^2,… maybe because I’m trying to interpolated Data2 at Y values of Data1,… really not sure what is wrong,… probably some stupid mistake,…

Anyway that’s a lot for help
Ondrej
larry_lan Posted - 08/30/2007 : 10:14:08 PM
Actuially, if you run the script on Script Window, you can see the result. If you want to make a button and paste result on the graph, modify the script like:

%P = %H;
win -a Data1; // restore Data1
wks.addcol(); // add column at end
icol=wks.ncols; // column number
wcol(icol)=Data2_B(col(1)); // interpolate fit at X values of Data1
wcol(icol) -= col(2);
wcol(icol) ^= 2;
sum(wcol(icol));
del wcol(icol); // delete last column
chi2 = sum.total;
win -a %P;
label -p 35 5 -s "The Chi^2 is $(chi2)";

Thanks

Larry
OriginLab Technical Services

Edited by - larry_lan on 08/30/2007 10:15:43 PM
OndrejM Posted - 08/30/2007 : 7:23:13 PM


Hello Mike,

I do something wrong because it doesn’t work,… I’ve tried to simplify my worksheets but still doesn’t work,..

Now I have two worksheets 1. Data1 (Experimental data): 13 rows, 3 columns [Stress(Y), Lat.str.Exp(X), Lat.str.Exp.Err(XErr)]
2. Data2 (Modelled data): 100rows, 2 columns [Stress(Y), Lat.str.Mod(X)]

see attached picture,...

not sure what is wrong,...
anyway thank you very much for helping
Ondrej
Mike Buess Posted - 08/30/2007 : 04:41:14 AM
You can interpolate the data in Data2 at the X values of Data1...

win -a Data1; // restore Data1
wks.addcol(); // add column at end
icol=wks.ncols; // column number
wcol(icol)=Data2_B(col(1)); // interpolate fit at X values of Data1
wcol(icol) -= col(2);
wcol(icol) ^= 2;
sum(wcol(icol));
del wcol(icol); // delete last column
chi2 = sum.total;
chi2=;


Mike Buess
Origin WebRing Member
OndrejM Posted - 08/30/2007 : 03:30:15 AM
Hi Mike,

thank you very much for the idea. but there is that problem that number of points is not same in worksheets,…

can I do this “chi^2 calculation” somehow it two steps

1.make “somehow” same number of points
2.do what you recommended

… ???

if you have any idea please let me know. Thanks ones again.

Ondrej
Mike Buess Posted - 08/30/2007 : 02:37:38 AM
Hi Ondrej,

If the number of points and their X values are the same you can use this...

tmp = Data1_B; // copy data to temporary dataset
tmp -= Data2_B; // subtract fit data
tmp ^= 2;
sum(tmp);
del tmp; // delete temporary dataset
chi2 = sum.total;
chi2=;

Origin reports the "reduced chi^2" which is chi2/dof, where dof (degrees of freedom) is the number of data points minus the number of fitting parameters.

Mike Buess
Origin WebRing Member

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