correlateC {RCPA3}R Documentation

Correlation analysis for two or more numeric variables, with options for scatterplots, weighted observations, and inferential statistics.

Description

Given two or more numeric variables, correlateC reports correlation coefficients, along with inferential statistics (if requested), works with sampling weights. If more than two x variables are supplied, the function calculates correlation coefficients using pairwise complete observations (as opposed to limiting analysis to observations complete on all variables). The wtd.cor function is imported from the weights package. See wtd.cor documentation for details.

Usage

correlateC(x, w, data, digits = 3, stats = FALSE, printC = FALSE,
  plot = FALSE, jitter = FALSE, ...)

Arguments

x

A list of variables for correlation analysis, variables must be numeric. Should be entered as list(dataset$var1, dataset$var2, dataset$var3 ... ) form unless dataset specified in optional data argument.

w

(Optional) Sampling weights variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument.

data

(Optional) Name of dataset that contains x (and w) variable (optional).

digits

(Optional) Number of decimal places reported in result (defaults to 3).

stats

(Optional) Do you want the inferential statistics (standard errors, t-statistics, and p-values)? Default is FALSE. Set to TRUE for inferential statistics.

printC

(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results.

plot

(Optional) Do you want scatterplot(s)? Default is FALSE.

jitter

(Optional) Do you want scatterplot pointed jittered? By default, points jittered when there are more than 500 observations, but you can set this arguments to TRUE/FALSE to override the default.

...

(Optional) Additional arguments passed to weights::wtd.cor function.

Details

Makes use of the wtd.cor function, part of the weights package.

Value

Returns the coefficients of correlation among x variables; if stats=TRUE, inferential statistics returned in tables as well.

RCPA3 Package Tutorial Videos

Textbook References

Online Resources

Examples

   library(RCPA3)
   
   
   correlateC(x=list(abortlaws, women.stateleg), data=states, plot=FALSE)
   
   # with weighted observations and inferential statistics
   correlateC(x=list(nes$ft.rep, nes$ft.trump.pre, nes$ft.dem, nes$ft.biden.pre), 
              w=nes$wt, stats=TRUE)
   

[Package RCPA3 version 1.2.1 Index]