[R] Arrays of functions or results of functions.

Gary Mallard gary.mallard at nist.gov
Mon Mar 27 19:03:56 CEST 2006

The general problem I am trying to solve is to determine if a series of 
subsets of data can be described with a single regression slope.  This 
involves fitting the data to each subset, calculating a joint slope 
followed by F tests to show that the variances are equal the final slope is 
The data for is characterized by a parameter PC (for the 4 - in this case) 
sets and a dependent variable RI and an independent variable ROH.
The data are contained in a variable "joint".
The joint has been attached and has RI, ROH and PC for each element.
The following gives the initial results:

joint_reduced <- joint;
for(i in 1:4) {

Now the statistics from AllLine can be compared with each of the individual 

 From a lot of point of view it would be useful to have a parameter 
generated by
for (i in 1:4){ 	Xline[i]=lm(RI[PC==i]~ROH[PC==i])}
And now all of the work of comparison can be done with calls to Xline[i] 
rather than having to  work individually with Mline, Eline, etc.

This appears to be impossible.  The constructor for Xline[i] is not 
automatic (as it is for Mline, etc) noted above.  I cannot determine how to 
construct the Xline[i] object so that this kind of process can be 
generalized.  Is it possible?  Is there another way to set us such tests of 
multiple line linearity that is already in a package?

Comments or pointers would be appreciated.

More information about the R-help mailing list