54
Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifi[email protected] & wnarifin.github.io 1

Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis [email protected] & wnarifin.github.io

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Questionnaire Analysis Using RDetermining the Validity of Internal Structure Using Factor Analysis

[email protected] & wnarifin.github.io

1

Page 2: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

About Me1. A medical doctor (long… time ago).2. A lecturer at Biostatistics & Research Methodology

Unit, School of Medical Sciences, USM.3. A PhD candidate at School of Computer Sciences,

USM.4. Questionnaire validation research.5. I “eat” R and Python everyday.

2

Page 3: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Outlines1. Overview of Validity2. Exploratory Factor Analysis3. Confirmatory Factor Analysis

3

Page 4: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Download workshop materials @wnarifin.github.io/workshop.html

2019/10/05 Questionnaire analysis using R @ confeRence 2019 (Sunway University)

4

Page 5: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Overview of Validity

5

Page 6: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Measurement validity & reliability● Measurement → Process of observing & recording.● Measurement validity → Accuracy.● Measurement reliability → Precision, consistency,

repeatability.

6

Page 7: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Classical validity3Cs:1. Content2. Criterion3. Construct

7

Page 8: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

The validity● Unitary concept.● Degree of evidence → Purpose & Intended use of a

tool.● Evidence from 5 sources:

1. Content.2. Internal structure.3. Relations to other variables4. Response process.5. Consequences.

8

Page 9: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

The validity● Construct – Concept to be measured by a tool.● Internal structure evidence of validity.● How relationship between items and factors reflect

construct.● Analysis:

1. Factor analysis.2. Reliability.

9

Page 10: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Factoring● Group things that have common concept.● Simplify.● Factoring = Grouping.● Factor = Construct = Domain = Concept.

10

Page 11: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

FactoringIntuitive factoring:

Orange, motorcycle, bus,durian, banana, car

Anything in common?

11

Page 12: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

FactoringGroup them

[ Orange, durian, banana ][ Motorcycle, bus, car ]

into two groups

12

Page 13: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

FactoringName the group

factor out the common concept13

Fruits Motor vehicle

Orange Motorcycle

Durian Bus

Banana Car

Page 14: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Factoring● Find out correlated variables from correlation

matrix.● Manageable for small number of variables.● Impossible for large number of variables.

14

Page 15: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Factor analysis● In fields like psychology, we cannot observe

directly (latent) psychological states, thus measured indirectly in of form items.

15

Page 16: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Factor analysis● e.g. Depression:

○ depression causes symptoms of depression.○ depression (latent) is measured indirectly by its

symptoms (items).○ prove the symptoms are correlated to each

other, representing the concept of depression → factor analysis.

16

Page 17: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Factor analysis● Multivariate analysis > 1 outcomes.● Numerical items, e.g. Likert scale, VAS scores,

laboratory results etc.● Group correlated items (in a measurement scale).● Factor out latent (unobserved) factors cause the

correlation between the items.● Latent variable model analysis.

17

Page 18: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Factor analysisCommon factor model:

Common Factors + Measurement Error

Classification:● Exploratory factor analysis (EFA).● Confirmatory factor analysis (CFA).

18

Page 19: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Internal consistency reliability● Consistent responses in a construct.● Homogenous → ↑Reliability.● Heterogenous → ↓Reliability.● Advantage: Measure 1x only.

19

Page 20: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Internal consistency reliability● EFA: Cronbach's alpha coefficient.● CFA: Raykov’s rho coefficient.● Range: Not reliable 0 → 1 Perfectly reliable.● Aim > 0.7.

20

Page 21: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Exploratory Factor Analysis (EFA)

21

Page 22: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFA● explorative method.● e.g. at early of questionnaire development.● theory generating.

22

Page 23: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFAResearch questions:● How many factors are there?● Strength of relationship between items and the

factors?● Factor correlations?● % variance explained by the extracted factors?

23

Page 24: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFAApplications:● Psychological scales/questionnaires, e.g.

personality, depression, stress etc.● Explore the number of common factors in

personality items.

24

Page 25: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFAExtraction methods:● classical: Principal axis factoring.● other methods: Maximum likelihood, image

analysis, alpha analysis.

Factor loading:● item-factor relationship.● values > 0.3.

25

Page 26: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFATo simplify EFA results, need factor rotation to obtain clear factors and factor loadings.

Types of rotation:● Orthogonal – uncorrelated factors.

○ Varimax, Quartimax, Equamax.● Oblique – correlated factors.

○ Oblimin, Promax.

26

Page 27: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFA - preliminariesSuitability of data for the analysis:● there must be correlations between the variables.

Judged by:● Kaiser-Meyer-Olkin (KMO) measures of sampling

adequacy (MSA). KMO > 0.7 required.● Bartlet’s test of sphericity. P-value < 0.05 indicates

presence of correlations.

27

Page 28: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFA - preliminariesNumber of factors to extract:● Factors with Eigenvalues > 1 (Kaiser’s rule).● Cattell’s scree test.● Parallel analysis.

28

Page 29: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

EFA - Practical [20 minutes]efa.R

1. Data exploration.2. EFA.3. Reliability Cronbach’s alpha.

29

Page 30: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

# librarieslibrary(foreign) # for importing SPSS datalibrary(psych) # for psychometrics

# descriptivedescribe(data)response.frequencies(data)mardia(data)

# preliminariesKMO(data)cortest.bartlett(data)scree = scree(data); print(scree)parallel = fa.parallel(data, fa = both); print(parallel)

30

Page 31: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

# run efafa = fa(data, nfactors = k, fm = "pa", rotate = "oblimin"); print(fa)

# reliabilityalpha = alpha(data[FACTOR]); print(alpha)

31

Page 32: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Confirmatory Factor Analysis (CFA)

32

Page 33: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFAStructural equation modeling (SEM):● measurement model – CFA.● structural model – path analysis.

33

Page 34: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFA● Confirmatory method – e.g. at final stage of

questionnaire development.● Theory confirmation.● Based on common factor model – similar to EFA.● Accounts for measurement errors.● Analysis done on variance-covariance matrix.● Allows assessment of model fit.

34

Page 35: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFA vs EFACFA items:● I love fast food● I hate vegetable● I hate eating fruits● I hate exercise→ Obesity

35

Page 36: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFA vs EFAEFA items:● I love cat● I love statistics● I love snorkelling● I love driving car● I love computer game● I like to have everything normally distributed● I love nasi ayam● I eat a lot of pisang goreng● I spend most of my time in front of computer

→ What factors???36

Page 37: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFA vs EFA

37

EFA CFA

Exploratory. Confirmatory.

Not necessary to specify factors. Pre-specified factors.

Theory generating. Theory confirmation.

Items not fixed to factors. Items fixed to factors.

Model fit not tested. Model fit assessment.

Page 38: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFA path diagram

38

Page 39: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFAResearch question:● Does our theoretical measurement model (factor +

item + correlation) fit the data?● Strength of relationship between items and the

factors?● Factor correlations?→ confirm the theory.

39

Page 40: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFAApplications:● confirm the measurement model of newly

developed questionnaires in target populations.● confirm the measurement model of existing

questionnaires in new populations.● confirm the measurement model translated

questionnaires in new populations.→ confirmatory role of the analysis.

40

Page 41: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFAEstimations methods:● numerical scale + multivariate normal data →

maximum likelihood.● numerical scale + non-multivariate normal data →

robust maximum likelihood.● categorical scale → weighted least squares.

Many more . . . http://lavaan.ugent.be/tutorial/est.html

41

Page 42: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFAResults to focus on:1. Overall model fit – by fit indices.2. Parameter estimates

a. Factor loadings.b. Factor correlations.

3. Localized areas of misfit - Modification indices.

42

Page 43: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

1. Fit indices

43

Category Fit index Cut-off

Absolute fit Chi-square P>0.05

Standardized root mean square (SRMR)

≤ 0.08

Parsimony correction Root mean square error of approximation (RMSEA)

RMSEA (90% CI) ≤ 0.08,CFit P>0.05

Comparative fit Comparative fit index (CFI) ≥ 0.95

Tucker-Lewis index (TLI) ≥ 0.95

Page 44: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

2.a Factor loadings (FLs)● The guideline for EFA is applicable also to CFA (FL >

0.3).● In addition, the P-values of the FLs must be

significant (at α = 0.05).● Also look for out-of-range values – FLs should be in

range of 0 to 1 (absolute values).

44

Page 45: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

2.b Factor correlations● Similar to EFA, a factor correlation must be < 0.85,

which indicates that the factors are distinct.● A correlation > 0.85 indicates multicollinearity

problem.● Also look for out-of-range values – factor

correlations should be in range of 0 to 1 (absolute values).

45

Page 46: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Modification indices (MIs)● MI indicates the expected parameter change if we

include a particular specification in the model.● e.g. by correlating between errors of Q1 and Q2.● MIs > 3.84 should be investigated.

46

Page 47: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Model revisionTo improve model fit.

Causes of poor fit:● Item – low FL, wrong factor.● Factor – multicollinearity.● Correlated error – items with similar

wording/meaning.● Model not supported by data.

47

Page 48: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Model-to-model comparisonTo choose the best model.

Compare models:● AIC (Akaike Information Criterion) and BIC

(Bayesian Information Criterion).● Better model = Smaller AIC/BIC.

48

Page 49: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

CFA - Practical [20 minutes]cfa.R

1. Data exploration.2. CFA.3. Path diagram.4. Reliability - Raykov’s rho.

49

Page 50: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

# libraries

library(foreign) # for importing SPSS data

library(psych) # for psychometrics

library(lavaan) # for CFA

library(semTools) # for additional functions in SEM

library(semPlot) # for path diagram

50

Page 51: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

# lavaan model specification

model = "

FACTOR1 =~ Q1 + Q2 + Q3

FACTOR2 =~ Q4 + Q5 + Q6

Q1 ~~ Q2

"

# fit cfa model

cfa.model = cfa(model, data, estimator = "MLR")

summary(cfa.model, fit.measures = T, standardized = T)

# modification indices

mi = modificationIndices(cfa.model); subset(mi, mi > 3.84)

# model comparison

anova(cfa.model, cfa.model1)

51

Page 52: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

# path diagram

semPaths(cfa.model, 'path', 'std', style = 'lisrel',

edge.color = 'black', intercepts = F)

# reliability

reliability(cfa.model)

52

Page 53: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Thank You

53

Page 54: Questionnaire Analysis Using R - GitHub Pages€¦ · Questionnaire Analysis Using R Determining the Validity of Internal Structure Using Factor Analysis wnarifin@usm.my & wnarifin.github.io

Q&A Session

54