itemDescriptives: Compute basic descriptives for binary-item analysis

View source: R/itemDescriptives.R

itemDescriptivesR Documentation

Compute basic descriptives for binary-item analysis

Description

Compute basic descriptives for binary item analysis

Usage

itemDescriptives(X, digits = 3)

Arguments

X

a matrix of binary (0/1) item responses.

digits

number of digits to print.

Value

alpha

Coefficient alpha for the total scale.

means

item means.

standard deviations

item standard deviations.

pt. biserial correlations

corrected item-total point biserial correlations.

biserial correlations

corrected item-total point biserial correlations.

corrected.alpha

corrected (leave item out) alpha coefficients.

Author(s)

Niels Waller

Examples


	## Example 1: generating binary data to match
	## an existing binary data matrix
	##
	## Generate correlated scores using factor 
	## analysis model
	## X <- Z *L' + U*D 
	## Z is a vector of factor scores
	## L is a factor loading matrix
	## U is a matrix of unique factor scores
	## D is a scaling matrix for U

	Nsubj <- 2000
	L <- matrix( rep(.707,5), nrow = 5, ncol = 1)
	Z <-as.matrix(rnorm(Nsubj))
	U <-matrix(rnorm(Nsubj * 5),nrow = Nsubj, ncol = 5)
	tmp <-  sqrt(1 - L^2) 
	D<-matrix(0, 5, 5)
	diag(D) <- tmp
	X <- Z %*% t(L) + U%*%D

	cat("\nCorrelation of continuous scores\n")
	print(round(cor(X),3))

	thresholds <- c(.2,.3,.4,.5,.6)

	Binary<-matrix(0,Nsubj,5)
	for(i in 1:5){
	  Binary[X[,i]<=thresholds[i],i]<-1
	}   

	cat("\nCorrelation of Binary scores\n")
	print(round(cor(Binary),3))

	## Now use 'bigen' to generate binary data matrix with 
	## same correlations as in Binary

	z <- bigen(data = Binary, n = 5000)

	cat("\n\nnames in returned object\n")
	print(names(z))

	cat("\nCorrelation of Simulated binary scores\n")
	print(round( cor(z$data), 3))


	cat("Observed thresholds of simulated data:\n")
	cat( apply(z$data, 2, mean) )
	
	itemDescriptives(z$data)


fungible documentation built on March 31, 2023, 5:47 p.m.