cor_cov {GPUmatrix}R Documentation

Correlation, Variance and Covariance for 'GPUmatrix' objects

Description

These functions mimic the stats functions cov and cor to compute on gpu.matrix objects: "cov and cor compute the covariance and correlation of x and y if these are vectors. If x and y are matrices then the covariances (or correlations) between the columns of x and the columns of y are computed."

cov2cor scales a covariance matrix into the corresponding correlation matrix efficiently.

Usage



## S4 method for signature 'gpu.matrix.tensorflow,ANY,ANY,ANY'
cor(x,y)
## S4 method for signature 'gpu.matrix.tensorflow,ANY,missing,character'
cor(x,y,method)
## S4 method for signature 'gpu.matrix.tensorflow,missing,missing,character'
cor(x,y,method)
## S4 method for signature 'ANY,gpu.matrix.tensorflow,ANY,ANY'
cor(x,y)
## S4 method for signature 'gpu.matrix.tensorflow,missing,ANY,ANY'
cor(x,y)

## S4 method for signature 'ANY,gpu.matrix.torch,ANY,ANY'
cor(x,y)
## S4 method for signature 'gpu.matrix.torch,ANY,ANY,ANY'
cor(x,y)
## S4 method for signature 'gpu.matrix.torch,ANY,missing,character'
cor(x,y,method)
## S4 method for signature 'gpu.matrix.torch,missing,missing,character'
cor(x,y,method)
## S4 method for signature 'gpu.matrix.torch,missing,missing,missing'
cor(x,y)
## S4 method for signature 'gpu.matrix.torch,missing,ANY,ANY'
cor(x,y)



## S4 method for signature 'gpu.matrix.tensorflow'
cov(x,y)
## S4 method for signature 'ANY,gpu.matrix.tensorflow'
cov(x,y)
## S4 method for signature 'gpu.matrix.tensorflow,ANY'
cov(x,y)
## S4 method for signature 'gpu.matrix.tensorflow,missing'
cov(x,y)


## S4 method for signature 'gpu.matrix.torch'
cov(x,y)
## S4 method for signature 'ANY,gpu.matrix.torch'
cov(x,y)
## S4 method for signature 'gpu.matrix.torch,ANY'
cov(x,y)
## S4 method for signature 'gpu.matrix.torch,missing'
cov(x,y)

## S4 method for signature 'gpu.matrix.tensorflow'
cov2cor(V)
## S4 method for signature 'gpu.matrix.torch'
cov2cor(V)



Arguments

x

a gpu.matrix.

y

NULL (default) or a vector, matrix, data frame or gpu.matrix with compatible dimensions to x.

method

a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default) or "spearman".

V

symmetric numeric gpu.matrix, usually positive definite such as a covariance matrix.

Details

These functions work in the same way as their counterparts in the 'stats' library. Note that the 'Kendal' method (implemented in the 'stats' library) is not available for working with gpu.matrix-class objects.

Notice that the inputs can be either an object of class 'matrix', 'Matrix' or 'gpu.matrix'. User must be sure that the input values must be numeric.

If the input gpu.matrix-class object(s) are stored on the GPU, then the operations will be performed on the GPU. See gpu.matrix. The result will be a gpu.matrix object.

For more details see cor and cov2cor.

Value

The result obtained by applying these functions will be a gpu.matrix object. For each function the result will be:

- cor correlation between x and y (when two vectors are the input) or the correlation between the columns of x and y if x and y are a gpu.matrix class object. If y is empty, is equivalent to y=x.

- cov the same as cor but compute the covariance.

- cov2cor scales a covariance matrix into the corresponding correlation matrix efficiently.

See Also

For more information: cor, cov, cov2cor,

Examples


## Not run: 
a <- gpu.matrix(rnorm(10))
b <- gpu.matrix(rnorm(10))
cor(a,b)

#example taken from stats corresponding help page:
longley_matrix <- as.matrix(longley)
longley_gpu <- as.gpu.matrix(longley_matrix)
C1 <- cor(longley_gpu)
cov(longley_gpu)
cov2cor(cov(longley_gpu))



## End(Not run)


[Package GPUmatrix version 1.0.2 Index]