## Example using the built in iris dataset
s <- SEMSummary(~ Sepal.Length + Sepal.Width + Petal.Length, data = iris)
s # show output ... not very nice
## Prettier output from SEMSummary
APAStyler(s)
#### Subset the dataset and use the . expansion ####
## summary for all variables in mtcars data set
## with 11 variables, this could be a pain to write out
SEMSummary(~ ., data = mtcars)
## . expansion is also useful when we know column positions
## but not necessarily names
SEMSummary(~ ., data = mtcars[, c(1, 2, 3, 9, 10, 11)])
## clean up
rm(s)
## sample data
Xmiss <- as.matrix(iris[, -5])
# make q0% missing completely at random
set.seed(10)
Xmiss[sample(length(Xmiss), length(Xmiss) * .10)] <- NA
Xmiss <- as.data.frame(Xmiss)
SEMSummary(~ ., data = Xmiss, use = "fiml")
## pairwise
APAStyler(SEMSummary(~ ., data = Xmiss, use = "pair"),
type = "cor")
## same as cor()
cor(Xmiss, use = "pairwise.complete.obs")
## complete cases only
SEMSummary(~ ., data = Xmiss, use = "comp")
## clean up
rm(Xmiss)
Run the code above in your browser using DataLab