/* -------------------------------------------------------- File: cfa.nfactors.wisc.sas Purpose: Using CFA and maximum likelihood to estimate the number of factors. NOTE VERY WELL: This code is useful only for checking the number of factors. It is NOT useful for interpreting the loadings. Data: from Tabachnick & Fidell, 3rd edition -------------------------------------------------------- */ /* -------------------------------------------------------- this code creates a temporary data set that is used for the duration of the SAS session. this is recommended practice to avoid messing up the original data set -------------------------------------------------------- */ *NOTE: LIBNAME p7291 must be assigned; *LIBNAME p7291 ''; /* -------------------------------------------------------- this code creates a temporary data set that is used for the duration of the SAS session. this is recommended practice to avoid messing up the original data set -------------------------------------------------------- */ DATA temp; set p7291.wiscsem; RUN; /* ------------------------------------------------------------ the CALIS statements the CORR option specifies that the correlation (and not not the covariance matrix) is analyzed the RESIDUAL option prints the residual correlation matrix. this is useful to inspect to assess the fit of the model. sometimes chi square may be lartge because of a large sample size, but the residuals are small. other times, the residuals are large and indicate those correlations that are very discrepant from the model. ------------------------------------------------------------- */ OPTIONS NOCENTER NODATE PAGENO=1; TITLE "T & F WISC Data Set: Confirmatory Factor Analysis"; TITLE2 "General Model: Three factor solution"; PROC CALIS DATA=temp CORR RESIDUAL; VAR info -- coding; /* --- Two very important issue about uncovering the number of factors: (1) No correlations among the factors (2) Set loadings to 0 as shown below: (2a) first factor = all free loadings (2b) second factor = 0 loading on first variable (2c) third factor = 0 loadings on first and second variable (2d) fourth factor = 0 loadings on first, second & third vars (2e) etc. --- */ LINEQS info = binfo1 f1 + 0 f2 + 0 f3 + e_info , comp = bcomp1 f1 + bcomp2 f2 + 0 f3 + e_comp , arith = barithf1 f1 + barith2 f2 + barith f3 + e_arith , simil = bsimil1 f1 + bsimul2 f2 + bsimil3 f3 + e_simul , vocab = bvocab1 f1 + bvocab2 f2 + bvocab3 f3 + e_vocab , digit = bdigit1 f1 + bdigit2 f2 + bdigit3 f3 + e_digit , pictcomp = bpictc1 f1 + bpictc2 f2 + bpictc3 f3 + e_pictc , parang = bparang1 f1 + bparang2 f2 + bparang3 f3 + e_parang, block = bblockf1 f1 + bblock2 f2 + bblock3 f3 + e_block , object = bonject1 f1 + bobject2 f2 + bonject3 f3 + e_object, coding = bcoding1 f1 + bcoding2 f2 + bcoding3 f3 + e_coding; /* --- note that the variances of the three latent factors are constrainted to equal 1. this is one of several different ways to scale the problem --- */ STD f1 = 1.0, f2 = 1.0, f3 = 1.0, e_info = ve_info , e_comp = ve_comp , e_arith = ve_arith , e_simul = ve_simul , e_vocab = ve_vocab , e_digit = ve_digit , e_pictc = ve_pictc , e_parang = ve_paran , e_block = ve_block , e_object = ve_objec , e_coding = ve_codin ; RUN; TITLE2 "Reduced Model: Two factor solution"; PROC CALIS DATA=temp CORR RESIDUAL; VAR info -- coding; /* --- Here Factor 3 disappears --- */ LINEQS info = binfo1 f1 + 0 f2 + e_info , comp = bcomp1 f1 + bcomp2 f2 + e_comp , arith = barithf1 f1 + barith2 f2 + e_arith , simil = bsimil1 f1 + bsimul2 f2 + e_simul , vocab = bvocab1 f1 + bvocab2 f2 + e_vocab , digit = bdigit1 f1 + bdigit2 f2 + e_digit , pictcomp = bpictc1 f1 + bpictc2 f2 + e_pictc , parang = bparang1 f1 + bparang2 f2 + e_parang, block = bblockf1 f1 + bblock2 f2 + e_block , object = bonject1 f1 + bobject2 f2 + e_object, coding = bcoding1 f1 + bcoding2 f2 + e_coding; /* --- note that the variances of the two latent factors are constrainted to equal 1. this is one of several different ways to scale the problem --- */ STD f1 = 1.0, f2 = 1.0, e_info = ve_info , e_comp = ve_comp , e_arith = ve_arith , e_simul = ve_simul , e_vocab = ve_vocab , e_digit = ve_digit , e_pictc = ve_pictc , e_parang = ve_paran , e_block = ve_block , e_object = ve_objec , e_coding = ve_codin ; RUN;