# [R] hi

Cox Lwaka clwaka at yahoo.com
Fri Nov 14 10:19:49 CET 2014

```Thanks,Following your explanation i have through bi conductor but still unable to figure out how to group. for the data, my data takes values 0,1,2  hence simulating from a multinomial distribution such as (rmultinom(10, size = 3, prob = c(0.1,0.2,0.8))) gives 10 variables from three individuals assume this variables are ordered.I am to develop an r algorithm that will develop groups as follows;
i) Calculate the correlation between successive variables and correlation matrix for all the variables
ii) if r(i) is the maximum correlation coefficient in the successive variable correlation then my first group has variables [x(i-k ), ...x(i),... x(i+k )]. this gives me group one of size 2k+1. note that variables are picked on that line and order is maintained.iii) the max r is removed from the list of successive correlation between variables, but we don't recalculate the correlation since this will destroy the array.
iv)check for remaining correlation btn successive variables relative to the bigger correlation matrix and select  other groups. these groups don't need to be of same size and they must not overlap.
e.g,if for instance  x1, x2,......x10   are my 10 variables. i calculate correlation btn successive variable. Say the max correlation is  Cor(x4,x5) i take group one to have values (x2,x3,x4,x5),   my data remains,   x1,-,-,-,-,x6,x7,x8,x9,x10. Clearly x1 will form a group and the algorithm has to check for other groups form x6,x7,x8,x9,x10 based on max r and also the correlation matrix.

Note that i have large number of variables. i don't need the groups to overlap
i will have divided in to disjoint groups but maintaining the order.
kindly assist me see how i can get this done, thanks

On Thursday, November 13, 2014 1:50 PM, Cox Lwaka <clwaka at yahoo.com> wrote:

I have a bit of trouble here to program in r. I am anew user but i really enjoy working with it.I have a large number of variables in a matrix that are arranged sequentially on a line (chromosome). This order has to be maintained whatsoever. I am to develop an r algorithm that will develop groups as follows;i) Calculate the correlation between successive variables and correlation matrix for all the variables
ii) if r(i) is the maximum correlation coefficient in the successive variable correlation then my first group has variables [x(i-k ), ...x(i),... x(i+k )]. this gives me group one of size 2k+1. note that variables are picked on that line and order is maintained.iii) we check for remaining correlation btn successive variables relative to the bigger correlation matrix and select  other groups. these groups don't need to be of same size and they must not overlap.i will have divided in to disjoint groups but maintaining the order.kindly assist me see how i can get this done, thanks

[[alternative HTML version deleted]]

```