test_pair: Test for association between two paired variables.

Description Usage Arguments Details Value Author(s) Examples

View source: R/test_pair.R

Description

Tests for association between two variables:

Categorical-Categorical

Using pearson's chi-squared test (chisq.test function from stats package).

Continuous-Continuous

Using correlation test (cor.test function from stats package).

Categorical-Continuous

Using analysis of variance model (aov function from stats package).

Usage

1
test_pair(data, var1_name, var2_name, levels = NULL)

Arguments

data

A dataframe. It is strongly recommended that the dataframe has no missing data and is preprocessed.

var1_name

First variable's name.

var2_name

Second variable's name.

levels

An integer value indicating the maximum number of levels of a categorical variable. To be used to distinguish the categorical variable. Defaults to NULL because it is supposed that data has been preprocessed using data_preproc and the categorical variables are specified.

Details

This provides a wrapper to chisq.test, cor.test, aov from stats package to test association between two variables

Value

P.value of test between the two variables.

Author(s)

Elyas Heidari

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Preprocess the data
data("NHANES")
data <- data_preproc(NHANES, levels = 15)
## Find test p.values for:
## One continuous and one categorical variable
cont_cat_test <- test_pair(data, var1_name = "LBXTC", var2_name = "RIAGENDR")
## Two continuous variables
cont_cont_test <- test_pair(data, var1_name = "LBXTC", var2_name = "LBXVIE")

## Two categorical variables
cat_cat_test <- test_pair(data, var1_name = "DIQ010", var2_name = "SMD410")

bAIo-lab/Questools documentation built on Nov. 9, 2019, 3:59 a.m.