# RPQ <- CSCOT[, c("SRQ1_T1","SRQ2r_T1","SRQ3_T1", "SRQ4_T1", "SRQ5_T1", "SRQ6_T1", "SRQ7_T1", "SRQ8_T1", "SRQ9_T1", "SRQ10_T1", "SRQ11_T1","SRQ12_T1","SRQ13r_T1", "SRQ14_T1", "SRQ15_T1", "SRQ16_T1", "SRQ17_T1", "SRQ18r_T1", "SRQ19_T1")]
# RPQ <- RPQ[complete.cases(RPQ), ]
#
# ind <- sample(c(TRUE, FALSE), nrow(RPQ), replace=TRUE, prob=c(0.3, 0.7))
# data1 <- RPQ[ind, ]
# data2 <- RPQ[!ind, ]
#
# write.csv(data1, file = "data1.csv")
# write.csv(data2, file = "data2.csv")
data1 <- read_csv("data1.csv")
## Parsed with column specification:
## cols(
## SRQ1_T1 = col_double(),
## SRQ2r_T1 = col_double(),
## SRQ3_T1 = col_double(),
## SRQ4_T1 = col_double(),
## SRQ5_T1 = col_double(),
## SRQ6_T1 = col_double(),
## SRQ7_T1 = col_double(),
## SRQ8_T1 = col_double(),
## SRQ9_T1 = col_double(),
## SRQ10_T1 = col_double(),
## SRQ11_T1 = col_double(),
## SRQ12_T1 = col_double(),
## SRQ13r_T1 = col_double(),
## SRQ14_T1 = col_double(),
## SRQ15_T1 = col_double(),
## SRQ16_T1 = col_double(),
## SRQ17_T1 = col_double(),
## SRQ18r_T1 = col_double(),
## SRQ19_T1 = col_double()
## )
data2 <- read_csv("data2.csv")
## Parsed with column specification:
## cols(
## SRQ1_T1 = col_double(),
## SRQ2r_T1 = col_double(),
## SRQ3_T1 = col_double(),
## SRQ4_T1 = col_double(),
## SRQ5_T1 = col_double(),
## SRQ6_T1 = col_double(),
## SRQ7_T1 = col_double(),
## SRQ8_T1 = col_double(),
## SRQ9_T1 = col_double(),
## SRQ10_T1 = col_double(),
## SRQ11_T1 = col_double(),
## SRQ12_T1 = col_double(),
## SRQ13r_T1 = col_double(),
## SRQ14_T1 = col_double(),
## SRQ15_T1 = col_double(),
## SRQ16_T1 = col_double(),
## SRQ17_T1 = col_double(),
## SRQ18r_T1 = col_double(),
## SRQ19_T1 = col_double()
## )
dim(data1)
## [1] 262 19
dim(data2)
## [1] 667 19
0.00 to 0.49 unacceptable. 0.50 to 0.59 miserable. 0.60 to 0.69 mediocre. 0.70 to 0.79 middling. 0.80 to 0.89 meritorious. 0.90 to 1.00 marvelous.
KMO(data1)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = data1)
## Overall MSA = 0.95
## MSA for each item =
## SRQ1_T1 SRQ2r_T1 SRQ3_T1 SRQ4_T1 SRQ5_T1 SRQ6_T1 SRQ7_T1 SRQ8_T1
## 0.95 0.94 0.96 0.95 0.95 0.95 0.96 0.95
## SRQ9_T1 SRQ10_T1 SRQ11_T1 SRQ12_T1 SRQ13r_T1 SRQ14_T1 SRQ15_T1 SRQ16_T1
## 0.97 0.96 0.95 0.96 0.95 0.95 0.95 0.93
## SRQ17_T1 SRQ18r_T1 SRQ19_T1
## 0.96 0.93 0.95
The sampling is adequate for each variable in the model and the for the complete model. Thus, the data is suitable for factor analysis.
Bartlett’s Test compares an observed correlation matrix to the identity matrix. If the correlation matrix is not different from the identity matrix (the variables are orthogonal), the data is suitable for data reduction technique.
cortest.bartlett(data1)
## R was not square, finding R from data
## $chisq
## [1] 2612.426
##
## $p.value
## [1] 0
##
## $df
## [1] 171
Eigenvalues
ev <- eigen(cor(data1)) # get eigenvalues
ev$values
## [1] 9.1741478 1.1222786 0.9605583 0.8118292 0.7115737 0.6961735 0.6793184
## [8] 0.5974156 0.5387722 0.4968266 0.4834333 0.4216593 0.4051783 0.3710480
## [15] 0.3518144 0.3488169 0.2994897 0.2863519 0.2433145
Scree plot
scree(data1, factors = TRUE, pc = FALSE)
Parallel Analyses
fa <- fa.parallel(data1, fm = "wls", fa = "fa", sim = FALSE, SMC = FALSE)
## Parallel analysis suggests that the number of factors = 1 and the number of components = NA
fit <- fa(data1, nfactors = 1,rotate = "oblimin", fm="wls")
print(fit)
## Factor Analysis using method = wls
## Call: fa(r = data1, nfactors = 1, rotate = "oblimin", fm = "wls")
## Standardized loadings (pattern matrix) based upon correlation matrix
## WLS1 h2 u2 com
## SRQ1_T1 0.56 0.31 0.69 1
## SRQ2r_T1 0.61 0.37 0.63 1
## SRQ3_T1 0.73 0.53 0.47 1
## SRQ4_T1 0.77 0.60 0.40 1
## SRQ5_T1 0.67 0.46 0.54 1
## SRQ6_T1 0.71 0.51 0.49 1
## SRQ7_T1 0.70 0.49 0.51 1
## SRQ8_T1 0.68 0.46 0.54 1
## SRQ9_T1 0.69 0.48 0.52 1
## SRQ10_T1 0.73 0.53 0.47 1
## SRQ11_T1 0.74 0.54 0.46 1
## SRQ12_T1 0.74 0.54 0.46 1
## SRQ13r_T1 0.70 0.50 0.50 1
## SRQ14_T1 0.62 0.38 0.62 1
## SRQ15_T1 0.69 0.47 0.53 1
## SRQ16_T1 0.61 0.37 0.63 1
## SRQ17_T1 0.54 0.29 0.71 1
## SRQ18r_T1 0.64 0.41 0.59 1
## SRQ19_T1 0.63 0.40 0.60 1
##
## WLS1
## SS loadings 8.64
## Proportion Var 0.45
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 10.29 with Chi Square of 2612.43
## The degrees of freedom for the model are 152 and the objective function was 1.42
##
## The root mean square of the residuals (RMSR) is 0.05
## The df corrected root mean square of the residuals is 0.05
##
## The harmonic number of observations is 262 with the empirical chi square 235.92 with prob < 1.5e-05
## The total number of observations was 262 with Likelihood Chi Square = 360.56 with prob < 5.5e-19
##
## Tucker Lewis Index of factoring reliability = 0.904
## RMSEA index = 0.072 and the 90 % confidence intervals are 0.063 0.082
## BIC = -485.83
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## WLS1
## Correlation of (regression) scores with factors 0.97
## Multiple R square of scores with factors 0.94
## Minimum correlation of possible factor scores 0.89
#Factor Loadings
print(fit$loadings,cutoff = 0.4)
##
## Loadings:
## WLS1
## SRQ1_T1 0.556
## SRQ2r_T1 0.611
## SRQ3_T1 0.729
## SRQ4_T1 0.774
## SRQ5_T1 0.675
## SRQ6_T1 0.714
## SRQ7_T1 0.700
## SRQ8_T1 0.680
## SRQ9_T1 0.691
## SRQ10_T1 0.727
## SRQ11_T1 0.736
## SRQ12_T1 0.735
## SRQ13r_T1 0.705
## SRQ14_T1 0.616
## SRQ15_T1 0.689
## SRQ16_T1 0.608
## SRQ17_T1 0.543
## SRQ18r_T1 0.637
## SRQ19_T1 0.634
##
## WLS1
## SS loadings 8.643
## Proportion Var 0.455
##EFA with 2 factors
fit2 <- fa(data1, nfactors = 2,rotate = "oblimin",fm="wls")
## Loading required namespace: GPArotation
print(fit2)
## Factor Analysis using method = wls
## Call: fa(r = data1, nfactors = 2, rotate = "oblimin", fm = "wls")
## Standardized loadings (pattern matrix) based upon correlation matrix
## WLS1 WLS2 h2 u2 com
## SRQ1_T1 0.64 -0.07 0.35 0.65 1.0
## SRQ2r_T1 0.48 0.16 0.37 0.63 1.2
## SRQ3_T1 0.58 0.18 0.53 0.47 1.2
## SRQ4_T1 0.75 0.06 0.63 0.37 1.0
## SRQ5_T1 0.81 -0.12 0.52 0.48 1.0
## SRQ6_T1 0.82 -0.08 0.57 0.43 1.0
## SRQ7_T1 0.72 0.00 0.52 0.48 1.0
## SRQ8_T1 0.55 0.16 0.47 0.53 1.2
## SRQ9_T1 0.65 0.06 0.50 0.50 1.0
## SRQ10_T1 0.46 0.31 0.53 0.47 1.7
## SRQ11_T1 0.52 0.25 0.54 0.46 1.4
## SRQ12_T1 0.38 0.41 0.55 0.45 2.0
## SRQ13r_T1 0.27 0.49 0.52 0.48 1.5
## SRQ14_T1 0.06 0.62 0.44 0.56 1.0
## SRQ15_T1 0.25 0.50 0.50 0.50 1.5
## SRQ16_T1 -0.02 0.71 0.47 0.53 1.0
## SRQ17_T1 0.47 0.09 0.30 0.70 1.1
## SRQ18r_T1 0.13 0.57 0.45 0.55 1.1
## SRQ19_T1 -0.07 0.78 0.53 0.47 1.0
##
## WLS1 WLS2
## SS loadings 5.83 3.46
## Proportion Var 0.31 0.18
## Cumulative Var 0.31 0.49
## Proportion Explained 0.63 0.37
## Cumulative Proportion 0.63 1.00
##
## With factor correlations of
## WLS1 WLS2
## WLS1 1.00 0.77
## WLS2 0.77 1.00
##
## Mean item complexity = 1.2
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 10.29 with Chi Square of 2612.43
## The degrees of freedom for the model are 134 and the objective function was 1.07
##
## The root mean square of the residuals (RMSR) is 0.04
## The df corrected root mean square of the residuals is 0.05
##
## The harmonic number of observations is 262 with the empirical chi square 150.05 with prob < 0.16
## The total number of observations was 262 with Likelihood Chi Square = 271.44 with prob < 2.3e-11
##
## Tucker Lewis Index of factoring reliability = 0.928
## RMSEA index = 0.062 and the 90 % confidence intervals are 0.052 0.073
## BIC = -474.72
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## WLS1 WLS2
## Correlation of (regression) scores with factors 0.96 0.94
## Multiple R square of scores with factors 0.92 0.87
## Minimum correlation of possible factor scores 0.85 0.75
print(fit2$loadings,cutoff = 0.4)
##
## Loadings:
## WLS1 WLS2
## SRQ1_T1 0.639
## SRQ2r_T1 0.479
## SRQ3_T1 0.584
## SRQ4_T1 0.748
## SRQ5_T1 0.810
## SRQ6_T1 0.819
## SRQ7_T1 0.719
## SRQ8_T1 0.551
## SRQ9_T1 0.653
## SRQ10_T1 0.462
## SRQ11_T1 0.524
## SRQ12_T1 0.410
## SRQ13r_T1 0.492
## SRQ14_T1 0.617
## SRQ15_T1 0.498
## SRQ16_T1 0.706
## SRQ17_T1 0.473
## SRQ18r_T1 0.568
## SRQ19_T1 0.780
##
## WLS1 WLS2
## SS loadings 5.122 2.749
## Proportion Var 0.270 0.145
## Cumulative Var 0.270 0.414
##Confirmatory Factor Analysis
##One-factor model**
##Model Specification
SRQ_1factor <-
' # latent variable definitions
factor1 =~ SRQ1_T1 + SRQ2r_T1 + SRQ3_T1 + SRQ4_T1 + SRQ5_T1 + SRQ6_T1 + SRQ7_T1 + SRQ8_T1 + SRQ9_T1 + SRQ10_T1 + SRQ11_T1 + SRQ12_T1 + SRQ13r_T1 + SRQ14_T1 + SRQ15_T1 + SRQ16_T1 + SRQ17_T1 + SRQ18r_T1 + SRQ19_T1
'
##Model Fitting
model1 <- cfa(SRQ_1factor, data = data2, std.lv = T, estimator = "DWLS")
summary(model1, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-7 ended normally after 35 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of free parameters 38
##
## Number of observations 667
##
## Model Test User Model:
##
## Test statistic 270.034
## Degrees of freedom 152
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 20167.299
## Degrees of freedom 171
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.994
## Tucker-Lewis Index (TLI) 0.993
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.034
## 90 Percent confidence interval - lower 0.027
## 90 Percent confidence interval - upper 0.041
## P-value RMSEA <= 0.05 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.049
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## factor1 =~
## SRQ1_T1 0.407 0.011 35.958 0.000 0.407 0.509
## SRQ2r_T1 0.493 0.011 43.985 0.000 0.493 0.627
## SRQ3_T1 0.592 0.013 47.310 0.000 0.592 0.703
## SRQ4_T1 0.655 0.013 49.601 0.000 0.655 0.728
## SRQ5_T1 0.587 0.013 45.738 0.000 0.587 0.660
## SRQ6_T1 0.665 0.013 50.205 0.000 0.665 0.725
## SRQ7_T1 0.663 0.014 48.039 0.000 0.663 0.701
## SRQ8_T1 0.570 0.013 44.134 0.000 0.570 0.647
## SRQ9_T1 0.639 0.014 47.143 0.000 0.639 0.674
## SRQ10_T1 0.728 0.014 50.550 0.000 0.728 0.733
## SRQ11_T1 0.684 0.014 49.962 0.000 0.684 0.727
## SRQ12_T1 0.709 0.014 50.591 0.000 0.709 0.740
## SRQ13r_T1 0.501 0.012 42.227 0.000 0.501 0.608
## SRQ14_T1 0.579 0.013 45.465 0.000 0.579 0.677
## SRQ15_T1 0.588 0.013 44.639 0.000 0.588 0.673
## SRQ16_T1 0.447 0.012 37.462 0.000 0.447 0.566
## SRQ17_T1 0.496 0.013 38.148 0.000 0.496 0.548
## SRQ18r_T1 0.483 0.012 41.912 0.000 0.483 0.601
## SRQ19_T1 0.491 0.013 38.852 0.000 0.491 0.569
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SRQ1_T1 0.474 0.030 15.920 0.000 0.474 0.741
## .SRQ2r_T1 0.375 0.035 10.752 0.000 0.375 0.607
## .SRQ3_T1 0.359 0.036 10.068 0.000 0.359 0.506
## .SRQ4_T1 0.380 0.040 9.479 0.000 0.380 0.470
## .SRQ5_T1 0.446 0.038 11.875 0.000 0.446 0.564
## .SRQ6_T1 0.400 0.040 10.054 0.000 0.400 0.475
## .SRQ7_T1 0.455 0.041 11.024 0.000 0.455 0.509
## .SRQ8_T1 0.452 0.038 11.799 0.000 0.452 0.582
## .SRQ9_T1 0.491 0.042 11.677 0.000 0.491 0.545
## .SRQ10_T1 0.456 0.044 10.357 0.000 0.456 0.462
## .SRQ11_T1 0.417 0.042 9.893 0.000 0.417 0.471
## .SRQ12_T1 0.417 0.045 9.255 0.000 0.417 0.453
## .SRQ13r_T1 0.428 0.036 12.023 0.000 0.428 0.630
## .SRQ14_T1 0.396 0.038 10.368 0.000 0.396 0.542
## .SRQ15_T1 0.417 0.042 9.908 0.000 0.417 0.547
## .SRQ16_T1 0.424 0.040 10.591 0.000 0.424 0.680
## .SRQ17_T1 0.576 0.038 14.966 0.000 0.576 0.700
## .SRQ18r_T1 0.412 0.035 11.645 0.000 0.412 0.639
## .SRQ19_T1 0.504 0.039 12.777 0.000 0.504 0.677
## factor1 1.000 1.000 1.000
##Two-factor model
##Model Specification
SRQ_2factors <-
' # latent variable definitions
factor1 =~ SRQ1_T1 + SRQ2r_T1 + SRQ3_T1 + SRQ4_T1 + SRQ5_T1 + SRQ6_T1 + SRQ7_T1 + SRQ8_T1 + SRQ9_T1 + SRQ10_T1 + SRQ11_T1 + SRQ17_T1
factor2 =~ SRQ12_T1 + SRQ13r_T1 + SRQ14_T1 + SRQ15_T1 + SRQ16_T1 + SRQ18r_T1 + SRQ19_T1
'
##Model Fitting
model2 <- cfa(SRQ_2factors, data = data2, std.lv = T, estimator = "DWLS")
summary(model2, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-7 ended normally after 33 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of free parameters 39
##
## Number of observations 667
##
## Model Test User Model:
##
## Test statistic 232.705
## Degrees of freedom 151
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 20167.299
## Degrees of freedom 171
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.996
## Tucker-Lewis Index (TLI) 0.995
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.029
## 90 Percent confidence interval - lower 0.021
## 90 Percent confidence interval - upper 0.036
## P-value RMSEA <= 0.05 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.045
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## factor1 =~
## SRQ1_T1 0.413 0.011 35.972 0.000 0.413 0.516
## SRQ2r_T1 0.497 0.011 43.780 0.000 0.497 0.633
## SRQ3_T1 0.599 0.013 47.181 0.000 0.599 0.711
## SRQ4_T1 0.663 0.013 49.461 0.000 0.663 0.737
## SRQ5_T1 0.594 0.013 45.645 0.000 0.594 0.668
## SRQ6_T1 0.675 0.013 50.081 0.000 0.675 0.735
## SRQ7_T1 0.670 0.014 47.896 0.000 0.670 0.709
## SRQ8_T1 0.576 0.013 44.029 0.000 0.576 0.654
## SRQ9_T1 0.647 0.014 47.018 0.000 0.647 0.682
## SRQ10_T1 0.736 0.015 50.290 0.000 0.736 0.741
## SRQ11_T1 0.690 0.014 49.690 0.000 0.690 0.733
## SRQ17_T1 0.501 0.013 38.003 0.000 0.501 0.552
## factor2 =~
## SRQ12_T1 0.739 0.016 47.618 0.000 0.739 0.771
## SRQ13r_T1 0.522 0.013 40.744 0.000 0.522 0.634
## SRQ14_T1 0.607 0.014 43.569 0.000 0.607 0.709
## SRQ15_T1 0.617 0.014 42.958 0.000 0.617 0.706
## SRQ16_T1 0.468 0.013 36.538 0.000 0.468 0.593
## SRQ18r_T1 0.505 0.012 40.678 0.000 0.505 0.628
## SRQ19_T1 0.514 0.014 37.876 0.000 0.514 0.596
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## factor1 ~~
## factor2 0.907 0.014 63.613 0.000 0.907 0.907
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SRQ1_T1 0.470 0.030 15.736 0.000 0.470 0.734
## .SRQ2r_T1 0.370 0.035 10.602 0.000 0.370 0.599
## .SRQ3_T1 0.351 0.036 9.800 0.000 0.351 0.494
## .SRQ4_T1 0.369 0.040 9.174 0.000 0.369 0.457
## .SRQ5_T1 0.438 0.038 11.594 0.000 0.438 0.553
## .SRQ6_T1 0.388 0.040 9.676 0.000 0.388 0.460
## .SRQ7_T1 0.444 0.041 10.715 0.000 0.444 0.497
## .SRQ8_T1 0.444 0.038 11.570 0.000 0.444 0.573
## .SRQ9_T1 0.481 0.042 11.401 0.000 0.481 0.535
## .SRQ10_T1 0.445 0.044 10.047 0.000 0.445 0.451
## .SRQ11_T1 0.409 0.042 9.659 0.000 0.409 0.462
## .SRQ17_T1 0.571 0.039 14.819 0.000 0.571 0.695
## .SRQ12_T1 0.373 0.046 8.031 0.000 0.373 0.406
## .SRQ13r_T1 0.406 0.036 11.241 0.000 0.406 0.598
## .SRQ14_T1 0.364 0.039 9.302 0.000 0.364 0.497
## .SRQ15_T1 0.383 0.043 8.921 0.000 0.383 0.502
## .SRQ16_T1 0.404 0.040 10.001 0.000 0.404 0.648
## .SRQ18r_T1 0.391 0.036 10.898 0.000 0.391 0.606
## .SRQ19_T1 0.480 0.040 12.017 0.000 0.480 0.645
## factor1 1.000 1.000 1.000
## factor2 1.000 1.000 1.000
anova(model1, model2)
## Chi-Squared Difference Test
##
## Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
## model2 151 232.71
## model1 152 270.03 37.329 1 9.98e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1