如何解决使用R将创建的“因子”从“ fa”函数映射到原始数据
我有一个数据框twin_dedup
,为此我只选择了需要输入到因子分析中的数值。我创建了因子模型fa_twindedup3
,但是现在如何将因子得分映射回twin_dedup
的原始数据框?我想要twin_dedup
中的所有变量和因子得分在哪里?
#removing missing values from background variables
twin_dedup <- twin[complete.cases(twin[,4:6]),]
t_subdedup = subset(twin_dedup,select = c("english","math","socsci","natsci","vocab"))
> head(twin_dedup)
id sex zygosity moed faed faminc english math socsci natsci vocab
1 1 2 1 3 4 2 14 13 17 18 14
2 1 2 1 3 4 2 11 14 15 10 12
3 2 2 1 1 1 1 20 20 16 16 13
4 2 2 1 1 1 1 17 19 13 13 14
5 3 2 1 1 1 1 11 8 15 16 12
6 3 2 1 1 1 1 16 13 13 8 15
fa_twindedup3 <- fa(t_subdedup,nfactors = 1,fm="wls",rotate = "varimax")
fa_twindedup3
> head(fa_twindedup3$scores)
WLS1
1 -1.1245230
2 -1.7486677
3 -0.9129794
4 -1.3063351
5 -1.6774486
6 -1.6304542
对此的任何帮助都是非常有用的。我想要最后一个数据框,其中包含twin_dedup
中的所有变量和fa_twindedup3$scores
中的一个变量
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。