gpt4 book ai didi

python - Python 中的验证性因素分析

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:12 28 4
gpt4 key购买 nike

是否有一个Python包可以进行验证性因子分析?我找到了一些可以在 python 中执行探索性因子分析的程序(scikitlearn、factor_analyzer 等),但我还没有找到执行 CFA 的包。

最佳答案

Spyder 中的 python 3.7.3(Anaconda Navigator)

factor_analyzer 也可以进行 CFA:

导入必要的库

import pandas as pd
from factor_analyzer import FactorAnalyzer

导入示例数据

df= pd.read_csv("test.csv")

验证性因素分析

from factor_analyzer import (ConfirmatoryFactorAnalyzer, ModelSpecificationParser)    

model_dict = {"F1": ["V1", "V2", "V3", "V4"], "F2": ["V5", "V6", "V7", "V8"]}

model_spec = ModelSpecificationParser.parse_model_specification_from_dict(df, model_dict)

cfa = ConfirmatoryFactorAnalyzer(model_spec, disp=False)

cfa.fit(df.values)

cfa.loadings_
  • V1 到 V8 是指数据框中您想要分配给每个因子(F1 和 F2)的列的名称。您需要根据您的数据集和要测试的假设,将 V1 到 V8 替换为适当的列名称。

关于python - Python 中的验证性因素分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54347275/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com