partialcor.table {petersenlab}R Documentation

Partial Correlation Matrix.

Description

Function that creates a partial correlation matrix similar to SPSS output.

Usage

partialcor.table(
  x,
  y,
  z = NULL,
  type = "none",
  dig = 2,
  correlation = "pearson"
)

Arguments

x

Variable or set of variables in the form of a vector or dataframe to correlate with y (if y is specified) in an any asymmetric correlation matrix or with itself in a symmetric correlation matrix (if y is not specified).

y

(optional) Variable or set of variables in the form of a vector or dataframe to correlate with x.

z

Covariate(s) to partial out from association.

type

Type of correlation matrix to print. One of:

  • "none" = correlation matrix with r, n, p-values

  • "latex" = generates latex code for correlation matrix with only r-values

  • "latexSPSS" = generates latex code for full SPSS-style correlation matrix

  • "manuscript" = only r-values, 2 digits; works with x only (cannot enter variables for y)

  • "manuscriptBig" = only r-values, 2 digits, no asterisks; works with x only (cannot enter variables for y)

  • "manuscriptLatex" = generates latex code for: only r-values, 2 digits; works with x only (cannot enter variables for y)

  • "manuscriptBigLatex" = generates latex code for: only r-values, 2 digits, no asterisks; works with x only (cannot enter variables for x)

dig

Number of decimals to print.

correlation

Method for calculating the association. One of:

  • "pearson" = Pearson product moment correlation coefficient

  • "spearman" = Spearman's rho

  • "kendall" = Kendall's tau

Details

Co-created by Angela Staples (astaples@emich.edu) and Isaac Petersen (isaac-t-petersen@uiowa.edu). Creates a partial correlation matrix, controlling for one or more covariates. For a standard correlation matrix, see cor.table.

Value

A partial correlation matrix.

See Also

Other correlations: addText(), cor.table(), crossTimeCorrelation(), crossTimeCorrelationDF(), vwReg()

Examples

# Prepare Data
data("mtcars")

#Correlation Matrix
partialcor.table(mtcars[,c("mpg","cyl","disp")], z = mtcars$hp)
partialcor.table(mtcars[,c("mpg","cyl","disp")], z = mtcars[,c("hp","wt")])
partialcor.table(mtcars[,c("mpg","cyl","disp")], z = mtcars[,c("hp","wt")],
  dig = 3)
partialcor.table(mtcars[,c("mpg","cyl","disp")], z = mtcars[,c("hp","wt")],
  dig = 3, correlation = "spearman")

partialcor.table(mtcars[,c("mpg","cyl","disp")], z = mtcars[,c("hp","wt")],
  type = "manuscript", dig = 3)
partialcor.table(mtcars[,c("mpg","cyl","disp")], z = mtcars[,c("hp","wt")],
  type = "manuscriptBig")

table1 <- partialcor.table(mtcars[,c("mpg","cyl","disp")],
  z = mtcars[,c("hp","wt")], type = "latex")
table2 <- partialcor.table(mtcars[,c("mpg","cyl","disp")],
  z = mtcars[,c("hp","wt")], type = "latexSPSS")
table3 <- partialcor.table(mtcars[,c("mpg","cyl","disp")],
  z = mtcars[,c("hp","wt")], type = "manuscriptLatex")
table4 <- partialcor.table(mtcars[,c("mpg","cyl","disp")],
  z = mtcars[,c("hp","wt")], type = "manuscriptBigLatex")

partialcor.table(mtcars[,c("mpg","cyl","disp")], mtcars[,c("drat","qsec")],
  mtcars[,c("hp","wt")])
partialcor.table(mtcars[,c("mpg","cyl","disp")], mtcars[,c("drat","qsec")],
  mtcars[,c("hp","wt")], type = "manuscript", dig = 3)

[Package petersenlab version 1.0.0 Index]