Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
John Luke Gallup <jlgallup@pdx.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Commands to send factor analysis to another application |

Date |
Wed, 5 Dec 2012 13:39:16 -0800 |

Kerry, You can use the command -frmttable- to create the table you describe. Commands like -outreg-, -outreg2-, and -estout- don't work because -factor- does not save results in the e(b) and e(V) matrices used by these programs. -frmttable- takes results from a generic Stata matrix and creates a formatted table with them. It is distributed with the -outreg- package. The following code pieces together a table like the one you describe: sysuse auto, clear factor price-foreign, pcf rotate, promax predict f1 f2 f3 alpha price-foreign, generate(factor1) scalar alpha1 = r(alpha) alpha rep78-foreign, generate(factor2) scalar alpha2 = r(alpha) alpha trunk-foreign, generate(factor3) scalar alpha3 = r(alpha) // make table of rotated factor loadings frmttable, statmat(e(r_L)) varlabels // insert blank row; need -blankrows- option from now on mat row = J(1,`e(f)',.) frmttable, statmat(row) blankrows append // append eigenvalues>1 mat Ev = e(Ev) mat Ev = Ev[1, 1..`e(f)'] frmttable, statmat(Ev) blankrows append // cumulative? variance frmttable, statmat(e(r_Ev)) rtitle(Variance) blankrows append // Cronbach's alpha mat alpha = (alpha1, alpha2, alpha3) frmttable using fac_test, statmat(alpha) rtitle(Alpha) blankrows append The resulting table looks like this: ----------------------------------------------------- Factor1 Factor2 Factor3 ----------------------------------------------------- Price 1.13 0.35 -0.23 Mileage (mpg) -0.57 0.29 -0.14 Repair Record 1978 0.17 1.03 0.28 Headroom (in.) -0.22 0.11 1.07 Trunk space (cu. ft.) 0.18 0.10 0.84 Weight (lbs.) 0.60 -0.36 0.20 Length (in.) 0.48 -0.30 0.36 Turn Circle (ft.) 0.34 -0.55 0.19 Displacement (cu. in.) 0.59 -0.38 0.16 Gear Ratio -0.41 0.55 -0.05 Car type 0.13 0.92 -0.08 Eigenvalues 6.79 1.32 1.02 Variance 5.17 5.14 4.66 Alpha 0.27 0.25 0.26 ----------------------------------------------------- John On Dec 3, 2012, at 8:07 AM, "MacQuarrie, Kerry" <Kerry.MacQuarrie@icfi.com> wrote: > Hello Statalisters, > > I am wondering if there are available commands (either native or user-written) to select from the results of factor analysis procedures and produce tables in another application (namely Excel). I have used tabout, estout, and outreg commands for doing so with descriptive and regression results, but I'm stymied here. I've also been reading an (somewhat older) Stata Journal article* on using the file command, but it's not clear that is exactly what I'm looking for either. > > My basic code for the factor analysis takes the form of: > > factor var1 var2 var3 ... vark, pcf > rotate, promax > predict f1 f2 f3 > alpha var1 var2...vark, generate(factor1) > alpha var3 var4...vark, generate(factor2) > alpha var5 var6...vark, generate(factor3) > > I want to save a table that has the rotated factor loadings that comes from the second line of syntax--this is the core of the table--, but I want to append an output table with other pieces of information too. These would include the eigenvalues and cumulative variance (but only for the retained factors, e.g. those with eigenvalues>1) from the first line and the Cronbach's alpha for each of the factors in lines 4-6. > > Another complication is that the above factor analysis code will likely be modified into looped code, as I am running the factor analyses on multiple country datasets, each of which (so far) appear to have the same structure regarding these factors. > > Any tips on where to start would be much, much appreciated. > > Regards, > Kerry > > *Slaymaker, E. (2005) "Using the file command to produce formatted output for other applications." The Stata Journal 5(2): 239-247. > > Kerry MacQuarrie > > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: Commands to send factor analysis to another application***From:*"MacQuarrie, Kerry" <Kerry.MacQuarrie@icfi.com>

**References**:**st: Commands to send factor analysis to another application***From:*"MacQuarrie, Kerry" <Kerry.MacQuarrie@icfi.com>

- Prev by Date:
**Re: st: example about choice experiment datasheet** - Next by Date:
**Re: st: Random effect Cox Regression_Shared() option in stcox** - Previous by thread:
**st: Commands to send factor analysis to another application** - Next by thread:
**RE: st: Commands to send factor analysis to another application** - Index(es):