pointbiserial: Point-biserial correlation

View source: R/pointbiserial.R

pointbiserialR Documentation

Point-biserial correlation

Description

Estimates the point-biserial correlation coefficient between dichotomous items and the person's score.

Usage

pointbiserial(x, wt = NULL, exclude = FALSE, listwise = FALSE, recScore = TRUE)

Arguments

x

a numeric data frame or matrix containing only two categories.

wt

a numeric vector of total weights. Default is NULL.

exclude

a logical value indicating if the point-biserial correlation should be calculated excluding the item from the total score. Defaulft is FALSE.

listwise

only consider complete data (remove rows with NAs). Defaulft is FALSE.

recScore

a logical value indicating if the total score for should be calculated based only on valid values. Thus, if TRUE: rowMeans(x,na.rm = TRUE)*apply(x,1L,function(k) sum(!is.na(k))); if FALSE: rowMeans(x,na.rm = TRUE)*ncol(x). Defaulft is TRUE. If listwise, this argument is meaningless.

Value

A numeric vector with the point-biserial correlation coefficients by item.

Examples

data(dichodata)
data(dichokey)

# Data preparation
## Corrected data
corr <- correct(x = dichodata, key = dichokey, navalue = NA)
## Random weights creation
set.seed(1919)
wt <- sample(x = 1:4, size = nrow(corr), replace = TRUE)


# Correlations without weights
pointbiserial(x = corr, wt = NULL)

# Correlations with weights
pointbiserial(x = corr, wt = wt)

# Correlations if item is excluded
pointbiserial(x = corr, exclude = TRUE)

# Correlations if NAs are considered 0s (recScore)
pointbiserial(x = corr, recScore = FALSE)

# Correlations with listwise
pointbiserial(x = corr, listwise = TRUE)


classicaltest documentation built on Oct. 28, 2024, 5:06 p.m.