简体   繁体   中英

How to use Stargazer R package with factor analysis output

I've used stargazer in the past with regression tables.

However I'd like to know how to use stargazer with output from factor analysis and principal component analysis.

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))

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. 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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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