Published on :
Statistical CREATION_INTERNE

Example of Confirmatory Factor Analysis with PROC CALIS

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a 'scores' dataset containing six numerical variables. Then, it uses the CALIS procedure three times with slight variations to illustrate different syntaxes and options. The first PROC CALIS block defines a simple factor model. The second block specifies paths more explicitly and customizes fit indices. The third block generates a path diagram to visualize the factor model. The latent factors 'verbal' and 'math' are linked respectively to variables 'x1-x3' and 'y1-y3'.
Data Analysis

Type : CREATION_INTERNE


The 'scores' dataset is created directly within the script via a DATA STEP block and the 'datalines' statement. It contains scores for 32 observations for 6 variables (x1-x3, y1-y3).

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'scores' table by reading embedded data directly into the code using the 'datalines' statement. The table contains 6 numerical variables: x1, x2, x3, y1, y2, y3.
Copied!
1DATA scores;
2 INPUT x1 x2 x3 y1 y2 y3;
3 DATALINES;
4 23 17 16 15 14 16
5 29 26 23 22 18 19
6 14 21 17 15 16 18
7 20 18 17 18 21 19
8 25 26 22 26 21 26
9 26 19 15 16 17 17
10 14 17 19 4 6 7
11 12 17 18 14 16 13
12 25 19 22 22 20 20
13 7 12 15 10 11 8
14 29 24 30 14 13 16
15 28 24 29 19 19 21
16 12 9 10 18 19 18
17 11 8 12 15 16 16
18 20 14 15 24 23 16
19 26 25 21 24 23 24
20 20 16 19 22 21 20
21 14 19 15 17 19 23
22 14 20 13 24 26 25
23 29 24 24 21 20 18
24 26 28 26 28 26 23
25 20 23 24 22 23 22
26 23 24 20 23 22 18
27 14 18 17 13 16 14
28 28 34 27 25 21 21
29 17 12 10 14 12 16
30 8 1 13 14 15 14
31 22 19 19 13 11 14
32 18 21 18 15 18 19
33 12 12 10 13 13 16
34 22 14 20 20 18 19
35 29 21 22 13 17 12
36;
2 Code Block
PROC CALIS
Explanation :
This block executes an initial confirmatory factor analysis. The 'factor' statement defines two latent factors: 'verbal' (linked to variables x1 to x3) and 'math' (linked to variables y1 to y3). The 'pvar' statement sets the variance of each factor to 1 for model identification.
Copied!
1PROC CALIS DATA=scores;
2 factor
3 verbal ===> x1-x3,
4 math ===> y1-y3;
5 pvar
6 verbal = 1.,
7 math = 1.;
8RUN;
3 Code Block
PROC CALIS
Explanation :
This second call to PROC CALIS shows an alternative syntax for the 'factor' statement, where each path between the factor and the variable is declared individually. The 'fitindex' option is used to select and display specific model fit indices (Chi-square, RMSEA, SRMR, etc.).
Copied!
1title "Basic Confirmatory Factor Model: Separate Path Entries";
2title2 "FACTOR Model Specification";
3PROC CALIS DATA=scores;
4 factor
5 verbal ===> x1,
6 verbal ===> x2,
7 verbal ===> x3,
8 math ===> y1,
9 math ===> y2,
10 math ===> y3;
11 pvar
12 verbal = 1.,
13 math = 1.;
14 fitindex noindextype on(only)=[chisq df probchi rmsea srmr bentlercfi];
15RUN;
4 Code Block
PROC CALIS
Explanation :
This third block activates ODS graphics via 'ods graphics on'. PROC CALIS is then called with the 'plots=pathdiagram' option to generate a visual representation of the factor model. The syntax '= 1.' in the 'factor' statement is another way to fix factor loadings for identification. Graphics are then deactivated with 'ods graphics off'.
Copied!
1ods graphics on;
2PROC CALIS DATA=scores plots=pathdiagram;
3 factor
4 verbal ===> x1-x3 = 1. ,
5 math ===> y1-y3 = 1. ;
6RUN;
7ods graphics off;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : S A S S A M P L E L I B R A R Y