class: center, middle, inverse, title-slide # MULTIVARIJATNE STATISTIČKE METODE ## Predavanje 5: Faktorska analiza ### Luka Šikić, PhD ### Fakultet hrvatskih studija |
Github MV
--- <style type="text/css"> @media print { .has-continuation { display: block !important; } } remark-slide-content { font-size: 22px; padding: 20px 80px 20px 80px; } .remark-code, .remark-inline-code { background: #f0f0f0; } .remark-code { font-size: 16px; } .mid. remark-code { /*Change made here*/ font-size: 60% !important; } .tiny .remark-code { /*Change made here*/ font-size: 40% !important; } </style> # Pregled predavanja <br> <br> <br> 1. [Jednodimenzionalna faktorska analiza (FA)](#uni) 2. [Eksplorativna FA (EFA)](#multi) 3. [Konfirmatorna FA (CFA)](#conf) --- class: inverse, center, middle name: uni # FAKTORSKA ANALIZA <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> (Općenito) --- # Karakteristike FA <br> <br> <br> - Charles Spearman (1904) zaslužan za uvođenje FA <br> - FA ima mnogo sličnosti sa PCA <br> - Cilj FA je reducirati veliki broj (koreliranih) varijabli na mali broj indeksa (faktora) <br> - FA je statistički model (za razliku od PCA koja je statistička metoda) <br> - Ekstenzija (C)FA je modeliranje strukturnih jednadžbi (SEM) <br> <br> .footnote[[*]Izvstan uvodni [turorial](https://stats.idre.ucla.edu/spss/seminars/introduction-to-factor-analysis/a-practical-introduction-to-factor-analysis/).] --- # Vrste FA <br> <br> .pull-left[ ##### EKSPLORATIVNA - koristi se u fazi razvoja modela - pregled faktorske strukture - opća slika o varijablama ] .pull-right[ ##### KONFIRMATORNA - procijeni kostnrukt - koristi se nakon razvoja mjere ] .footnote[[*]Ogledni primjer za motivaciju FA na [poveznici](https://pdf.sciencedirectassets.com/280203/1-s2.0-S1877050915X00123/1-s2.0-S1877050915013605/main.pdf?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGgaCXVzLWVhc3QtMSJGMEQCIEKL%2BgWTeDULrBDdHjLVVYTpTw0x1b3IcmAwY2fj49agAiB%2F6alKu3d8Cd6HSjQBNDTNSPxADKPdUigLTWG0YLbrpSq9Awih%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAMaDDA1OTAwMzU0Njg2NSIMR5PnGB3hxYeBGMh5KpEDhNllxnviP6RXrFwFD6GCbdR4qA8%2BcDAcuyonvbAcLcYcjusNF1bVoxijJsUrTO7IHkq1%2F6gfTMW%2Fuis0iw0h5BZsVMg8d2xIt4XVDq2uCE1378Si6BN1zAc7%2BTpI1OX7MlwN0RFYXYcItSs0uGptpELpdqCSC5MbpvOHq2dSk32Rr96UfUtgWP5%2BK00neqh8raUZTOICa9qgQ1e2xraj1yH5PwwZjprfpODiFNnxbUX3FyzYw446DDa0o0hp5Nq0ftEFsQXXLt8PREU4DbGF6URs7yhNp3EUW8FsbNaFBW83FUkq5g8EB22KbnfoaMjL%2FGdX75QKy2Wi2IAKOJ0Gbg1dR8hEMfVvG25lzN3YWBHTZP1CDH43ucW01bUD47CoguLZJ3OlB1YX%2F8VirEyyMqS%2FZDTGRX6PVJw3tt5otbaMDOSxofNnEjIbLMz7POE4XcOPUiTzMorx7xZUqn3n8s6D7jtS%2F9rRExcwJ%2B8KGkG8npqhI70AGEthDjpR6Ja4%2FwnPp2LT07McMcYzGcfORrQwyJHhggY67AGoh98fTEoT0vbi3g%2FgJjuNSkhome8unAE873Wvjb0czEg8VUzqUmq2lgHQFbsrRqyly1HXxTi1garhIhwOXMs7OH%2F13G4dbweUnzHfvHGhkmCGPNEPCO%2BuiAzsv25woyDCYEabk1PIWUbmF5Zy2blhh4tvZ2STlB1w6tM6GVYbXVAHPO3m4CrLYfSDdw86vPFkzWAs2lav7u911%2FCJBWFX%2B18kZ0yN7ChfqR2t2M46ZtQWAbG3NLWlrnWMcpq4hwkth0VI84FgisBGO8jRU5L3wdJcNYFUj7K8DczHTrE6XzDJhIBVldLhUpXjAA%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210322T080825Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=ASIAQ3PHCVTYWHRILQQO%2F20210322%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=6d94252743a7ed60e313fbcccbf494512775492c51e14248e59850866d82cdde&hash=ff6722f6278a608c06c40e587140d6976c1cd76177433d4700cc253bb613a370&host=68042c943591013ac2b2430a89b270f6af2c76d8dfd086a07176afe7c76c2c61&pii=S1877050915013605&tid=spdf-2c946717-28f9-49fa-b844-b8b4f083fea2&sid=b1057b8a1956c546f55a7420b46302cb07cbgxrqb&type=client).] --- # Eksplorativna vs. konfirmatorna FA <img src="../Foto/konf_FA.png" width="350px" style="display: block; margin: auto;" /> <img src="../Foto/eksp_FA.png" width="350px" style="display: block; margin: auto;" /> --- class: inverse, center, middle # OGLEDNI PRIMJER <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> (Pretpostavke za analizu) --- # Paket i podatci <br> - koristimo `psych` paket - za detalje o paketu pogledajte [Personality project](http://personality-project.org/r/psych/) ```r # učitaj paket library(psych) ``` - koristimo `gcbs` podatkovni skup (Generic Conspiracist Beliefs Survey) - provjerite da li i vas prisluškuju na [Open psychometrics](https://openpsychometrics.org/tests/GCBS/) :-) ```r gcbs <- readRDS("../Podatci/GCBS_data.rds") ``` --- # Pregledaj podatke ```r str(gcbs) ``` ``` ## 'data.frame': 2495 obs. of 15 variables: ## $ Q1 : int 5 5 2 5 5 1 4 5 1 1 ... ## $ Q2 : int 5 5 4 4 4 1 3 4 1 2 ... ## $ Q3 : int 3 5 1 1 1 1 3 3 1 1 ... ## $ Q4 : int 5 5 2 2 4 1 3 3 1 1 ... ## $ Q5 : int 5 5 2 4 4 1 4 4 1 1 ... ## $ Q6 : int 5 3 2 5 5 1 3 5 1 5 ... ## $ Q7 : int 5 5 4 4 4 1 3 5 1 1 ... ## $ Q8 : int 3 5 2 1 3 1 4 5 1 1 ... ## $ Q9 : int 4 1 2 4 1 1 2 5 1 1 ... ## $ Q10: int 5 4 4 5 5 1 3 5 1 4 ... ## $ Q11: int 5 4 2 5 5 1 3 5 1 1 ... ## $ Q12: int 5 5 4 5 5 1 2 5 1 1 ... ## $ Q13: int 3 4 0 1 3 1 2 3 1 1 ... ## $ Q14: int 5 4 2 4 5 1 3 4 1 1 ... ## $ Q15: int 5 5 4 5 5 1 4 5 1 5 ... ``` --- # Konstrukti <br> <br> - Zavjera vlade (GM) <br> - Prikrivanje vanzemaljaca (ET) <br> - Zle i zavjereničke globalne organizacije (MG) <br> - Osobna dobrobit (PW) <br> - Kontrola informacija (CI) Za detalje o varijablama pogledajte [Measuring belief in conspiracy theories](https://www.frontiersin.org/articles/10.3389/fpsyg.2013.00279/full). --- # Varijable i konstrukti <img src="../Foto/konstrukti_FA.png" width="400px" style="display: block; margin: auto;" /> --- # Jednodimenzionalni konstrukt <img src="../Foto/unidim_FA.png" width="400px" style="display: block; margin: auto;" /> --- # Jednodimenzionalni konstrukt .tiny[ .pull-left[ ```r EFA_model <- fa(gcbs) # Default je 1 faktor EFA_model$loadings ``` ``` ## ## Loadings: ## MR1 ## Q1 0.703 ## Q2 0.719 ## Q3 0.638 ## Q4 0.770 ## Q5 0.672 ## Q6 0.746 ## Q7 0.734 ## Q8 0.654 ## Q9 0.695 ## Q10 0.565 ## Q11 0.719 ## Q12 0.786 ## Q13 0.679 ## Q14 0.743 ## Q15 0.574 ## ## MR1 ## SS loadings 7.267 ## Proportion Var 0.484 ``` ] ] .pull-right[ ```r fa.diagram(EFA_model) ``` <img src="05_FA_files/figure-html/unnamed-chunk-10-1.png" style="display: block; margin: auto;" /> ] --- class: inverse, center, middle name: multi # EKSPLORATIVNA (E)FA <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> (Bez teorije...) --- # Procedura provedbe EFA <br> <br> - Provjeri faktorabilnost <br> <br> - Izvuci faktore <br> <br> - Izaberi odgovarajući broj faktora <br> <br> - Rotiraj faktore <br> <br> - Interpretiraj rezultate --- # Podatci - koristimo podatke [Synthetic Aperture Personality Assessment](https://www.sapa-project.org/survey/start.php) (SAPA) - 2.800 osoba - 25 pitanja .tiny[ ```r data(bfi) str(bfi) ``` ``` ## 'data.frame': 2800 obs. of 28 variables: ## $ A1 : int 2 2 5 4 2 6 2 4 4 2 ... ## $ A2 : int 4 4 4 4 3 6 5 3 3 5 ... ## $ A3 : int 3 5 5 6 3 5 5 1 6 6 ... ## $ A4 : int 4 2 4 5 4 6 3 5 3 6 ... ## $ A5 : int 4 5 4 5 5 5 5 1 3 5 ... ## $ C1 : int 2 5 4 4 4 6 5 3 6 6 ... ## $ C2 : int 3 4 5 4 4 6 4 2 6 5 ... ## $ C3 : int 3 4 4 3 5 6 4 4 3 6 ... ## $ C4 : int 4 3 2 5 3 1 2 2 4 2 ... ## $ C5 : int 4 4 5 5 2 3 3 4 5 1 ... ## $ E1 : int 3 1 2 5 2 2 4 3 5 2 ... ## $ E2 : int 3 1 4 3 2 1 3 6 3 2 ... ## $ E3 : int 3 6 4 4 5 6 4 4 NA 4 ... ## $ E4 : int 4 4 4 4 4 5 5 2 4 5 ... ## $ E5 : int 4 3 5 4 5 6 5 1 3 5 ... ## $ N1 : int 3 3 4 2 2 3 1 6 5 5 ... ## $ N2 : int 4 3 5 5 3 5 2 3 5 5 ... ## $ N3 : int 2 3 4 2 4 2 2 2 2 5 ... ## $ N4 : int 2 5 2 4 4 2 1 6 3 2 ... ## $ N5 : int 3 5 3 1 3 3 1 4 3 4 ... ## $ O1 : int 3 4 4 3 3 4 5 3 6 5 ... ## $ O2 : int 6 2 2 3 3 3 2 2 6 1 ... ## $ O3 : int 3 4 5 4 4 5 5 4 6 5 ... ## $ O4 : int 4 3 5 3 3 6 6 5 6 5 ... ## $ O5 : int 3 3 2 5 3 1 1 3 1 2 ... ## $ gender : int 1 2 2 2 1 2 1 1 1 2 ... ## $ education: int NA NA NA NA NA 3 NA 2 1 NA ... ## $ age : int 16 18 17 17 17 21 18 19 19 17 ... ``` ] --- # Podatci ```r head(bfi) ``` ``` ## A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 N2 N3 N4 N5 O1 O2 O3 O4 ## 61617 2 4 3 4 4 2 3 3 4 4 3 3 3 4 4 3 4 2 2 3 3 6 3 4 ## 61618 2 4 5 2 5 5 4 4 3 4 1 1 6 4 3 3 3 3 5 5 4 2 4 3 ## 61620 5 4 5 4 4 4 5 4 2 5 2 4 4 4 5 4 5 4 2 3 4 2 5 5 ## 61621 4 4 6 5 5 4 4 3 5 5 5 3 4 4 4 2 5 2 4 1 3 3 4 3 ## 61622 2 3 3 4 5 4 4 5 3 2 2 2 5 4 5 2 3 4 4 3 3 3 4 3 ## 61623 6 6 5 6 5 6 6 6 1 3 2 1 6 5 6 3 5 2 2 3 4 3 5 6 ## O5 gender education age ## 61617 3 1 NA 16 ## 61618 3 2 NA 18 ## 61620 2 2 NA 17 ## 61621 5 2 NA 17 ## 61622 3 1 NA 17 ## 61623 1 2 3 21 ``` --- # Podatci <br> <br> ```r names(bfi) ``` ``` ## [1] "A1" "A2" "A3" "A4" "A5" "C1" ## [7] "C2" "C3" "C4" "C5" "E1" "E2" ## [13] "E3" "E4" "E5" "N1" "N2" "N3" ## [19] "N4" "N5" "O1" "O2" "O3" "O4" ## [25] "O5" "gender" "education" "age" ``` --- # Konstrukt <img src="../Foto/bfi_FA.png" width="350px" style="display: block; margin: auto;" /> --- # Konstrukt - konstrukt se ne može direktno mjeriti - primjeri: samoodređenost, sposobnost razmišljanja, politička pripadnost, ekstrovertiranost <br> <br> <img src="../Foto/konstrukt_FA.png" width="450px" style="display: block; margin: auto;" /> --- # ...bez teorije <img src="../Foto/noTheory_FA.png" width="550px" style="display: block; margin: auto;" /> --- # Faktorabilnost <br> <br> .pull-left[ - `Barlett sphericity` test (BS) ```r bfi_hetcor <- polycor::hetcor(bfi[,1:25]) # korelacije bfi_c <- bfi_hetcor$correlations # kor- matrica bfi_faktorablinost <- cortest.bartlett(bfi_c) # Barlett test bfi_faktorablinost ``` ``` ## $chisq ## [1] 671.9842 ## ## $p.value ## [1] 1.497658e-30 ## ## $df ## [1] 300 ``` ] .pull-right[ - `Keiser-Meyer-Olkin` test (MKO) ```r KMO(bfi_c) # KMO test ``` ``` ## Kaiser-Meyer-Olkin factor adequacy ## Call: KMO(r = bfi_c) ## Overall MSA = 0.85 ## MSA for each item = ## A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 ## 0.75 0.84 0.87 0.88 0.90 0.84 0.80 0.85 0.83 0.86 0.84 0.88 0.90 0.88 0.89 0.78 ## N2 N3 N4 N5 O1 O2 O3 O4 O5 ## 0.78 0.86 0.89 0.86 0.86 0.78 0.84 0.77 0.76 ``` ] --- # Ekstrakcija faktora <br> <br> - `minres` : minimum residual [default] (slightly modi,ed methods: ols , wls , gls ) <br> - `mle` : Maximum Likelihood Estimation (MLE) <br> - `paf` : Principal Axes Factor (PAF) extraction <br> - `minchi` : minimum sample size weighted chi square <br> - `minrank` : minimum rank <br> - `alpha` : alpha factoring --- # `minres` metoda ```r # EFA sa 3 faktora f_bfi_minres <- fa(bfi_c,nfactors = 3,rotate = "none") # Sortiraj komunalnosti f_bfi_minres_common <- sort(f_bfi_minres$communality,decreasing = TRUE) # Pregled head(data.frame(f_bfi_minres_common),8) ``` ``` ## f_bfi_minres_common ## N1 0.5671549 ## N3 0.5611354 ## N2 0.5567788 ## E4 0.4892165 ## C4 0.4494178 ## N4 0.4491858 ## A5 0.4389367 ## E2 0.4208485 ``` --- # `minres` metoda ```r # Sortiraj jedinstvenosti f_bfi_minres_unique <- sort(f_bfi_minres$uniqueness,decreasing = TRUE) # Pregled head(data.frame(f_bfi_minres_unique),10) ``` ``` ## f_bfi_minres_unique ## A1 0.9383857 ## O5 0.9194360 ## O4 0.9180685 ## O2 0.9033127 ## O1 0.8399469 ## A4 0.8087487 ## O3 0.7693042 ## C3 0.7636974 ## E1 0.7349999 ## N5 0.7161468 ``` --- # `MLE` metoda ```r # MLE ekstrakcija f_bfi_mle <- fa(bfi_c, nfactors = 3, fm ="ml") ``` ``` ## Loading required namespace: GPArotation ``` ```r # Sortiraj komunalnost f_bfi_mle_common <- sort(f_bfi_mle$communality,decreasing = TRUE) # Pregled head(data.frame(f_bfi_mle_common),10) ``` ``` ## f_bfi_mle_common ## N1 0.6602592 ## N2 0.6427504 ## N3 0.5241467 ## E4 0.4912137 ## C4 0.4756779 ## A5 0.4348396 ## E2 0.4194426 ## C2 0.4188591 ## E3 0.4055702 ## N4 0.3923124 ``` --- # Koliko faktora zadržati? <br> - Kaiser-Guttman test - Scree test - Parallel analiza <br> ```r fa.parallel(bfi_c, n.obs = 200,fa = "fa", fm = "minres") # minres metoda ``` <img src="05_FA_files/figure-html/unnamed-chunk-22-1.png" style="display: block; margin: auto;" /> ``` ## Parallel analysis suggests that the number of factors = 5 and the number of components = NA ``` --- # Koliko faktora zadržati? ```r fa.parallel(bfi_c, n.obs = 200,fa = "fa", fm = "mle") # MLE metoda ``` <img src="05_FA_files/figure-html/unnamed-chunk-23-1.png" style="display: block; margin: auto;" /> ``` ## Parallel analysis suggests that the number of factors = 5 and the number of components = NA ``` --- # Rotacija faktora <br> <br> - Rotacija se radi zbog lakše interpretacije .pull_left[ ##### Ortogonalna - Quartimax - Equiumax - Varimax ] .pull_right[ ##### Zaobljena - Direct Oblimin - Promax ] --- # Rotacija faktora <br> <br> <br> <img src="../Foto/roto_fa.png" width="700px" style="display: block; margin: auto;" /> --- # Varimax rotacija ```r f_bfi_varimax <- fa(bfi_c,fm = "minres",nfactors = 5,rotate = "varimax") ``` <br> <img src="../Foto/varimax_fa.png" width="450px" style="display: block; margin: auto;" /> --- # Interpretacija ```r fa.diagram(f_bfi_varimax) ``` <img src="05_FA_files/figure-html/unnamed-chunk-27-1.png" style="display: block; margin: auto;" /> --- # Interpretacija .tiny[ ```r print(f_bfi_varimax$loadings, cut=0) ``` ``` ## ## Loadings: ## MR2 MR1 MR3 MR5 MR4 ## A1 0.111 0.040 0.023 -0.428 -0.078 ## A2 0.030 0.214 0.139 0.627 0.062 ## A3 0.009 0.318 0.109 0.651 0.056 ## A4 -0.066 0.205 0.231 0.436 -0.113 ## A5 -0.122 0.393 0.088 0.537 0.067 ## C1 0.010 0.070 0.546 0.039 0.210 ## C2 0.090 0.033 0.649 0.103 0.115 ## C3 -0.031 0.024 0.557 0.112 -0.005 ## C4 0.240 -0.065 -0.634 -0.037 -0.108 ## C5 0.290 -0.176 -0.562 -0.048 0.037 ## E1 0.043 -0.575 0.033 -0.105 -0.059 ## E2 0.245 -0.679 -0.102 -0.113 -0.042 ## E3 0.024 0.537 0.083 0.258 0.281 ## E4 -0.116 0.647 0.102 0.306 -0.073 ## E5 0.036 0.504 0.313 0.090 0.214 ## N1 0.787 0.079 -0.046 -0.216 -0.085 ## N2 0.754 0.027 -0.031 -0.194 -0.010 ## N3 0.732 -0.061 -0.067 -0.028 -0.004 ## N4 0.591 -0.345 -0.179 0.006 0.075 ## N5 0.538 -0.161 -0.037 0.101 -0.150 ## O1 -0.002 0.213 0.115 0.062 0.505 ## O2 0.176 0.005 -0.100 0.082 -0.469 ## O3 0.027 0.311 0.077 0.127 0.596 ## O4 0.221 -0.191 -0.022 0.155 0.369 ## O5 0.085 -0.005 -0.063 -0.010 -0.534 ## ## MR2 MR1 MR3 MR5 MR4 ## SS loadings 2.710 2.473 2.041 1.844 1.522 ## Proportion Var 0.108 0.099 0.082 0.074 0.061 ## Cumulative Var 0.108 0.207 0.289 0.363 0.424 ``` ] --- class: inverse, center, middle # Procjena kvalitete modela <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> (Koliko je pouzdana procjena!?) --- # Podijeli podatke <br> <br> ```r N <- nrow(bfi) indices <- seq(1, N) indices_EFA <- sample(indices, floor((.5*N))) indices_CFA <- indices[!(indices %in% indices_EFA)] bfi_EFA <- bfi[indices_EFA, ] bfi_CFA <- bfi[indices_CFA, ] ``` --- # Podijeli podatke ```r head(bfi_EFA, 2) ``` ``` ## A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 N2 N3 N4 N5 O1 O2 O3 O4 ## 64069 2 6 5 3 4 2 3 6 5 5 1 3 4 6 5 3 4 5 1 4 4 3 4 6 ## 64495 3 5 4 6 5 5 5 6 1 1 6 6 2 2 4 4 4 2 4 4 5 1 5 6 ## O5 gender education age ## 64069 3 2 4 24 ## 64495 2 1 4 28 ``` ```r head(bfi_CFA, 2) ``` ``` ## A1 A2 A3 A4 A5 C1 C2 C3 C4 C5 E1 E2 E3 E4 E5 N1 N2 N3 N4 N5 O1 O2 O3 O4 ## 61617 2 4 3 4 4 2 3 3 4 4 3 3 3 4 4 3 4 2 2 3 3 6 3 4 ## 61620 5 4 5 4 4 4 5 4 2 5 2 4 4 4 5 4 5 4 2 3 4 2 5 5 ## O5 gender education age ## 61617 3 1 NA 16 ## 61620 2 2 NA 17 ``` --- # Korelacijska matrica .tiny[ ```r bfi_EFA_cor <- cor(bfi_EFA, use = "pairwise.complete.obs") head(bfi_EFA_cor,4) ``` ``` ## A1 A2 A3 A4 A5 C1 C2 ## A1 1.0000000 -0.3352959 -0.2728057 -0.1375883 -0.1514420 0.01739205 0.01060102 ## A2 -0.3352959 1.0000000 0.4877745 0.3459091 0.3811325 0.12697746 0.14392010 ## A3 -0.2728057 0.4877745 1.0000000 0.3613521 0.4900486 0.12489855 0.13785354 ## A4 -0.1375883 0.3459091 0.3613521 1.0000000 0.3235077 0.09467829 0.23279038 ## C3 C4 C5 E1 E2 E3 ## A1 -0.01783306 0.1376209 0.04123172 0.1112480 0.09490553 -0.0283627 ## A2 0.23100935 -0.1588774 -0.12757642 -0.2207431 -0.22859332 0.2721867 ## A3 0.16741553 -0.1454697 -0.16289472 -0.2483077 -0.32009550 0.4171098 ## A4 0.13725781 -0.1463744 -0.20863281 -0.1310965 -0.18430445 0.1784194 ## E4 E5 N1 N2 N3 N4 ## A1 -0.06212886 -0.03560382 0.15099350 0.12728828 0.10307092 0.02589476 ## A2 0.30960792 0.29424172 -0.09966623 -0.07923077 -0.05475419 -0.10669241 ## A3 0.39248887 0.26610977 -0.10400972 -0.08546580 -0.05685266 -0.14574324 ## A4 0.30785232 0.16574148 -0.08886486 -0.12879214 -0.06764519 -0.13969324 ## N5 O1 O2 O3 O4 O5 ## A1 0.01821888 0.02036992 0.09238427 -0.06042714 -0.07379101 0.10281922 ## A2 0.02189162 0.12222326 0.02202875 0.15042011 0.08569123 -0.09351295 ## A3 -0.03098240 0.12210058 -0.02616394 0.23878685 0.02402204 -0.06915835 ## A4 0.03268684 0.06035262 0.04658407 0.07070544 -0.04244752 0.01176520 ## gender education age ## A1 -0.1186945 -0.13282060 -0.15790071 ## A2 0.1957883 -0.01801807 0.12943842 ## A3 0.1592532 -0.01504874 0.07515617 ## A4 0.1500163 -0.04727867 0.14161828 ``` ] --- # Svojsvene vrijednosti ```r scree(bfi_EFA_cor, factors = FALSE) ``` <img src="05_FA_files/figure-html/unnamed-chunk-32-1.png" style="display: block; margin: auto;" /> --- # Provedi FA .tiny[ ```r EFA_model <- fa(bfi_EFA, nfactors = 6) EFA_model ``` ``` ## Factor Analysis using method = minres ## Call: fa(r = bfi_EFA, nfactors = 6) ## Standardized loadings (pattern matrix) based upon correlation matrix ## MR2 MR1 MR3 MR5 MR4 MR6 h2 u2 com ## A1 0.07 -0.05 0.06 -0.55 0.00 0.37 0.371 0.63 1.9 ## A2 -0.01 -0.07 0.10 0.63 0.03 -0.01 0.473 0.53 1.1 ## A3 -0.05 -0.18 0.04 0.57 0.09 0.11 0.500 0.50 1.4 ## A4 -0.06 -0.08 0.19 0.40 -0.12 0.13 0.283 0.72 2.1 ## A5 -0.19 -0.20 0.02 0.44 0.08 0.21 0.458 0.54 2.5 ## C1 0.03 0.09 0.51 -0.02 0.18 0.08 0.325 0.68 1.4 ## C2 0.09 0.14 0.65 0.02 0.11 0.20 0.492 0.51 1.4 ## C3 0.03 0.09 0.54 0.12 -0.04 0.06 0.302 0.70 1.2 ## C4 0.07 0.06 -0.65 -0.04 -0.01 0.27 0.543 0.46 1.4 ## C5 0.14 0.16 -0.60 0.03 0.10 0.05 0.457 0.54 1.3 ## E1 -0.14 0.58 0.10 -0.15 -0.09 0.05 0.382 0.62 1.4 ## E2 0.03 0.73 0.00 -0.06 -0.06 0.03 0.590 0.41 1.0 ## E3 0.00 -0.32 0.01 0.16 0.37 0.28 0.486 0.51 3.2 ## E4 -0.07 -0.54 0.03 0.21 -0.02 0.27 0.546 0.45 1.9 ## E5 0.17 -0.41 0.25 0.05 0.26 0.00 0.415 0.59 2.9 ## N1 0.84 -0.11 0.01 -0.09 -0.04 -0.02 0.681 0.32 1.1 ## N2 0.80 -0.05 0.01 -0.06 0.03 -0.06 0.623 0.38 1.0 ## N3 0.68 0.12 -0.04 0.07 0.03 0.08 0.543 0.46 1.1 ## N4 0.45 0.39 -0.16 0.12 0.06 0.02 0.491 0.51 2.4 ## N5 0.46 0.20 -0.01 0.24 -0.18 0.15 0.396 0.60 2.5 ## O1 -0.02 -0.05 0.05 -0.06 0.56 0.09 0.338 0.66 1.1 ## O2 0.11 -0.02 -0.08 0.09 -0.41 0.28 0.284 0.72 2.2 ## O3 0.01 -0.06 0.02 0.04 0.66 0.05 0.487 0.51 1.0 ## O4 0.09 0.38 -0.01 0.18 0.34 0.02 0.246 0.75 2.6 ## O5 0.05 -0.05 -0.03 -0.02 -0.52 0.27 0.348 0.65 1.5 ## gender 0.19 -0.06 0.13 0.31 -0.18 -0.07 0.150 0.85 3.0 ## education -0.01 0.09 0.00 0.08 0.09 -0.21 0.062 0.94 2.1 ## age -0.02 0.02 0.07 0.24 -0.01 -0.23 0.103 0.90 2.2 ## ## MR2 MR1 MR3 MR5 MR4 MR6 ## SS loadings 2.52 2.19 2.09 1.95 1.78 0.84 ## Proportion Var 0.09 0.08 0.07 0.07 0.06 0.03 ## Cumulative Var 0.09 0.17 0.24 0.31 0.38 0.41 ## Proportion Explained 0.22 0.19 0.18 0.17 0.16 0.07 ## Cumulative Proportion 0.22 0.41 0.60 0.77 0.93 1.00 ## ## With factor correlations of ## MR2 MR1 MR3 MR5 MR4 MR6 ## MR2 1.00 0.24 -0.18 -0.06 -0.01 0.16 ## MR1 0.24 1.00 -0.22 -0.27 -0.20 -0.12 ## MR3 -0.18 -0.22 1.00 0.18 0.24 0.03 ## MR5 -0.06 -0.27 0.18 1.00 0.19 0.17 ## MR4 -0.01 -0.20 0.24 0.19 1.00 0.04 ## MR6 0.16 -0.12 0.03 0.17 0.04 1.00 ## ## Mean item complexity = 1.8 ## Test of the hypothesis that 6 factors are sufficient. ## ## The degrees of freedom for the null model are 378 and the objective function was 7.75 with Chi Square of 10763.45 ## The degrees of freedom for the model are 225 and the objective function was 0.66 ## ## The root mean square of the residuals (RMSR) is 0.03 ## The df corrected root mean square of the residuals is 0.03 ## ## The harmonic number of observations is 1374 with the empirical chi square 657.2 with prob < 6.4e-44 ## The total number of observations was 1400 with Likelihood Chi Square = 914.57 with prob < 7.3e-84 ## ## Tucker Lewis Index of factoring reliability = 0.888 ## RMSEA index = 0.047 and the 90 % confidence intervals are 0.044 0.05 ## BIC = -715.39 ## Fit based upon off diagonal values = 0.98 ## Measures of factor score adequacy ## MR2 MR1 MR3 MR5 MR4 MR6 ## Correlation of (regression) scores with factors 0.93 0.89 0.89 0.87 0.86 0.76 ## Multiple R square of scores with factors 0.86 0.80 0.78 0.76 0.74 0.58 ## Minimum correlation of possible factor scores 0.72 0.60 0.57 0.52 0.49 0.17 ``` ] --- # Faktorska opterećenja .tiny[ ```r EFA_model$loadings ``` ``` ## ## Loadings: ## MR2 MR1 MR3 MR5 MR4 MR6 ## A1 -0.548 0.369 ## A2 0.633 ## A3 -0.179 0.566 0.107 ## A4 0.194 0.397 -0.119 0.131 ## A5 -0.190 -0.201 0.438 0.214 ## C1 0.512 0.184 ## C2 0.138 0.654 0.105 0.197 ## C3 0.537 0.123 ## C4 -0.649 0.267 ## C5 0.140 0.163 -0.600 0.102 ## E1 -0.140 0.576 -0.147 ## E2 0.729 ## E3 -0.318 0.156 0.372 0.281 ## E4 -0.537 0.209 0.272 ## E5 0.168 -0.406 0.248 0.262 ## N1 0.841 -0.113 ## N2 0.804 ## N3 0.679 0.117 ## N4 0.455 0.385 -0.164 0.119 ## N5 0.462 0.197 0.237 -0.175 0.154 ## O1 0.555 ## O2 0.109 -0.412 0.281 ## O3 0.662 ## O4 0.376 0.181 0.338 ## O5 -0.525 0.266 ## gender 0.191 0.131 0.313 -0.177 ## education -0.214 ## age 0.241 -0.230 ## ## MR2 MR1 MR3 MR5 MR4 MR6 ## SS loadings 2.430 1.948 1.948 1.782 1.689 0.787 ## Proportion Var 0.087 0.070 0.070 0.064 0.060 0.028 ## Cumulative Var 0.087 0.156 0.226 0.290 0.350 0.378 ``` ] --- # Faktorski koeficijenti <br> <br> ```r head(EFA_model$scores) ``` ``` ## MR2 MR1 MR3 MR5 MR4 MR6 ## 64069 0.36384774 -0.5520311 -1.1317340 0.5768891 -0.3937724 0.3201839 ## 64495 0.07988474 1.6059104 1.2631588 -0.3233387 0.1540410 -0.7019641 ## 62795 0.54030891 0.4617641 -1.2126318 -0.1319860 -2.7327064 0.3696351 ## 62942 0.23525170 0.1962169 0.7800890 0.6559302 -0.3013955 0.1670891 ## 67238 0.06193102 0.1612078 -0.4647004 -1.6962687 0.2489364 0.3774843 ## 66264 NA NA NA NA NA NA ``` --- # Procjena kvalitete modela (fit) <br> <br> ##### Apsolutne mjere - Chi-square test: nesignifikanstnost - Tucker-Lewis Index (TLI) : > 0.90 - Root Mean Square Error of Approximation (RMSEA): < 0.05 ##### Relativne mjere - Bayesian Information Criterion (BIC) --- # Procjena kvalitete modela (relativna) ```r EFA_model <- fa(bfi_EFA, nfactors = 6) EFA_model ``` ```r bfi_theory <- fa(bfi_EFA, nfactors = 5) bfi_eigen <- fa(bfi_EFA, nfactors = 6) bfi_theory$BIC ``` ``` ## [1] -466.7392 ``` ```r bfi_eigen$BIC ``` ``` ## [1] -715.3859 ``` --- class: inverse, center, middle name: conf # KONFIRMATORNA FA (CFA) <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> (Teorija u pozadini...) --- # Razlozi za korištenje <br> <br> <br> - Eksplicitno specificiran odnos među varijablama <br> <br> - Testiranje teorije koja je unaprijed poznata <br> <br> - Pristup koji se koristi kod razvoja nove mjere --- # Skica I (*jedan konstrukt*) <br> <br> <img src="assets/8431578.png" width="614" style="display: block; margin: auto;" /> --- # Skica II (*više konstrukata*) <br> <br> <img src="assets/8697169.png" width="507" style="display: block; margin: auto;" /> --- # Podatci ```r hz <- lavaan::HolzingerSwineford1939 hz %>% dplyr::glimpse() ``` ``` ## Rows: 301 ## Columns: 15 ## $ id <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, ~ ## $ sex <int> 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, ~ ## $ ageyr <int> 13, 13, 13, 13, 12, 14, 12, 12, 13, 12, 12, 12, 12, 12, 12, 12,~ ## $ agemo <int> 1, 7, 1, 2, 2, 1, 1, 2, 0, 5, 2, 11, 7, 8, 6, 1, 11, 5, 8, 3, 1~ ## $ school <fct> Pasteur, Pasteur, Pasteur, Pasteur, Pasteur, Pasteur, Pasteur, ~ ## $ grade <int> 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, ~ ## $ x1 <dbl> 3.333333, 5.333333, 4.500000, 5.333333, 4.833333, 5.333333, 2.8~ ## $ x2 <dbl> 7.75, 5.25, 5.25, 7.75, 4.75, 5.00, 6.00, 6.25, 5.75, 5.25, 5.7~ ## $ x3 <dbl> 0.375, 2.125, 1.875, 3.000, 0.875, 2.250, 1.000, 1.875, 1.500, ~ ## $ x4 <dbl> 2.333333, 1.666667, 1.000000, 2.666667, 2.666667, 1.000000, 3.3~ ## $ x5 <dbl> 5.75, 3.00, 1.75, 4.50, 4.00, 3.00, 6.00, 4.25, 5.75, 5.00, 3.5~ ## $ x6 <dbl> 1.2857143, 1.2857143, 0.4285714, 2.4285714, 2.5714286, 0.857142~ ## $ x7 <dbl> 3.391304, 3.782609, 3.260870, 3.000000, 3.695652, 4.347826, 4.6~ ## $ x8 <dbl> 5.75, 6.25, 3.90, 5.30, 6.30, 6.65, 6.20, 5.15, 4.65, 4.55, 5.7~ ## $ x9 <dbl> 6.361111, 7.916667, 4.416667, 4.861111, 5.916667, 7.500000, 4.8~ ``` .footnote[[*] Vidi detalje o podatcima na [poveznici](https://rdrr.io/cran/lavaan/man/HolzingerSwineford1939.html).] --- # Definiraj model <br> <br> <br> ##### Sintaksa za definiranje CFA modela: ```r hz.model <- ' visual =~ x1 + x2 + x3 writing =~ x4 + x5 + x6 maths =~ x7 + x8 + x9 ' ``` .footnote[ [*]Za detalje o lavaan projektu pogledajte [stranicu](https://lavaan.ugent.be/tutorial/syntax1.html).] --- # Provedi model .tiny[ ```r hz.fit <- lavaan::cfa(hz.model, data=hz) lavaan::summary(hz.fit, fit.measures=TRUE) ``` ``` ## lavaan 0.6-8 ended normally after 35 iterations ## ## Estimator ML ## Optimization method NLMINB ## Number of model parameters 21 ## ## Number of observations 301 ## ## Model Test User Model: ## ## Test statistic 85.306 ## Degrees of freedom 24 ## P-value (Chi-square) 0.000 ## ## Model Test Baseline Model: ## ## Test statistic 918.852 ## Degrees of freedom 36 ## P-value 0.000 ## ## User Model versus Baseline Model: ## ## Comparative Fit Index (CFI) 0.931 ## Tucker-Lewis Index (TLI) 0.896 ## ## Loglikelihood and Information Criteria: ## ## Loglikelihood user model (H0) -3737.745 ## Loglikelihood unrestricted model (H1) -3695.092 ## ## Akaike (AIC) 7517.490 ## Bayesian (BIC) 7595.339 ## Sample-size adjusted Bayesian (BIC) 7528.739 ## ## Root Mean Square Error of Approximation: ## ## RMSEA 0.092 ## 90 Percent confidence interval - lower 0.071 ## 90 Percent confidence interval - upper 0.114 ## P-value RMSEA <= 0.05 0.001 ## ## Standardized Root Mean Square Residual: ## ## SRMR 0.065 ## ## Parameter Estimates: ## ## Standard errors Standard ## Information Expected ## Information saturated (h1) model Structured ## ## Latent Variables: ## Estimate Std.Err z-value P(>|z|) ## visual =~ ## x1 1.000 ## x2 0.554 0.100 5.554 0.000 ## x3 0.729 0.109 6.685 0.000 ## writing =~ ## x4 1.000 ## x5 1.113 0.065 17.014 0.000 ## x6 0.926 0.055 16.703 0.000 ## maths =~ ## x7 1.000 ## x8 1.180 0.165 7.152 0.000 ## x9 1.082 0.151 7.155 0.000 ## ## Covariances: ## Estimate Std.Err z-value P(>|z|) ## visual ~~ ## writing 0.408 0.074 5.552 0.000 ## maths 0.262 0.056 4.660 0.000 ## writing ~~ ## maths 0.173 0.049 3.518 0.000 ## ## Variances: ## Estimate Std.Err z-value P(>|z|) ## .x1 0.549 0.114 4.833 0.000 ## .x2 1.134 0.102 11.146 0.000 ## .x3 0.844 0.091 9.317 0.000 ## .x4 0.371 0.048 7.779 0.000 ## .x5 0.446 0.058 7.642 0.000 ## .x6 0.356 0.043 8.277 0.000 ## .x7 0.799 0.081 9.823 0.000 ## .x8 0.488 0.074 6.573 0.000 ## .x9 0.566 0.071 8.003 0.000 ## visual 0.809 0.145 5.564 0.000 ## writing 0.979 0.112 8.737 0.000 ## maths 0.384 0.086 4.451 0.000 ``` ] --- # Prikaži grafički ```r semPlot::semPaths(hz.fit) ``` <img src="05_FA_files/figure-html/unnamed-chunk-44-1.png" style="display: block; margin: auto;" /> --- # Prikaži grafički ```r semPlot::semPaths(hz.fit, "std") ``` <img src="05_FA_files/figure-html/unnamed-chunk-45-1.png" style="display: block; margin: auto;" /> --- # Kvaliteta procjene (Fit) <br> <br> ```r lavaan::fitmeasures(hz.fit, c('cfi', 'rmsea', 'rmsea.ci.upper', 'bic')) ``` ``` ## cfi rmsea rmsea.ci.upper bic ## 0.931 0.092 0.114 7595.339 ``` --- class: inverse, center, middle # Hvala na pažnji <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> (Nastavak: Klaster analiza)