TexaSoft Home

Star Tutorials Menu



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



Winks Manual

  Order WINKS Now 


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

RADIO3=No Rotation,none

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---
HTMLLABEL=Factor Analysis Help

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

# Scree Plot repeated
fit <- princomp(&Table, cor=TRUE)
summary(fit) # print variance accounted for
loadings(fit) # pc loadings
plot(fit,type="lines") # scree plot
'CHECKVALUE1 makes the next statement a comment or not
&CHECKVALUE1fit$scores # the principal components

# 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


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:

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

        0.39      0.40      0.29      0.32      0.04 
             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