/* ---------------------------------------------------------
FILE: sem.nmtwins.sas
DATA: National Merit Twin data
PURPOSE: Structural Equation Modeling. Compare this with
the output from file multreg.nmtwins.sas which does
a multivariate multiple regression.
We will predict the Verbal and the Quant factor from
the National Merit Test using family demographics.
---------------------------------------------------------- */
* - NOTE: Assign LIBNAME p7291 to the directory/folder
containing the Natinoal Merit Twin data;
*LIBNAME p7291 '';
OPTIONS NOCENTER NODATE PAGENO=1;
* - first we will use factor analysis to get the factor
scores;
PROC FACTOR DATA=p7291.nmtwins OUT=temp ROTATE=promax
N=2 SCORE;
VAR english--math;
RUN;
* - remane the factors;
DATA temp (RENAME=(Factor1=Verbal Factor2=Quant));
SET temp;
RUN;
/* A little tip here:
If you have a very large data set and want to avoid
all the computation involved in getting a correlation
matrix or a covariance matrix, use PROC CORR and save
the covariance matrix or correlation matrix. The
following statements show how to do that.
The NOPRINT option supresses printed output.
The NOMISS option is equivalent to listwise deletion in
SPSS--i.e., an observation with a missing value on any
variable is elminated from the analysis. This is a recommended,
albeit conservative, way of handling missing data for path
analysis.
The COV options saves the covariance matrix as well as the
the correlation matrix.
The OUT= option save the statistics (N, means, standard
deviations, covariance matrix, and correlation matrix) to
the named data set, "nmtcov" in this case. */
PROC CORR DATA=temp NOPRINT NOMISS COV OUT=nmtcov;
VAR moed faed FamInc verbal quant;
RUN;
/* ---------------------------------------------------
The following code uses PROC CALIS to perform
a path analysis identical to that you did in a
previous homework. Verify that the answers are
the same as those you calculated using multiple
regression
---------------------------------------------------- */
PROC CALIS DATA=nmtcov CORR PRINT;
VAR moed faed FamInc verbal quant;
LINEQS
verbal = vm moed + vf faed + vinv FamInc + ev,
quant = qm moed + qf faed + qinv FamInc + eq;
STD ev=var_ev, eq=var_eq;
COV ev eq = ceveq;
RUN;
/* ---------------------------------------------------
The following code uses PROC CALIS to perform
a path analysis using the latent variable called
f1 as family background. Mother's education,
father's education, and family income are measures
of this latent factor
---------------------------------------------------- */
PROC CALIS DATA=nmtcov CORR PRINT;
VAR moed faed FamInc verbal quant;
LINEQS
moed = 1 f1 + e1,
faed = b2 f1 + e2,
FamInc = b3 f1 + e3,
verbal = b4 f1 + e4,
quant = b5 f1 + e5;
STD f1 = vf1, e1-e5 = ve1-ve5;
COV e4 e5 = ce4e5;
RUN;