Confirmatory Factor Analysis Using OpenMx & R

Slides:



Advertisements
Similar presentations
1 Regression as Moment Structure. 2 Regression Equation Y =  X + v Observable Variables Y z = X Moment matrix  YY  YX  =  YX  XX Moment structure.
Advertisements

Structural Equation Modeling. What is SEM Swiss Army Knife of Statistics Can replicate virtually any model from “canned” stats packages (some limitations.
Structural Equation Modeling Using Mplus Chongming Yang Research Support Center FHSS College.
Structural Equation Modeling
Confirmatory Factor Analysis
Linear Regression and Binary Variables The independent variable does not necessarily need to be continuous. If the independent variable is binary (e.g.,
Factor Analysis & Structural Equation Models 2 Sociology 8811, Class 29 Copyright © 2007 by Evan Schofer Do not copy or distribute without permission.
Structural Equation Modeling
(Re)introduction to OpenMx Sarah Medland. Starting at the beginning  Opening R Gui – double click Unix/Terminal – type R  Closing R Gui – click on the.
Factor Analysis Ulf H. Olsson Professor of Statistics.
Econ 140 Lecture 121 Prediction and Fit Lecture 12.
“Ghost Chasing”: Demystifying Latent Variables and SEM
Factor Analysis Ulf H. Olsson Professor of Statistics.
Measurement Models and CFA Ulf H. Olsson Professor of Statistics.
GRA 6020 Multivariate Statistics Confirmatory Factor Analysis Ulf H. Olsson Professor of Statistics.
GRA 6020 Multivariate Statistics Factor Analysis Ulf H. Olsson Professor of Statistics.
Factor Analysis Ulf H. Olsson Professor of Statistics.
Structural Equation Modeling Intro to SEM Psy 524 Ainsworth.
Modern Navigation Thomas Herring
Stages in Structural Equation Modeling
Confirmatory factor analysis
Introduction to CFA. LEARNING OBJECTIVES: Upon completing this chapter, you should be able to do the following: Distinguish between exploratory factor.
Karri Silventoinen University of Helsinki Osaka University.
Structural Equation Modeling 3 Psy 524 Andrew Ainsworth.
GEO7600 Inverse Theory 09 Sep 2008 Inverse Theory: Goals are to (1) Solve for parameters from observational data; (2) Know something about the range of.
Kayla Jordan D. Wayne Mitchell RStats Institute Missouri State University.
Confirmatory Factor Analysis Psych 818 DeShon. Purpose ● Takes factor analysis a few steps further. ● Impose theoretically interesting constraints on.
CJT 765: Structural Equation Modeling Class 7: fitting a model, fit indices, comparingmodels, statistical power.
SEM: Basics Byrne Chapter 1 Tabachnick SEM
Introduction to OpenMx Sarah Medland. What is OpenMx? Free, Open-source, full–featured SEM package Software which runs on Windows, Mac OSX, and Linux.
1 Exploratory & Confirmatory Factor Analysis Alan C. Acock OSU Summer Institute, 2009.
ROB CRIBBIE QUANTITATIVE METHODS PROGRAM – DEPARTMENT OF PSYCHOLOGY COORDINATOR - STATISTICAL CONSULTING SERVICE COURSE MATERIALS AVAILABLE AT:
CJT 765: Structural Equation Modeling Class 8: Confirmatory Factory Analysis.
1 General Structural Equations (LISREL) Week 1 #4.
Confirmatory Factor Analysis Psych 818 DeShon. Construct Validity: MTMM ● Assessed via convergent and divergent evidence ● Convergent – Measures of the.
Measurement Models: Exploratory and Confirmatory Factor Analysis James G. Anderson, Ph.D. Purdue University.
Full Structural Models Kline Chapter 10 Brown Chapter 5 ( )
2nd Order CFA Hierarchical Latent Models
Multigroup Models Byrne Chapter 7 Brown Chapter 7.
BUSI 6480 Lecture 8 Repeated Measures.
Multigroup Models Beaujean Chapter 4 Brown Chapter 7.
G Lecture 7 Confirmatory Factor Analysis
Measurement Models: Identification and Estimation James G. Anderson, Ph.D. Purdue University.
In late 2003, Jost and colleagues received death threats for publishing a paper that said that being politically conservative served a number of ‘existential.
G Lecture 81 Comparing Measurement Models across Groups Reducing Bias with Hybrid Models Setting the Scale of Latent Variables Thinking about Hybrid.
CFA: Basics Beaujean Chapter 3. Other readings Kline 9 – a good reference, but lumps this entire section into one chapter.
SEM: Basics Byrne Chapter 1 Tabachnick SEM
SEM Basics 2 Byrne Chapter 2 Kline pg 7-15, 50-51, ,
CJT 765: Structural Equation Modeling Class 8: Confirmatory Factory Analysis.
SEM Model Fit: Introduction David A. Kenny January 12, 2014.
ALISON BOWLING STRUCTURAL EQUATION MODELLING. WHAT IS SEM? Structural equation modelling is a collection of statistical techniques that allow a set of.
Examples. Path Model 1 Simple mediation model. Much of the influence of Family Background (SES) is indirect.
ALISON BOWLING CONFIRMATORY FACTOR ANALYSIS. REVIEW OF EFA Exploratory Factor Analysis (EFA) Explores the data All measured variables are related to every.
1 Statistics 262: Intermediate Biostatistics Regression Models for longitudinal data: Mixed Models.
Mx modeling of methylation data: twin correlations [means, SD, correlation] ACE / ADE latent factor model regression [sex and age] genetic association.
CFA Model Revision Byrne Chapter 4 Brown Chapter 5.
Chapter 17 STRUCTURAL EQUATION MODELING. Structural Equation Modeling (SEM)  Relatively new statistical technique used to test theoretical or causal.
The SweSAT Vocabulary (word): understanding of words and concepts. Data Sufficiency (ds): numerical reasoning ability. Reading Comprehension (read): Swedish.
Testing the Equality of Means and Variances in Over-Time Data David A. Kenny.
Data Screening. What is it? Data screening is very important to make sure you’ve met all your assumptions, outliers, and error problems. Each type of.
CFA: Basics Byrne Chapter 3 Brown Chapter 3 (40-53)
Full Structural Models Byrne Chapter 6 Kline Chapter 10 (stop 288, but the reporting section at the end is good to mark for later)
Advanced Statistical Methods: Continuous Variables
Chapter 15 Confirmatory Factor Analysis
Dolan & Abdellaoui Boulder Workshop 2016
Measurement invariance in the linear factor model: practical
CJT 765: Structural Equation Modeling
(Re)introduction to Mx Sarah Medland
Confirmatory Factor Analysis
Structural Equation Modeling
Presentation transcript:

Confirmatory Factor Analysis Using OpenMx & R (CFA) Practical Session Timothy C. Bates

Confirmatory Factor Analysis to test theory Are there 5 independent domains of personality? Do domains have facets? Is Locus of control the same as primary control? Is prosociality one thing , or three? Is Grit independent of Conscientiousness?

Prosocial Obligations Prosociality covers several domains, e.g. Workplace: voluntary overtime Civic life: Giving evidence in court Welfare of others: paying for other’s healthcare CFA can test the fit of theories Which hypothesised model fits best? 3 indicators of one factor? 3 correlated factors? 3 independent factors?

Factor structure of Prosociality Distinct domains? Work Civic Welfare Work1 Work 2 Work 3 Civic 1 Civic 2 Civic 3 Welfare 1 Welfare 2 Welfare 3

Factor structure of Prosociality One underlying prosociality factor? Prosociality Work1 Work 2 Work 3 Civic 1 Civic 2 Civic 3 Welfare 1 Welfare 2 Welfare 3

Factor structure of Prosociality Hierarchical structure: Common and distinct factors? Prosociality Work Civic Welfare Work1 Work 2 Work 3 Civic 1 Civic 2 Civic 3 Welfare 1 Welfare 2 Welfare 3

Note: These last two models are equivalent! Work Civic Welfare Work1 Work 2 Work 3 Civic 1 Civic 2 Civic 3 Welfare 1 Welfare 2 Welfare 3

CFA with R & OpenMx library(OpenMx) What is OpenMx? # library(sem) “OpenMx is free and open source software for use with R that allows estimation of a wide variety of advanced multivariate statistical models.” Homepage: http://openmx.psyc.virginia.edu/ # library(sem)

Our data Dataset: Midlife Study of Well-Being in the US (Midus) Prosocial obligations - c. 1000 individuals How much obligation do you feel… to testify in court about an accident you witnessed?’ [civic] to do more than most people would do on your kind of job?’ [work] to pay more for your healthcare so that everyone had access to healthcare? [welfare]

Preparatory code First we need to load OpenMx require(OpenMx) Now lets get the data (R can read data off the web) myData= read.csv("http://www.subjectpool.com/prosocial_data.csv") ? What are the names in the data? summary(myData) # We have some NAs myData= na.omit(myData) # imputation is another solution summary(myData)

Core OpenMx functions mxModel() mxRun() this will contain all the objects in our model mxPath(): each path in our model mxData(): the data for the model mxRun() Generate parameter estimates by sending the model to an optimizer Returns a fitted model

CFA on our competing models Three competing models to test today: One general factor Three uncorrelated factors Three correlated factors

Model 1: One general factor Prosociality Work1 Work 2 Work 3 Civic 1 Civic 2 Civic 3 Welfare 1 Welfare 2 Welfare 3

Quite a bit more code than you have used before: We’ll go through it step-by-step

Model 1 – Step 1 latents = "F1” manifests = names(myData) # Get set up observedCov = cov(myData) numSubjects = nrow(myData) # Create a model using the mxModel function cfa1<- mxModel("Common Factor Model”, type="RAM”,

Model 1 – Step 2 # Here we set the measured and latent variables manifestVars = manifests, latentVars = latents,

Model 1 – Step 3 # Create residual variance for manifest variables using mxPath mxPath( from=manifests, arrows=2, free=T, values=1, labels=paste("error”, 1:9, sep=“”) ), # using mxPath, fix the latent factor variance to 1 mxPath( from="F1", arrows=2, free=F, values=1, labels ="varF1”), # Using mxPath, specify the factor loadings mxPath(from="F1”, to=manifests, arrows=1, free=T, values=1, labels =paste(”l”, 1:9, sep=“”)),

Model 1 – Step 4 # Give mxData the covariance matrix of ‘data2’ for analysis mxData(observed=observedCov , type="cov", numObs=numSubjects ) # make sure your last statement DOESN’T have a comma after it ) # Close model

Model 1 – Run the model # The mxRun function fits the model cfa1<- mxRun(cfa1) # Lets see the summary output summary(cfa1) # What is in a model? slotNames(cfa1@output) names(cfa1@output)

Summary Output # Ideally, chi-square should be non-significant chi-square: 564.41; p: < .001 # Lower is better for AIC and BIC AIC (Mx): 510.41 BIC (Mx): 191.47 # < .06 is good fit: This model is a bad fit RMSEA: 0.15

Story so far… Model 1 (one common factor) is a poor fit to the data)

Model 2 Work Civic Welfare Work1 Work 2 Work 3 Civic 1 Civic 2 Civic 3

Model 2 – Step 1 # Create a model using the mxModel function cfa3<-mxModel("Three Distinct Factors Model Path Specification", type="RAM",

Model 2 – Step 2 # Here we name the measured variables manifestVars=manifests, # Here we name the latent variable latentVars=c("F1","F2", "F3"),

Model 2 – Step 3 # Create residual variance for manifest variables mxPath(from=manifests, arrows=2, free=T,values=1, labels=c("error”, 1:9, sep=“”)),

Model 2 – Step 4 # Specify latent factor variances mxPath(from=c("F1","F2", "F3"), arrows=2,free=F, values=1, labels=c("varF1","varF2", "varF3") ),

Model 2 – Step 5 # Fix the covariance between latent factors to zero (i.e. specify the factors as uncorrelated) mxPath( from="F1", to="F2", arrows=2, free=FALSE, values=0, labels="cov1” ),

Model 2 – Step 6 mxPath(from="F1”,to="F3", arrows=2, free=F, values=0, labels="cov2"), mxPath(from="F2",to="F3", arrows=2, free=F, values=0, labels="cov3"),

Model 2 – Step 7 # Specify the factor loading i.e. here we specify that F1 loads on work1, 2, and 3 mxPath( from="F1", to=c("work1","work2","work3"), arrows=1, free=T, values=1, labels=c("l1","l2","l3") ), from="F2", to=c("civic1","civic2", "civic3"), labels=c("l4","l5", "l6")

Model 2 – Step 8 mxPath( from="F3", to=c("welfare1", "welfare2", "welfare3"), arrows=1, free=T, values=1, labels=c("l7", "l8", "l9") ), # Use the covariance matrix of ‘myData’ for analysis mxData(observed=cov(myData), type="cov", numObs=nrow(myData)) ) # Close the model

Model 2 – Run the model # The mxRun function fits the model threeDistinctFactorFit <- mxRun(threeDistinctfactorModel) # The following line will deliver a lot of output twoFactorFit@output # Lets see the summary output summary(threeDistinctFactorFit)

Summary Output # Ideally, chi-square should be non-significant chi-square: 576.50; p: <.0001 # Lower is better for AIC and BIC AIC (Mx): 522.50 BIC (Mx): 197.51 # <.08 is a reasonable fit: This model is a poor fit RMSEA: 0.16

Now your turn… Install OpenMx repos <- c('http://openmx.psyc.virginia.edu/testing/') If you have your laptop: install.packages('OpenMx', repos=repos) lib <- 'C:/workspace’ install.packages('OpenMx', repos=repos, lib=lib) library(OpenMx, lib=lib)