简体   繁体   English

如何使用带有因子分析输出的 Stargazer R 包

[英]How to use Stargazer R package with factor analysis output

I've used stargazer in the past with regression tables.我过去曾使用过带有回归表的 stargazer。

However I'd like to know how to use stargazer with output from factor analysis and principal component analysis.但是我想知道如何将 stargazer 与因子分析和主成分分析的输出一起使用。

My code runs as follows:我的代码运行如下:

fa1 <- factanal(new2, factors = 4, rotation = "varimax", sort = TRUE)
print(fa1, digits = 3, cutoff = .5, sort = TRUE)
load <- fa1$loadings[,1:2] 
plot(load,type="n")
text(load,labels=names(new2),cex=.7) 

AND

two <- pca(new2, nfactors = 3)

THIS doesn't work - my only attempt so far.这不起作用 - 到目前为止我唯一的尝试。

stargazer(fa1, type = "text", title="Descriptive statistics", digits=1, out="table1.txt")

UPDATE: Since posting I have been able to convert the object to a data frame with:更新:自发布以来,我已经能够将对象转换为数据框:

converted <- as.data.frame(unclass(fa1$loadings))转换 <- as.data.frame(unclass(fa1$loadings))

I then used the code above successfully EXCEPT that the output doesn't seem to include individual factor scores.然后我成功地使用了上面的代码,除了输出似乎不包括单个因素分数。

See below:见下文:

loadings负荷

this might not be a perfect sulution and you might have found out by now, but what you can do is to output the factor scores separately with stagazer by adding summary = FALSE as an option.这可能不是一个完美的解决方案,您现在可能已经发现了,但是您可以做的是通过添加summary = FALSE作为选项,使用 stagazer 单独输出因子分数。 This way you get only the factor loadings as an output.通过这种方式,您只能将因子载荷作为输出。 For example like this:例如像这样:

stargazer(fa1, summary = FALSE, title="Descriptive statistics", digits=1, out="table1.txt")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM