R语言library(psych)什么意思?

Python011

R语言library(psych)什么意思?,第1张

导入函数包psych

library()这个函数是把括号内包含的函数包导入,然后才可以运用psych中的一些现成的函数or模型。

psych函数包好像是一个和心理学等有关的函数包,Rstudio里给的psych函数包的定义如下:

A general purpose toolbox 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. Functions for simulating and testing particular item and test structures are included. Several functions serve as a useful front end for structural equation modeling. Graphical displays of path diagrams, 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 <https://personality-project.org/r>web page.

上述英文来自:网页链接

成分分析和探索性因子分析是两种用来探索和简化多变量复杂关系的常用方法。

主成分分析(PCA)是一种将数据降维技巧,它将大量相关变量转化成一组很少的不相关变量,这些无相关变量称为主成分。

探索性因子分析(EFA)是一系列用来发现一组变量的潜在结构的方法。

R基础安装包提供了PCA和EFA的函数,分别是princomp()和factanal()。本章重点介绍psych包中提供的函数,该包提供了比基础函数更丰富和有用的选项。

最常见步骤

1、数据预处理,在计算前请确保数据没有缺失值;

2、选择因子模型,是选择PCA还是EFA,如果选择EFA,需要选择一种估计因子模型,如最大似然法估计;

3、判断要选择的主成分/因子数目;

4、选择主成分/因子;

5、旋转主成分/因子;

6、解释结果;

7、计算主成分或因子得分。

加载psych包

library(ggplot2)

library(psych)

展示基于观测特征值的碎石检验、根据100个随机数据矩阵推导出来的特征值均值、以及大于1的特征值准则(Y=1的水平线)

fa.parallel(USJudgeRatings[, -1], fa = "pc", n.iter = 100, show.legend = FALSE, main = 'Scree plot with parallel analysis')

对数据USJudgeRatings进行主成分分析

pc<-principal(USJudgeRatings[, -1],nfactors=1)

pc