create.CCM {CCM} | R Documentation |

## Creates a CCM correlation matrix

### Description

Creates a CCM correlation matrix that calculates correlations between test and training samples or between each test sample

### Usage

```
create.CCM(X.test, X.train = NULL, method = "pearson", use = "everything", verbose = 1)
```

### Arguments

`X.test` |
matrix of test samples with rows containing variables and columns containing observations |

`X.train` |
optional matrix of training samples with rows containing variables and columns containing observations |

`method` |
the type of correlation to use, either 'pearson' (the default) or 'spearman' |

`use` |
instructions for handling missing values. See details and |

`verbose` |
A value of '0' will suppress output |

### Details

The default correlation is the Pearson product moment correlation. If `method`

is 'spearman', then the Spearman's rank correlation is used, which is the Pearson correlation calculated using the ranks of the data.

If `X.train`

is NULL then correlations are calculated between each column of `X.test`

, but the correlation between a sample and itself will be assigned the value `NA`.

When `X.train`

is specified, correlations are calculated sequentially between each test observation and all training observations using `apply`

. Note that if missing values are present, they may be handled differently for different test samples.

### Value

A CCM correlation matrix with element (i,j) as follows: if `X.train`

is not NULL, then the correlation between the i(th) test sample and the j(th) training sample; otherwise the correlation between the i(th) and j(th) test samples, with NA along the diagonal.

### Author(s)

Garrett M. Dancik and Yuanbin Ru

### See Also

`cor`

, the function used to calculate correlations;
`predict.CCM`

, for classification based on the CCM matrix;
`plot.CCM`

for plotting correlations of test samples

### Examples

```
data(data.expr)
data(data.gender)
## split dataset into training / testing ##
train.expr = data.expr[,1:20]
test.expr = data.expr[,21:40]
train.gender = data.gender[1:20]
test.gender = data.gender[21:40]
## CCM using spearman correlation ##
K = create.CCM(test.expr, train.expr, method = "spearman")
## predict based on the class with the highest mean correlation (the default) ##
p = predict(K, train.gender)
table(pred = p, true = test.gender) # check accuracy
## CCM using pearson correlation ##
K = create.CCM(test.expr, train.expr, method = "pearson")
## predict based on the class with the maximum correlation
p = predict(K, train.gender, func = max)
table(pred = p, true = test.gender) # check accuracy
### leave-one-out cross validation on entire dataset ###
K = create.CCM(data.expr, method = "spearman")
p = predict(K, data.gender)
table(pred = p, true = data.gender) # check accuracy
```

*CCM*version 1.2 Index]