wtd.cor: Calculates Correlation Coefficient Between Two Numeric...

View source: R/helper.functions.r

wtd.corR Documentation

Calculates Correlation Coefficient Between Two Numeric Variables Makes use of the wtd.cor function, part of the weights package.

Description

Given two numeric variables, wtd.cor reports correlation coefficient, works with sampling weights. The wtd.cor function is imported from the weights package. See wtd.cor documentation for details.

Usage

wtd.cor(x1, x2, w = NULL, data, digits = 3, stats = FALSE, ...)

Arguments

x1

A variable (must be numeric), should be in dataset$var form unless dataset specified in optional data argument.

x2

Another variable, different than x1 (must be numeric), should be in dataset$var form unless dataset specified in optional data argument.

w

(Optional) Sampling weights of 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.

digits

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

stats

(Optional) Do you want inferential statistics for correlation coefficient? (default: FALSE)

...

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

Value

Returns the coefficient of correlation between x1 and x2 variables, a numeric value.

Examples

   library(RCPA3)
   
   wtd.cor(x1=nes$ft.rep, x2=nes$ft.pence.pre, w=nes$wt)
   wtd.cor(x1=ft.dem, x2=ft.harris.pre, w=wt, data=nes)

RCPA3 documentation built on May 29, 2024, 12:19 p.m.

Related to wtd.cor in RCPA3...