

Hi,
 
after all, brute force seems  the way to go.
 
I will use a simplified example to illustrate what I want (dump of dat4 is
below):
suppose dat4:
ID  rrt Mnd Result
 1 0.45   0    0.1
 1 0.48   0    0.3
 1 1.24   0    0.5
 2 0.45   3    0.2
 2 0.48   3    0.6
 2 1.22   3    0.4
 
I want to generate all possible combinations of Mnd 0 with Mnd 3 to
calculate the sum of the squared differences divided by the number of rrt's
eg:
Mnd 0 rrt 0.45 gives result 0.1 where Mnd 3 rrt 0.45 gives 0.2 
At the same time rrt 0.48 at Mnd 0 gives 0.3 where rrt 0.48 at Mnd 3 gives
0.6
The same for rrt 1.24 at Mnd 0: 0.5 ....
This gives (0.1-0.2) ^2 + (0.3-0.6)^2  + ....  
 
The permutations should follow this rules:
- rrt's can never differ more than 10%
- rrt's can never switch (eg if rrt 0.45 at 0 Mnd is coupled to 0.48 mnd at
3 Mnd, then 0.48 at 0Mnd can not be coupled to 0.45 at 3 Mnd)
- rrt's can be coupled to NA values and shouldn't be coupled necessarily.  
 
 
I already played with combn, and expand.grid, but couldn't figure out how to
generate the combinations...
 
The  goal is to minimize the resulting value, but be aware of the fact that
the problem above is simplified, and thus isn't limited to only 2 Mnd
values, but maybe 5 - 10.
 
Thanks
 
Bart
 
 
dat4 <-
structure(list(ID = c(1L, 1L, 1L, 2L, 2L, 2L), rrt = c(0.45, 
0.48, 1.24, 0.45, 0.48, 1.22), Mnd = c(0L, 0L, 0L, 3L, 3L, 3L
), Result = c(0.1, 0.3, 0.5, 0.2, 0.6, 0.4)), .Names = c("ID", 
"rrt", "Mnd", "Result"), row.names = c(NA, 6L), class = "data.frame")
 
 
 
 		 	   		  
	[[alternative HTML version deleted]]

