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
 LabTalk Forum
 linear regression on dataset with missing values

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
G.Bartsch Posted - 09/01/2006 : 09:51:40 AM
is there a method to perform a linear fit on datasets containing "-" besides deleting "-"?
thanks!
9   L A T E S T    R E P L I E S    (Newest First)
G.Bartsch Posted - 09/05/2006 : 09:07:36 AM
yes! thats very useful! thank you very much again.
Mike Buess Posted - 09/05/2006 : 08:05:46 AM
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
G.Bartsch Posted - 09/05/2006 : 07:18:37 AM
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?
G.Bartsch Posted - 09/02/2006 : 03:55:25 AM
yes, i think this will be very useful. ill try that next week.
Mike Buess Posted - 09/01/2006 : 1:16:26 PM
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
G.Bartsch Posted - 09/01/2006 : 12:37:24 PM
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
Mike Buess Posted - 09/01/2006 : 11:22:42 AM
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
G.Bartsch Posted - 09/01/2006 : 10:51:10 AM
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.
Mike Buess Posted - 09/01/2006 : 10:06:10 AM
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

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