library(learnr) library(learnSEM) knitr::opts_chunk$set(echo = FALSE) data(efa)
This section should help you begin to think about how structural equation models are described. In the lecture, we will discuss manifest and latent variables and how EFA can be used to explore the relationship of measured items to their underlying constructs. In this assignment, you will get the following practice:
You can use vignette("lecture_efa", "learnSEM")
to view these notes in R.
What is in the dataset? The Openness to Experience dataset includes the following:
Instructions: Below are some phrases describing people's behaviors. Please use the rating scale below to describe how accurately each statement describes you. Describe yourself as you generally are now, not as you wish to be in the future. Describe yourself as you honestly see yourself in relation to other people of your gender and of roughly your same age. Please read each statement carefully, and then check the box that corresponds to your response.
Scale: very inaccurate, moderately inaccurate, neither inaccurate nor accurate, moderately accurate, very accurate
Items:
In this next section, you will answer questions using the R code blocks provided. Be sure to use the solution
option to see the answer if you need it!
Please enter your name for submission. If you do not need to submit, just type anything you'd like in this box.
question_text( "Student Name:", answer("Your Name", correct = TRUE), incorrect = "Thanks!", try_again_button = "Modify your answer", allow_retry = TRUE )
Let's start by taking a look at the dataset. Use the head()
function to see the first few rows of data.
library(learnSEM) data(efa)
library(learnSEM) data(efa) head(efa)
First, exclude any participants that have missing data, and call the dataset nomissing
. Then, you can also drop the group variable to help make the EFA section easier.
nomissing <- na.omit(efa) nomissing <- nomissing[ , -ncol(nomissing)] #or you can do it all at once nomissing <- na.omit(efa[ , -ncol(efa)])
Include a parallel analysis and scree plot on the nomissing
dataset. Be sure to save the parallel analysis as EFA_parallel
to be able to complete the next question. You should use maximum likelihood
for the math and fa
for the output.
nomissing <- na.omit(efa[ , -ncol(efa)])
library(psych) library(GPArotation)
library(psych) library(GPArotation) EFA_parallel <- fa.parallel(nomissing, fm = "ml", fa = "fa")
Include a summary of the eigenvalues for the Kaiser criterion. You should determine how many of the fa.values
are over the cut off score of 1
and of .7
.
nomissing <- na.omit(efa[ , -ncol(efa)]) library(psych) library(GPArotation) EFA_parallel <- suppressMessages(fa.parallel(nomissing, fm = "ml", fa = "fa", plot = F))
sum(EFA_parallel$fa.values > 1) sum(EFA_parallel$fa.values > .7)
question_text( "How many factors should you use given the results of the parallel analysis, scree plot, and eigenvalues?", answer("Between 2 and 3", correct = TRUE), incorrect = "You should describe the different answers given by the diagnostics, and potentially, they suggest between 2 and 5 factors.", try_again_button = "Modify your answer", allow_retry = TRUE )
oblimin
rotation and maximum likelihood
as your math, run the EFA analysis with two factors. Save this analysis as EFA_fit
.EFA_fit
(just edit your model by excluding columns).nomissing <- na.omit(efa[ , -ncol(efa)]) library(psych) library(GPArotation) EFA_parallel <- suppressMessages(fa.parallel(nomissing, fm = "ml", fa = "fa", plot = F))
#run the analysis EFA_fit <- ______ #examine the output EFA_fit
#run the analysis EFA_fit <- fa(nomissing[ , -c(3,11,15,16)], nfactors = 2, rotate = "oblimin", "fm" = "ml") #examine the output EFA_fit
Show the RMSR, RMSEA, TLI, and CFI fit indices by printing them directly from the EFA_fit
model. Remember, you will need the formula for CFI: 1 - ((model chi square / df) / (null chi square / df))
.
nomissing <- na.omit(efa[ , -ncol(efa)]) library(psych) library(GPArotation) EFA_parallel <- suppressMessages(fa.parallel(nomissing, fm = "ml", fa = "fa", plot = F)) EFA_fit <- fa(nomissing[ , -c(3,11,15,16)], nfactors = 2, rotate = "oblimin", "fm" = "ml")
EFA_fit$rms EFA_fit$RMSEA EFA_fit$TLI 1 - ((EFA_fit$STATISTIC-EFA_fit$dof)/ (EFA_fit$null.chisq-EFA_fit$null.dof))
question_text( "Interpret these fit indices. What do they tell you about your model?", answer("The model shows mixed fit indices.", correct = TRUE), incorrect = "You should note that the model a mix of ok and poor fit indices.", try_again_button = "Modify your answer", allow_retry = TRUE )
Calculate Cronbach's alpha for each factor, and remember to use the nomissing
dataset. Because we did not reverse score any items, use the check.keys = TRUE
argument as part of alpha
.
nomissing <- na.omit(efa[ , -ncol(efa)]) library(psych) library(GPArotation) EFA_parallel <- suppressMessages(fa.parallel(nomissing, fm = "ml", fa = "fa", plot = F)) EFA_fit <- fa(nomissing[ , -c(3,11,15,16)], nfactors = 2, rotate = "oblimin", "fm" = "ml")
factor1 <- c(4:10,13,17,19,20) factor2 <- c(1,2,12,14,18) alpha(nomissing[ , factor1], check.keys = T) alpha(nomissing[ , factor2], check.keys = T)
Create a plot of the factors using either fa.plot
or fa.diagram
.
nomissing <- na.omit(efa[ , -ncol(efa)]) library(psych) library(GPArotation) EFA_parallel <- suppressMessages(fa.parallel(nomissing, fm = "ml", fa = "fa", plot = F)) EFA_fit <- fa(nomissing[ , -c(3,11,15,16)], nfactors = 2, rotate = "oblimin", "fm" = "ml")
fa.plot(EFA_fit) fa.diagram(EFA_fit)
question_text( "What do you think the factors are measuring? Try describing your factors.", answer("Art and ideas.", correct = TRUE), incorrect = "One factor appears to be about the arts, while the other factor appears to be about new ideas and thinking.", try_again_button = "Modify your answer", allow_retry = TRUE )
On this page, you will create the submission for your instructor (if necessary). Please copy this report and submit using a Word document or paste into the text window of your submission page. Click "Generate Submission" to get your work!
encoder_logic()
encoder_ui()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.