Learn R Programming

psych (version 2.4.6.26)

Procedures for Psychological, Psychometric, and Personality Research

Description

A general purpose toolbox developed originally for personality, psychometric theory and experimental psychology. Functions are primarily for multivariate analysis and scale construction using factor analysis, principal component analysis, cluster analysis and reliability analysis, although others provide basic descriptive statistics. Item Response Theory is done using factor analysis of tetrachoric and polychoric correlations. Functions for analyzing data at multiple levels include within and between group statistics, including correlations and factor analysis. Validation and cross validation of scales developed using basic machine learning algorithms are provided, as are functions for simulating and testing particular item and test structures. Several functions serve as a useful front end for structural equation modeling. Graphical displays of path diagrams, including mediation models, factor analysis and structural equation models are created using basic graphics. Some of the functions are written to support a book on psychometric theory as well as publications in personality research. For more information, see the web page.

Copy Link

Version

Install

install.packages('psych')

Monthly Downloads

150,960

Version

2.4.6.26

License

GPL (>= 2)

Maintainer

Last Published

June 27th, 2024

Functions in psych (2.4.6.26)

Gorsuch

Example data set from Gorsuch (1997) for an example factor extension.
Harman

Five data sets from Harman (1967). 9 cognitive variables from Holzinger and 8 emotional variables from Burt
RV

Three measures of the correlations between sets of variables
SD

Find the Standard deviation for a vector, matrix, or data.frame - do not return error if there are no cases
Garcia

Data from the sexism (protest) study of Garcia, Schmitt, Branscome, and Ellemers (2010)
Gleser

Example data from Gleser, Cronbach and Rajaratnam (1965) to show basic principles of generalizability theory.
00.psych

A package for personality, psychometric, and psychological research
ICC

Intraclass Correlations (ICC1, ICC2, ICC3 from Shrout and Fleiss)
iclust

iclust: Item Cluster Analysis -- Hierarchical cluster analysis using psychometric principles
KMO

Find the Kaiser, Meyer, Olkin Measure of Sampling Adequacy
ICLUST.rgraph

Draw an ICLUST graph using the Rgraphviz package
Yule

From a two by two table, find the Yule coefficients of association, convert to phi, or tetrachoric, recreate table the table to create the Yule coefficient.
bassAckward

The Bass-Ackward factoring algorithm discussed by Goldberg
anova.psych

Model comparison for regression, mediation, cluster and factor analysis
bfi

25 Personality items representing 5 factors
AUC

Decision Theory measures of specificity, sensitivity, and d prime
ICLUST.sort

Sort items by absolute size of cluster loadings
ICLUST.cluster

Function to form hierarchical cluster analysis of items
ICLUST.graph

create control code for ICLUST graphical output
Pinv

Compute the Moore-Penrose Pseudo Inverse of a matrix
bi.bars

Draw pairs of bargraphs based on two groups
Schmid

12 variables created by Schmid and Leiman to show the Schmid-Leiman Transformation
scoreOverlap

Find correlations of composite variables (corrected for overlap) from a larger matrix.
alpha

Find two estimates of reliability: Cronbach's alpha and Guttman's Lambda 6.
bestScales

A bootstrap aggregation function for choosing most predictive unit weighted items
cluster2keys

Convert a cluster vector (from e.g., kmeans) to a keys matrix suitable for scoring item clusters.
Bechtoldt

Seven data sets showing a bifactor solution.
cluster.fit

cluster Fit: fit of the cluster model to a correlation matrix
VSS.plot

Plot VSS fits
cluster.loadings

Find item by cluster correlations, corrected for overlap and reliability
Tucker

9 Cognitive variables discussed by Tucker and Lewis (1973)
cohen.d

Find Cohen d and confidence intervals
VSS

Apply the Very Simple Structure, MAP, and other criteria to determine the appropriate number of factors.
cattell

12 cognitive variables from Cattell (1963)
Promax

Perform Procustes,bifactor, promax or targeted rotations and return the inter factor angles.
cluster.plot

Plot factor/cluster loadings and assign items to clusters by their highest loading.
corTest

Find the correlations, sample sizes, and probability values between elements of a matrix or data.frame.
densityBy

Create a 'violin plot' or density plot of the distribution of a set of variables
VSS.scree

Plot the successive eigen values for a scree test
VSS.parallel

Compare real and random VSS solutions
comorbidity

Convert base rates of two diagnoses and their comorbidity into phi, Yule, and tetrachorics
cta

Simulate the C(ues) T(endency) A(ction) model of motivation
correct.cor

Find dis-attenuated correlations given correlations and reliabilities
congruence

Matrix and profile congruences and distances
circ.tests

Apply four tests of circumplex versus simple structure
Dwyer

8 cognitive variables used by Dwyer for an example.
eigen.loadings

Convert eigen vectors and eigen values to the more normal (for psychologists) component loadings
ellipses

Plot data and 1 and 2 sigma correlation ellipses
error.bars

Plot means and confidence intervals
cor2dist

Convert correlations to distances (necessary to do multidimensional scaling of correlation data)
block.random

Create a block randomized structure for n independent variables
RMSEA

Root Mean Squared Error of Approximation from chisq, df, and n
corFiml

Find a Full Information Maximum Likelihood (FIML) correlation or covariance matrix from a data matrix with missing data
bigCor

Find large correlation matrices by stitching together smaller ones found more rapidly
biplot.psych

Draw biplots of factor or component scores by factor or component loadings
draw.tetra

Draw a correlation ellipse and two normal curves to demonstrate tetrachoric correlation
dummy.code

Create dummy coded variables
corPlot

Create an image plot for a correlation or factor matrix
corCi

Bootstrapped and normal confidence intervals for raw and composite correlations
cosinor

Functions for analysis of circadian or diurnal data
fa.diagram

Graph factor loading matrices
bock

Bock and Liberman (1970) data set of 1000 observations of the LSAT
pairwiseCount

Count number of pairwise cases for a data set with missing (NA) data and impute values.
error.crosses

Plot x and y error bars
esem

Perform and Exploratory Structural Equation Model (ESEM) by using factor extension techniques
cor.smooth

Smooth a non-positive definite correlation matrix to make it positive definite
fa.poly

Deprecated Exploratory Factor analysis functions. Please use fa
fa

Exploratory Factor analysis using MinRes (minimum residual) as well as EFA by Principal Axis, Weighted Least Squares or Maximum Likelihood
fa.extension

Apply Dwyer's factor extension to find factor loadings for extended variables
faCor

Correlations between two factor analysis solutions
fa.multi

Multi level (hierarchical) factor analysis
cor.wt

The sample size weighted correlation may be used in correlating aggregated data
error.dots

Show a dot.chart with error bars for different groups or variables
cortest.bartlett

Bartlett's test that a correlation matrix is an identity matrix
factor.fit

How well does the factor model fit a correlation matrix. Part of the VSS package
cortest

Chi square tests of whether a single matrix is an identity matrix, or a pair of matrices are equal.
fparse

Parse and exten formula input from a model and return the DV, IV, and associated terms.
fa.random

A first approximation to Random Effects Exploratory Factor Analysis
describe

Basic descriptive statistics useful for psychometrics
describeBy

Basic summary statistics by group
fa.sort

Sort factor analysis or principal components analysis loadings
diagram

Helper functions for drawing path model diagrams
geometric.mean

Find the geometric mean of a vector or columns of a data.frame.
factor.model

Find R = F F' + U2 is the basic factor model
kaiser

Apply the Kaiser normalization when rotating factors
lmCor

Multiple Regression, Canonical and Set Correlation from matrix or raw input
fa.lookup

A set of functions for factorial and empirical scale construction
fa.parallel

Scree plots of data or correlation matrix compared to random ``parallel" matrices
error.bars.by

Plot means and confidence intervals for multiple groups
cohen.kappa

Find Cohen's kappa and weighted kappa coefficients for correlation of two raters
factor.scores

Various ways to estimate factor scores for the factor analysis model
factor.residuals

R* = R- F F'
errorCircles

Two way plots of means, error bars, and sample sizes
factor.stats

Find various goodness of fit statistics for factor analysis and principal components
faRotations

Multiple rotations of factor loadings to find local minima
irt.fa

Item Response Analysis by Exploratory Factor Analysis of tetrachoric/polychoric correlations
factor.rotate

``Hand" rotate a factor loading matrix
glb.algebraic

Find the greatest lower bound to reliability.
lowerUpper

Combine two square matrices to have a lower off diagonal for one, upper off diagonal for the other
logistic

Logistic transform from x to p and logit transform from p to x
mssd

Find von Neuman's Mean Square of Successive Differences
factor.congruence

Coefficient of factor congruence
multi.hist

Multiple histograms with density and normal fits on one page
irt.item.diff.rasch

Simple function to estimate item difficulties using IRT concepts
factor2cluster

Extract cluster definitions from factor loadings
omega.graph

Graph hierarchical factor structures
harmonic.mean

Find the harmonic mean of a vector, matrix, or columns of a data.frame
headTail

Combine calls to head and tail
splitHalf

Alternative estimates of test reliabiity
fisherz

Transformations of r, d, and t including Fisher r to z and z to r and confidence intervals
iclust.diagram

Draw an ICLUST hierarchical cluster structure diagram
multilevel.reliability

Find and plot various reliability/gneralizability coefficients for multilevel data
irt.1p

Item Response Theory estimate of theta (ability) using a Rasch (like) model
manhattan

"Manhattan" plots of correlations with a set of criteria.
interp.median

Find the interpolated sample median, quartiles, or specific quantiles for a vector, matrix, or data frame
omega

Calculate McDonald's omega estimates of general and total factor saturation
matrix.addition

A function to add two vectors or matrices
irt.responses

Plot probability of multiple choice responses as a function of a latent trait
psych.misc

Miscellaneous helper functions for the psych package
mediate

Estimate and display direct and indirect effects of mediators and moderator in path models
make.keys

Create a keys matrix for use by score.items or cluster.cor
partial.r

Find the partial correlations for a set (x) of variables with set (y) removed.
mixedCor

Find correlations for mixtures of continuous, polytomous, and dichotomous variables
pairs.panels

SPLOM, histograms and correlations for a data matrix
parcels

Find miniscales (parcels) of size 2 or 3 from a set of items
print.psych

Print and summary functions for the psych class
phi.demo

A simple demonstration of the Pearson, phi, and polychoric corelation
outlier

Find and graph Mahalanobis squared distances to detect outliers
phi

Find the phi coefficient of correlation between two dichotomous variables
phi2tetra

Convert a phi coefficient to a tetrachoric correlation
mat.sort

Sort the elements of a correlation matrix to reflect factor loadings
scaling.fits

Test the adequacy of simple choice, logistic, or Thurstonian scaling.
r.test

Tests of significance for correlations
p.rep

Find the probability of replication for an F, t, or r and estimate effect size
rangeCorrection

Correct correlations for restriction of range. (Thorndike Case 2)
plot.psych

Plotting functions for the psych package of class ``psych"
reliability

Reports 7 different estimates of scale reliabity including alpha, omega, split half
polychor.matrix

Phi or Yule coefficient matrix to polychoric coefficient matrix
polar

Convert Cartesian factor loadings into polar coordinates
rescale

Function to convert scores to ``conventional " metrics
mardia

Calculate univariate or multivariate (Mardia's test) skew and kurtosis for a vector, matrix, or data.frame
predict.psych

Prediction function for factor analysis, principal components (pca), bestScales
reverse.code

Reverse the coding of selected items prior to scale analysis
scatterHist

Draw a scatter plot with associated X and Y histograms, densities and correlation
paired.r

Test the difference between (un)paired correlations
sat.act

3 Measures of ability: SATV, SATQ, ACT
predicted.validity

Find the predicted validities of a set of scales based on item statistics
sim.VSS

create VSS like data
scrub

A utility for basic data cleaning and recoding. Changes values outside of minimum and maximum limits to NA.
sim

Functions to simulate psychological/psychometric data.
sim.anova

Simulate a 3 way balanced ANOVA or linear model, with or without repeated measures.
residuals.psych

Extract residuals from various psych objects
principal

Principal components analysis (PCA)
small.msq

A small example data set taken from a larger data set
smc

Find the Squared Multiple Correlation (SMC) of each variable with the remaining variables in a matrix
sim.congeneric

Simulate a congeneric data set with or without minor factors
spider

Make "radar" or "spider" plots.
structure.list

Create factor model matrices from an input list
superMatrix

Form a super matrix from two sub matrices.
sim.structure

Create correlation matrices or data matrices with a particular measurement and structural model
withinBetween

An example of the distinction between within group and between group correlations
simulation.circ

Simulations of circumplex and simple structure
sim.hierarchical

Create a population or sample correlation matrix, perhaps with hierarchical structure.
sim.irt

Functions to simulate psychological/psychometric data.
schmid

Apply the Schmid Leiman transformation to a correlation matrix
scoreIrt

Find Item Response Theory (IRT) based scores for dichotomous or polytomous items
score.alpha

Score scales and find Cronbach's alpha as well as associated statistics
sim.item

Generate simulated data structures for circumplex, spherical, or simple structure
scoreItems

Score item composite scales and find Cronbach's alpha, Guttman lambda 6 and item whole correlations
sim.multilevel

Simulate multilevel data with specified within group and between group correlations
sim.omega

Further functions to simulate psychological/psychometric data.
test.irt

A simple demonstration (and test) of various IRT scoring algorthims.
testRetest

Find various test-retest statistics, including test, person and item reliability
test.psych

Testing of functions in the psych package
score.multiple.choice

Score multiple choice items and provide basic test statistics
table2matrix

Convert a table with counts to a matrix or data.frame representing those counts.
scoreWtd

Score items using regression or correlation based weights
statsBy

Find statistics (including correlations) within and between groups for basic multilevel analyses
Tal_Or

Data set testing causal direction in presumed media influence
structure.diagram

Draw a structural equation model specified by two measurement models and a structural model
tetrachoric

Tetrachoric, polychoric, biserial and polyserial correlations from various types of input
unidim

Several indices of the unidimensionality of a set of variables.
thurstone

Thurstone Case V scaling
winsor

Find the Winsorized scores, means, sds or variances for a vector, matrix, or data.frame
tr

Find the trace of a square matrix