TexaSoft Home

Star Tutorials Menu

star3 BASIC WINKS

Star2 PROFESSIONAL

"I consider WINKS a treasure."
- Bill Lafitte, Pepperdine University - GSEP

Order WINKS NOW

 


Winks Manual

  Order WINKS Now 

7

These WINKS SDA statistics tutorials explain the use and interpretation of standard statistical analysis techniques for Medical, Pharmaceutical, Clinical Trials, Marketing or Scientific Research. The examples include how-to instructions for WINKS SDA Version 7.0 Software. Download evaluation copy of WINKS

Simple Factor Analysis Example
Using R for WINKS

The data for this example are National Merit scores, transformed to standard normal. This described how to run the R program from WINKS. This is not a complete description of Factor Analysis, just an example of how you could use some of the factor analysis modules in R to do an analysis from WINKS. WINKS R is an experimental feature of WINKS SDA 7.

Step 1. In WINKS, open the file named FACTOR_Example.SDA.

Typically, a first step in a factor analysis is determining the number of factors. In this example, we use a SCREE option to plot the eigenvalues. This plot is a two-dimensional graph with factors on the x-axis (bottom) and eigenvalues on the y-axis (vertical). The eigenvalues are produced by principal components analysis (PCA) and they represent the variance accounted for by each underlying factor.

The R-Code in the WINKSPROG.WR file that sets up the dialog box and runs the analysis is as follows

~BEGIN=Factor Analysis
INSTRUCTIONS=Enter variables to use for the Factor Analysis. Select number of Factors using the OPTIONS BUTTON. This program requires that the R program be installed on your computer. For more information, choose the R Properties/Setup/Help option in the R menu and click on Help.
SELECTTITLE=Factor Analysis
OPTIONTITLE=Select options for this analysis
DEPMINITEMS=1
DEPMAXITEMS=100
DEPMUSTBENUMBER=Y
DEPCAPTION=Observations

RADIOCAPTION=TYPE OF ROTATION
RADIO1=Varimax,varimax
RADIO2=Promax,promax
RADIO3=No Rotation,none
RADIODEFAULT=1

OPTVALUE1=Indicate number of factors,1,10,2
' Takes the form CHECKVALUE1=Caption, YesValue, NoValue, default (NO or Yes)
CHECKVALUE1=Display Fit Scores, ,# COMMENT OUT, No
TXTLABEL1=Enter a title here
TXTITEM1=---Factor Analysis using WINKS-R---
HTMLLINK=https://www.texasoft.com/Tutorial-Factor-Analysis-WINKS.html
HTMLLABEL=Factor Analysis Help

~CODESTART
cat('\n')
cat('Factor Analysis using data &TABLE\n')
cat('This is an Example R Program in WINKS\n')
cat('\n')
attach(&Table)

# Scree Plot repeated
fit <- princomp(&Table, cor=TRUE)
summary(fit) # print variance accounted for
loadings(fit) # pc loadings
jpeg(file="KSRPLOT1.jpg")
plot(fit,type="lines") # scree plot
cat('\n')
cat('&TXTITEM1\n')
cat('\n')
'CHECKVALUE1 makes the next statement a comment or not
&CHECKVALUE1fit$scores # the principal components
jpeg(file="KSRPLOT2.jpg")
biplot(fit)

# Maximum Likelihood Factor Analysis
# entering raw data and extracting 2 factors,
# with varimax rotation
fit <- factanal(&Table, &optvalue1, rotation="&RADIOSELECTED")
print(fit, digits=2, cutoff=.3, sort=TRUE)
# plot factor 1 by factor 2
load <- fit$loadings[,1:2]
plot(load,type="n") # set up plot
text(load,labels=names(&Table),cex=.7) # add variable names

~CODEEND
~END

Step 2. Select Analyze, R Routines, Run R WINKS Program. Select the Scree Plot R Program and Ok. In the dialog box, select all variables as shown below, and click Ok.


Facor Analsyis WINKS Dialog Box

The resulting Scree plot is shown here along with additional information include the importance of components. In particular, notice the “Proportion of Variance” line in the following table.

   Importance of components:                              Comp.1     Comp.2     Comp.3     Comp.4     Comp.5    Standard deviation     1.8884137 0.70181576 0.61167203 0.59099168 0.46683449    Proportion of Variance 0.7132213 0.09850907 0.07482853 0.06985423 0.04358689    Cumulative Proportion  0.7132213 0.81173034 0.88655888 0.95641311 1.00000000

Factor Analysis Scree Plot

Depending on how you interpret this plot… when does it level out, you might choose 1 or 2 factors. In the example, the default number selected is 2, but you can change that during in the options selection.

Click Return to return to the WINKS main data menu.

Step 3: Perform the Factor Analysis. Using the FACTOR_Example.SDA data file, from the WINKS menus, select Analyze, Run R WINKS Program. Select the Factor Analysis R Program and click Ok.

From the dialog box, select all of the variables.

Click Options to see the available options. This include the selection of the number of factors and whether or not to display scores (makes the output very large). For this example, leave the options as they are and Click Ok, and Ok to display the output:

   
   Call:
   factanal(x = FROMWINKS, factors = 2, rotation = "varimax")

   
   Uniquenesses:
   Z_ENGLISH    Z_MATH  Z_SOCSCI  Z_NATSCI   Z_VOCAB 
        0.39      0.40      0.29      0.32      0.04 
   
   Loadings:
             Factor1 Factor2
   Z_ENGLISH 0.62    0.48   
   Z_MATH    0.70    0.33   
   Z_NATSCI  0.75    0.35   
   Z_SOCSCI  0.60    0.60   
   Z_VOCAB   0.40    0.89   
   
                  Factor1 Factor2
   SS loadings       1.95    1.61
   Proportion Var    0.39    0.32
   Cumulative Var    0.39    0.71

   
   Test of the hypothesis that 2 factors are sufficient.
   The chi square statistic is 5.59 on 1 degree of freedom.
   The p-value is 0.0181 

Factor Analysis Plot

You can edit the file WINKSRPROGS.WR to change the options in the program, alhough we recommend that you keep a copy of the original file in case you need to recover to it.

There are several other example program in the WINKSRPROGS.WR file that you can use to understand how the code works.

This example works on most of the latest version of R. We recommend that you load a recent copy of R onto your computer before doing this example.

- End of Tutorial-

 


| Top of document | Tutorial Index | TexaSoft Homepage | Send comments |
\A9 Copyright TexaSoft, 2011