/* *************************************************************** */ /* */ /* CREATING COARSE ("SIMPLIFIED") FACTOR SCORES */ /* (Based on Eq. 5: Maximize R-squared) */ /* ---------------------------------------------- */ /* The user makes only one change to the program (marked in the */ /* code with a number) before running: */ /* 1. Desired options are set on the PROC FACTOR command. */ /* */ /* Note: The item correlation matrix must have an inverse for */ /* this program to run without producing an error. */ /* *************************************************************** */ options linesize=132 font='Sasfont' 8 nocenter; proc factor data=wisc m=ml n=4 r=v power=4 scree score outstat=fact; var piccom inform coding simila picara arithm blockd vocabu object compre symbol digits; /* 1 */ data ItmLabel; set fact; if _type_ = 'SCORE'; proc transpose data=ItmLabel out=ItmLabel; proc iml; reset fw=8 spaces=4; start sort(FSCVect, item, RankCoef, ItemR); n=nrow(FSCVect); ct=j(n,1,0); RankCoef=j(n,1,-9999); ItemR=j(n,1,' '); do j=1 to n; max=-9999; do i=1 to n; if FSCVect[i] > max then do; max=FSCVect[i]; place=i; end; end; FSCVect[place]=-9999; RankCoef[j]=max; ItemR[j]=item[place]; ct[j]=j; end; RankCoef=ct||RankCoef; finish sort; use ItmLabel; read all var{_name_} into Item; use fact; read all into ItemCor where(_type_ = 'CORR'); read all into Pattern where(_type_ = 'PATTERN'); Pattern=T(Pattern); nr=nrow(Pattern); nc=ncol(Pattern); read all into FactCor where(_type_ = 'FCORR'); if type(FactCor) = 'U' then FactCor = I(nc); FactCor=FactCor[1:nc,1:nc]; Struct=Pattern*FactCor; read all into N where(_type_ = 'N'); print , , "**** BEGIN OUTPUT FROM PROC IML **** ", , ; FSCoef=inv(ItemCor)*Struct; print "Factor Score Coefficients for Items / Factors", Item FSCoef [format=6.3], , ,; do j=1 to nc; FSCVect=FSCoef[,j]; run sort(FSCVect, item, RankCoef, Itemr); ranks=RankCoef; RankCoef=RankCoef[,2]; label=concat('Ranked Factor Score Coefficients: Factor ',char(j,2,0)); print label, Itemr RankCoef [format=6.3]; call pgraf(ranks, itemr, 'Rank','Factor Score Coefficient',label); end; C=t(FSCoef)*ItemCor*FSCoef; C=diag(C); C=sqrt(C); Univ=t(Struct)*FSCoef*inv(C); Valid=vecdiag(Univ); Rinv=inv(ItemCor); Errors=j(nr,nc,0); do i=1 to nr; do j=1 to nc; Errors[i,j] = sqrt((Rinv[i,i] * (1 - Valid[j]**2)) / (N[j] - nr - 1)); end; end; t_values=j(nr,nc,0); do i=1 to nr; do j=1 to nc; if Errors[i,j] <> 0 then t_values[i,j] = FSCoef[i,j] / Errors[i,j]; else t_values[i,j] = 0; end; end; print "Standard Errors and t-values for Factor Score Ceofficients", Item Errors [format=6.3] t_values [format=6.3], , ,; multR=t(Struct)*inv(ItemCor)*Struct; SMC=vecdiag(multR); /* multR=sqrt(vecdiag(multR)); */ Contrib = j(nr+1,nc,0); do i=1 to nr; do j=1 to nc; Contrib[i,j] = FSCoef[i,j] * Struct[i,j]; end; end; Item = Item // '.' // 'TOTALS'; Contrib[nr+1,] = .; Contrib = Contrib // T(SMC); print "Total Item Contribution to Squared Multiple Correlation", Item Contrib [format=6.3]; stop; run;