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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 linear regression on dataset with missing values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

G.Bartsch

Germany
Posts

Posted - 09/01/2006 :  09:51:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
is there a method to perform a linear fit on datasets containing "-" besides deleting "-"?
thanks!

Mike Buess

USA
3037 Posts

Posted - 09/01/2006 :  10:06:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Missing values are ignored and therefore will present no problem for a linear fit. What sort of problem do you see?

Mike Buess
Origin WebRing Member
Go to Top of Page

G.Bartsch

Germany
Posts

Posted - 09/01/2006 :  10:51:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
one example:
i fill data1's columns (a,b) both with (1,2,3,4). then i clear manually 1 and 2 in the y column. i recieve data1_a=(1,2,3,4), data1_b=(-,-,3,4) subsequent i type in script window
lr data1_b;
lr.a=;
lr.b=;

and recieve
LR.A=--
LR.B=0

i use originpro 7.0
@V=7.0383

if anything not clear i can mail you a scrennshot.

thank you.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/01/2006 :  11:22:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I can reproduce that with lr. (I thought you were using the linear fit commands on the menus.) It appears that lr requires that at least half the values are not missing. (The criteria for failure are actually more complicated but include more missing than non-missing values.) In other words, for data1_a={1,2,3,4,5} and data1_b={--,--,3,4,5} it returns the correct slope and intercept...

lr data1_b;
lr.a=;
LR.A=0
lr.b=;
LR.B=1

If fewer than half of your data points have missing values you can ignore those points. If your data contain many missing values you can delete them all with the following script...

sort -w %H %H_B; // sort active wks ascending in col(B) (missing values go to the end)
sum(%H_B); // sum.n is the # of (non-missing) values
set %H -er sum.n; // truncate wks to sum.n
sort -w %H %H_A; // restore order by sorting wks ascending in col(A)

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/01/2006 12:11:34 PM
Go to Top of Page

G.Bartsch

Germany
Posts

Posted - 09/01/2006 :  12:37:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
it would be difficult in my case to delete "-" because i dont have only one y value column and i would like to avert making another temporary worksheet for the linear fits.
but you say the menu commands ignore "-". if they do even in the case of too much "-" in the dataset, is there a way to call the menu commands by labtalk?
thank you for your fast and precise answers
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/01/2006 :  1:16:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The Analysis > Fit Linear command for graphs runs the FitLinear section of LR.ogs and uses the stat.lr() method for linear regression. The menu command is not available for worksheets but the scripts can be run on a worksheet by selecting a Y oolumn and entering run.section(LR,FitLinear) in the script window. Alternatively, you can refer to the stat object in the programming guide and write your own scripts.

The Advanced Fitting tool on the Analysis menu uses the nlsf object and has a Linear fitting function which also works with missing values. The MultiFit addon uses nlsf to fit multiple datasets and might be able to fit all Y columns in your worksheet and combine the results (A and B) in a single worksheet. (You need to apply the SR4 patch in order to use Multifit.)

I hope that's useful.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/01/2006 1:37:53 PM
Go to Top of Page

G.Bartsch

Germany
Posts

Posted - 09/02/2006 :  03:55:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
yes, i think this will be very useful. ill try that next week.
Go to Top of Page

G.Bartsch

Germany
Posts

Posted - 09/05/2006 :  07:18:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
the stat.lr object seems to suit very well. it has no problems with the missing values and doesnt need the data to be plotted. unfortunately i dont find a way to set the fitting range like it is possible with lr command. i mean lr dataset -b begin -e end. do you know a solution?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/05/2006 :  08:05:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This will work...

%A=stat.data$;
set %A -b begin;
set %A -e end;
stat.lr();

...Note that set dataset -b/-e hides the data at the beginning or end of the column. Use this to restore those values...

set %A -b 1;
set %A -e wks.maxrows;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/05/2006 08:13:15 AM
Go to Top of Page

G.Bartsch

Germany
Posts

Posted - 09/05/2006 :  09:07:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
yes! thats very useful! thank you very much again.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000