This chapter prepares the data set and does univariate and multivariate description of its characteristics prior to the CFA implementation in later chapters. Both numeric and graphical description and inference about distribution shape are quickly available with R functions from the psych and MVN packages.
2.1 The Data Set
The 175 case data set (no missing observations) is loaded from a .csv file. The .csv file was exported from the SPSS system file that is available from the website for the Tabachnick textbook (2019). Or it is available as a txt file: wisc1.csv.txt. It has eleven sub-scales from the WISC:
info (Information)
comp (Comprehension)
arith (Arithmetic)
simil (Similarities)
vocab (Vocabulary)
digit (Digit Span)
pictcomp (Picture Completion)
parang (Picture Arrangement)
block (Block Design)
object(Object Assembly)
coding (Coding - not sure if it is A or B, or a combination)
The user may recognize these scales as commonly discussed sub-tests of the WISC. The first 6 variables comprise the set of manifest variables for the latent factor known as Verbal. The last five are associated with Performance.
The original data file also contains an ID variable that is dropped for the working object created as wisc2 here.
Show/Hide Code
# import the primary data filewisc1 <-read.csv("wisc1.csv")knitr::kable(head(wisc1),booktabs=TRUE,format="markdown")
ID
info
comp
arith
simil
vocab
digit
pictcomp
parang
block
object
coding
3
8
7
13
9
12
9
6
11
12
7
9
4
9
6
8
7
11
12
6
8
7
12
14
5
13
18
11
16
15
6
18
8
11
12
9
6
8
11
6
12
9
7
13
4
7
12
11
7
10
3
8
9
12
9
7
7
11
4
10
8
11
7
15
12
10
12
6
12
10
5
10
Show/Hide Code
# create the working data frame by removing the ID variablewisc2 <- wisc1[,2:12]
A note about tables in this document: Many of the tables generated by the various R functions in this document are reformatted so that they do not appear as the plain text that is typically output into the R console. The kable function in the knitr package permits formatting that is well-rendered with rmarkdown and Quarto document production. kable is used frequently.
2.2 Numeric and Graphical Description of the Data
We can explore univariate characteristics of the data with summaries, plots, and evaluation of normality characteristics
2.2.1 Univariate descriptive statistics from the psych package.
2.2.2 Univariate Distribution Tests and Plots plus Evaluation of Multivariate Normality
The MVN package provides univariate and multivariate normality tests. It is an efficient way to explore characteristics of a set of variables. Several options are available for testing both univariate and Multivariate normality. First, explicit calls for univariate and multivariate tests are made, and then an approach is shown that obtains all at once plus a useful set of plots.
Note that none of the skewness or kurtosis coefficients are strikingly large, but that the large sample size yields substantial power and all Anderson-Darling tests of normality result in null hypothesis rejection. The frequency histograms also indicate that the univariate distributions of the variables are not radically non-normal, but modest positive skewness is present for some variables. The more interesting findings of these descriptive approaches would be the examination of multivariate outliers.
Show/Hide Code
x_vars <- wisc2# use the mvn function for an extensive evaluation# note that different kinds of tests can be specified with changes in the argumentsresult <- MVN::mvn(data= x_vars, mvnTest="mardia", univariateTest="AD")kable(result$univariateNormality, booktabs=TRUE, format="markdown")
This next code chunk gives much information in an RMarkdown/bookdown format (including univariate frequency histograms for all variables), but it is not working properly in Quarto. I show the code, but don’t execute it. Instead, I plot frequency histograms below.
We can plot frequency histograms of all variables in the data frame with ggplot2 and overlay densities.
Show/Hide Code
library(tidyr)library(ggplot2)library(ggthemes)data_long <- wisc2 %>%# Apply pivot_longer function to reshape the dataframe tidyr::pivot_longer(colnames(wisc2)) %>%as.data.frame()# head(data_long)
Or, much more simply, we can use the multi.hist function from the psych package which overlays both a normal distribution curve and a kernel density function on the frequency histograms.
Show/Hide Code
library(psych)psych::multi.hist(wisc2)
Either way, we see that most of the variables are not strikingly non-normal.
2.2.3 Multivariate Outlier tests
The MVN package permits a good array of diagnostic tests/plots for univariate/multivariate shape and outliers.
First, multivariate outliers are examined with Chi-square quantiles vs Mahalanobis distance:
Even with some control over colors and sizes of points/lines, this SPLOM has too many variables to be effective - each plot is very small. It is somewhat readable in the html version of this document, but very difficult in the pdf version. Nonetheless, the sense of fairly linear relationships among all pairs is somewhat apparent, as is the relative univariate normality of each of the eleven.
Note that the image can be enlarged if the reader is using a pdf version of this document simply by using the increase/decrease size capability of pdf readers. If the user is reading an html version of this document, then try to do a right mouse click on the image and “view image” (in Windows). Then the image can be increased in size in a browser.
2.4 Covariances and Zero Order Correlations
The covariance matrix is the basic input for the CFA algorithms outlined in later chapters.
Allaire, J., Xie, Y., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., … Iannone, R. (2018). Rmarkdown: Dynamic documents for r. Retrieved from https://CRAN.R-project.org/package=rmarkdown
Boker, S. M., Neale, M. C., Maes, H. H., Spiegel, M., Brick, T. R., Estabrook, R., … Kirkpatrick, R. M. (2019). OpenMx: Extended structural equation modelling. Retrieved from https://CRAN.R-project.org/package=OpenMx
Epskamp, S., & Simon Stuber, with contributions from. (2017). semPlot: Path diagrams and visual analysis of various SEM packages’ output. Retrieved from https://CRAN.R-project.org/package=semPlot