===== Run EQS from R for data analysis ===== ==== A working example ==== This example estimates a two factor model with mean structure. - Prepare data. We put data into a matrix with covariance matrix followed by means 2.845 0.759 0.227 0.76 0.876 -0.162 0.759 1.041 0.415 0.208 0.198 -0.1 0.227 0.415 1.433 0.006 0.192 0.248 0.76 0.208 0.006 1.051 0.576 0.084 0.876 0.198 0.192 0.576 1.073 0.236 -0.162 -0.1 0.248 0.084 0.236 0.81 0.305 0.096 0.072 0.183 0.203 0.122 The data are saved in a file called runr.dat. - Build a working EQS input file. For example, /TITLE SIMULATED CONFIRMATORY FACTOR ANALYSIS EXAMPLE (EXAMPLE IN EQS MANUAL P.117) RAW SCORES IN BENTLER (1985, P.105) DEFAULT START VALUES /SPECIFICATIONS CASES = 50; VARIABLES = 6; ME = ML, ROBUST; MAT=COV; data='runr.dat'; ANALYSIS=MOMENT; /EQUATIONS V1 =*V999 + *F1 + E1; V2 =*V999 + *F1 + E2; V3 =*V999 + *F1 + E3; V4 =*V999 + *F2 + E4; V5 =*V999 + *F2 + E5; V6 =*V999 + *F2 + E6; /VARIANCES F1 TO F2 = 1; E1 TO E6 = *; /COVARIANCE F1,F2 = *; /MEANS /OUTPUT CODEBOOK; DATA='runr.ETS'; PARAMETER ESTIMATES; STANDARD ERRORS; LISTING; /END  Note that: * The data file is specified by ''MAT=COV; data='runr.dat';'' * The means are provided by ''/MEANS'' in the model part. * We need to specify the output section in order to read results into R later on. - To run the analysis using REQS, the codes are write.table(rbind(cov.test, m.test),'runr.dat', row.names=F, col.names=F) res <- run.eqs(EQSpgm = '"C:/Program Files/EQS61/WINEQS"', EQSmodel = "c:/eqs61/examples/runr.eqs", serial = 1234) - To view the results, look at each component of res. > names(res) [1] "model.info" "pval" "fit.indices" "model.desc" "Phi" [6] "Gamma" "Beta" "par.table" "sample.cov" "sigma.hat" [11] "inv.infmat" "rinv.infmat" "cinv.infmat" "derivatives" "moment4" [16] "ssolution" "Rsquared" "fac.means" "var.desc" "indstd" [21] "depstd"