Description Usage Arguments Value Author(s) Examples

Computes correlation matrix for an arbitrary number of numeric variables, optionally within strata.

1 2 3 |

`...` |
an arbitrary number of variables for which a correlation matrix is desired. The
arguments can be vectors, matrices, or lists. Individual columns of a matrix or
elements of a list that are not of class |

`strata` |
vector, matrix, or list of stratification variables. Descriptive statistics will be
computed within strata defined by each unique combination of the stratification
variables, as well as in the combined sample. If |

`subset` |
vector indicating a subset to be used for all descriptive statistics. If |

`conf.level` |
a numeric scalar between 0 and 1 denoting the confidence level to be used in constructing confidence intervals for the correlation. |

`use` |
character string denoting the cases to use: |

`method` |
character string denoting the correlation method to use: |

`stat` |
a vector of character strings indicating the descriptive statistic(s) to be tabulated.
Possibilities include any statistic as specified by one or more of |

`byStratum` |
a logical scalar indicating whether statistics should be grouped by pair of
variables. If |

`version` |
if |

An object of class uCorrelate is returned, which consists of a list of correlation estimates and inference for each specified stratum and for the combined dataset. Each element of the list has six arrays:

`cormtx` |
the correlation matrix, printed. |

`n` |
matrix of sample sizes used to compute each correlation |

`t.stat` |
matrix of t-statistics, testing a correlation of 0. |

`pval` |
matrix of two-sided p-values for the t-test. |

`lo95%CI` |
lower bound of the 95% confidence interval. |

`hi95%CI` |
upper bound of the 95% confidence interval. |

Scott S. Emerson, M.D., Ph.D., Andrew J. Spieker, Brian D. Williamson, Travis Y. Hee Wai, and Solomon Lim

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
# Load required libraries
library(survival)
# Reading in a dataset
mri <- read.table("http://www.emersonstatistics.com/datasets/mri.txt",header=TRUE)
# Estimated correlation matrix using all data, complete cases, or pairwise complete (the default)
with (mri, correlate(age,weight,ldl,use="everything"))
with (mri, correlate(age,weight,ldl,use="complete"))
with (mri, correlate(age,weight,ldl))
# Correlation matrices for each stratum
with (mri, correlate(age,weight,ldl,strata=male))
# Correlations grouped by variable
with (mri, correlate(age,weight,ldl,strata=male,byStratum=FALSE))
# Special formatting of inference for correlations within strata
with (mri, correlate(age,weight,ldl,strata=male,stat="@[email protected] (@[email protected], @[email protected]); P @[email protected]; n= @[email protected]"))
# Special formatting of inference for correlations grouped by variable
with (mri, correlate(age,weight,ldl,strata=male,stat="@[email protected] (@[email protected], @[email protected]); P @[email protected]; n= @[email protected]",
byStratum=FALSE))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.